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,
42 Storage<Scalar> alpha3,
43 Storage<Scalar> alpha4,
44 Storage<Scalar> alpha5,
46 : alpha0_(alpha0)
47 , alpha1_(alpha1)
48 , alpha2_(alpha2)
49 , alpha3_(alpha3)
50 , alpha4_(alpha4)
51 , alpha5_(alpha5)
52 , moduleParams_(moduleParams)
53 {
54 }
55
56 OPM_HOST_DEVICE Scalar getAlpha(unsigned globalIndex, unsigned boundaryFaceIndex) const
57 {
58 if (boundaryFaceIndex == 0) {
59 return alpha0_[globalIndex];
60 } else if (boundaryFaceIndex == 1) {
61 return alpha1_[globalIndex];
62 } else if (boundaryFaceIndex == 2) {
63 return alpha2_[globalIndex];
64 } else if (boundaryFaceIndex == 3) {
65 return alpha3_[globalIndex];
66 } else if (boundaryFaceIndex == 4) {
67 return alpha4_[globalIndex];
68 } else if (boundaryFaceIndex == 5) {
69 return alpha5_[globalIndex];
70 } else {
71 OPM_THROW(std::logic_error, "Invalid boundary face index");
72 }
73 }
74
75 OPM_HOST_DEVICE const ModuleParams& moduleParams() const
76 {
77 return moduleParams_;
78 }
79 OPM_HOST_DEVICE ModuleParams& moduleParams()
80 {
81 return moduleParams_;
82 }
83
84 Storage<Scalar>& alpha0()
85 {
86 return alpha0_;
87 }
88
89 Storage<Scalar>& alpha1()
90 {
91 return alpha1_;
92 }
93
94 Storage<Scalar>& alpha2()
95 {
96 return alpha2_;
97 }
98
99 Storage<Scalar>& alpha3()
100 {
101 return alpha3_;
102 }
103
104 Storage<Scalar>& alpha4()
105 {
106 return alpha4_;
107 }
108
109 Storage<Scalar>& alpha5()
110 {
111 return alpha5_;
112 }
113
114private:
115 Storage<Scalar> alpha0_;
116 Storage<Scalar> alpha1_;
117 Storage<Scalar> alpha2_;
118 Storage<Scalar> alpha3_;
119 Storage<Scalar> alpha4_;
120 Storage<Scalar> alpha5_;
121 ModuleParams moduleParams_;
122};
123
124namespace gpuistl
125{
126
127 template <class Scalar>
128 ThermalGasWaterFlowProblem<Scalar, GpuBuffer>
130 {
133 GpuBuffer<Scalar>(cpuProblem.alpha0()),
134 GpuBuffer<Scalar>(cpuProblem.alpha1()),
135 GpuBuffer<Scalar>(cpuProblem.alpha2()),
136 GpuBuffer<Scalar>(cpuProblem.alpha3()),
137 GpuBuffer<Scalar>(cpuProblem.alpha4()),
138 GpuBuffer<Scalar>(cpuProblem.alpha5()),
139 ModuleParams {copy_to_gpu(cpuProblem.moduleParams().convectiveMixingModuleParam)});
140 }
141
142 template <class Scalar>
145 {
148 make_view(buffer.alpha0()),
149 make_view(buffer.alpha1()),
150 make_view(buffer.alpha2()),
151 make_view(buffer.alpha3()),
152 make_view(buffer.alpha4()),
153 make_view(buffer.alpha5()),
154 ModuleParams {make_view(buffer.moduleParams().convectiveMixingModuleParam)});
155 }
156
157} // namespace gpuistl
158
159} // namespace Opm
160
161#endif // THERMAL_GASWATER_FLOW_PROBLEM_HPP
Definition: ThermalGasWaterFlowProblem.hpp:33
Storage< Scalar > & alpha4()
Definition: ThermalGasWaterFlowProblem.hpp:104
Storage< Scalar > & alpha5()
Definition: ThermalGasWaterFlowProblem.hpp:109
Storage< Scalar > & alpha0()
Definition: ThermalGasWaterFlowProblem.hpp:84
Storage< Scalar > & alpha3()
Definition: ThermalGasWaterFlowProblem.hpp:99
BlackoilModuleParams< ConvectiveMixingModuleParam< Scalar, Storage > > ModuleParams
Definition: ThermalGasWaterFlowProblem.hpp:35
Storage< Scalar > & alpha2()
Definition: ThermalGasWaterFlowProblem.hpp:94
OPM_HOST_DEVICE const ModuleParams & moduleParams() const
Definition: ThermalGasWaterFlowProblem.hpp:75
Storage< Scalar > & alpha1()
Definition: ThermalGasWaterFlowProblem.hpp:89
ThermalGasWaterFlowProblem(Storage< Scalar > alpha0, Storage< Scalar > alpha1, Storage< Scalar > alpha2, Storage< Scalar > alpha3, Storage< Scalar > alpha4, Storage< Scalar > alpha5, ModuleParams moduleParams)
Definition: ThermalGasWaterFlowProblem.hpp:39
OPM_HOST_DEVICE Scalar getAlpha(unsigned globalIndex, unsigned boundaryFaceIndex) const
Definition: ThermalGasWaterFlowProblem.hpp:56
OPM_HOST_DEVICE ModuleParams & moduleParams()
Definition: ThermalGasWaterFlowProblem.hpp:79
Definition: GpuFlowProblem.hpp:50
inline ::Opm::NoThermalLawManager make_view(::Opm::NoThermalLawManager &)
make_view overload for the no-op thermal manager.
Definition: GpuFlowProblem.hpp:101
inline ::Opm::NoThermalLawManager copy_to_gpu(const ::Opm::NoThermalLawManager &)
copy_to_gpu overload for the no-op thermal manager.
Definition: GpuFlowProblem.hpp:94
Definition: blackoilbioeffectsmodules.hh:45
Definition: blackoilmoduleparams.hh:22