ThermalGasWaterFlowProblem.hpp
Go to the documentation of this file.
1/*
2 Copyright 2026 Equinor ASA
3 This file is part of the Open Porous Media project (OPM).
4 OPM is free software: you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation, either version 3 of the License, or
7 (at your option) any later version.
8 OPM is distributed in the hope that it will be useful,
9 but WITHOUT ANY WARRANTY; without even the implied warranty of
10 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 GNU General Public License for more details.
12 You should have received a copy of the GNU General Public License
13 along with OPM. If not, see <http://www.gnu.org/licenses/>.
14*/
15
16#ifndef THERMAL_GASWATER_FLOW_PROBLEM_HPP
17#define THERMAL_GASWATER_FLOW_PROBLEM_HPP
18
19#include <opm/common/ErrorMacros.hpp>
20#include <opm/common/utility/VectorWithDefaultAllocator.hpp>
21#include <opm/common/utility/gpuDecorators.hpp>
22#include <opm/common/utility/gpuistl_if_available.hpp>
23
24/*
25 A simple gas-water flow problem with thermal effects that is GPU compatible
26*/
27
28namespace Opm
29{
30
31template <class Scalar, template <class> class Storage = Opm::VectorWithDefaultAllocator>
33{
34public:
36
38
40 Storage<Scalar> alpha1,
41 Storage<Scalar> alpha2,
43 : alpha0_(alpha0)
44 , alpha1_(alpha1)
45 , alpha2_(alpha2)
46 , moduleParams_(moduleParams)
47 {
48 }
49
50 OPM_HOST_DEVICE Scalar getAlpha(unsigned globalIndex, unsigned boundaryFaceIndex) const
51 {
52 if (boundaryFaceIndex == 0) {
53 return alpha0_[globalIndex];
54 } else if (boundaryFaceIndex == 1) {
55 return alpha1_[globalIndex];
56 } else if (boundaryFaceIndex == 2) {
57 return alpha2_[globalIndex];
58 } else {
59 OPM_THROW(std::logic_error, "Invalid boundary face index");
60 }
61 }
62
63 OPM_HOST_DEVICE const ModuleParams& moduleParams() const
64 {
65 return moduleParams_;
66 }
67 OPM_HOST_DEVICE ModuleParams& moduleParams()
68 {
69 return moduleParams_;
70 }
71
72 Storage<Scalar>& alpha0()
73 {
74 return alpha0_;
75 }
76
77 Storage<Scalar>& alpha1()
78 {
79 return alpha1_;
80 }
81
82 Storage<Scalar>& alpha2()
83 {
84 return alpha2_;
85 }
86
87private:
88 Storage<Scalar> alpha0_;
89 Storage<Scalar> alpha1_;
90 Storage<Scalar> alpha2_;
91 ModuleParams moduleParams_;
92};
93
94namespace gpuistl
95{
96
97 template <class Scalar>
100 {
103 GpuBuffer<Scalar>(cpuProblem.alpha0()),
104 GpuBuffer<Scalar>(cpuProblem.alpha1()),
105 GpuBuffer<Scalar>(cpuProblem.alpha2()),
106 ModuleParams {copy_to_gpu(cpuProblem.moduleParams().convectiveMixingModuleParam)});
107 }
108
109 template <class Scalar>
112 {
115 make_view(buffer.alpha0()),
116 make_view(buffer.alpha1()),
117 make_view(buffer.alpha2()),
118 ModuleParams {make_view(buffer.moduleParams().convectiveMixingModuleParam)});
119 }
120
121} // namespace gpuistl
122
123} // namespace Opm
124
125#endif // THERMAL_GASWATER_FLOW_PROBLEM_HPP
Definition: ThermalGasWaterFlowProblem.hpp:33
Storage< Scalar > & alpha0()
Definition: ThermalGasWaterFlowProblem.hpp:72
BlackoilModuleParams< ConvectiveMixingModuleParam< Scalar, Storage > > ModuleParams
Definition: ThermalGasWaterFlowProblem.hpp:35
Storage< Scalar > & alpha2()
Definition: ThermalGasWaterFlowProblem.hpp:82
ThermalGasWaterFlowProblem(Storage< Scalar > alpha0, Storage< Scalar > alpha1, Storage< Scalar > alpha2, ModuleParams moduleParams)
Definition: ThermalGasWaterFlowProblem.hpp:39
OPM_HOST_DEVICE const ModuleParams & moduleParams() const
Definition: ThermalGasWaterFlowProblem.hpp:63
Storage< Scalar > & alpha1()
Definition: ThermalGasWaterFlowProblem.hpp:77
OPM_HOST_DEVICE Scalar getAlpha(unsigned globalIndex, unsigned boundaryFaceIndex) const
Definition: ThermalGasWaterFlowProblem.hpp:50
OPM_HOST_DEVICE ModuleParams & moduleParams()
Definition: ThermalGasWaterFlowProblem.hpp:67
ThermalGasWaterFlowProblem< Scalar, GpuView > make_view(ThermalGasWaterFlowProblem< Scalar, GpuBuffer > &buffer)
Definition: ThermalGasWaterFlowProblem.hpp:111
ThermalGasWaterFlowProblem< Scalar, GpuBuffer > copy_to_gpu(ThermalGasWaterFlowProblem< Scalar, Opm::VectorWithDefaultAllocator > &cpuProblem)
Definition: ThermalGasWaterFlowProblem.hpp:99
Definition: blackoilbioeffectsmodules.hh:45
Definition: blackoilmoduleparams.hh:22