opm-simulators
flow_comp.hpp
1 /*
2  Copyright 2024, 2026, SINTEF Digital
3 
4  This file is part of the Open Porous Media project (OPM).
5 
6  OPM is free software: you can redistribute it and/or modify
7  it under the terms of the GNU General Public License as published by
8  the Free Software Foundation, either version 3 of the License, or
9  (at your option) any later version.
10 
11  OPM is distributed in the hope that it will be useful,
12  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  GNU General Public License for more details.
15 
16  You should have received a copy of the GNU General Public License
17  along with OPM. If not, see <http://www.gnu.org/licenses/>.
18 */
19 #ifndef FLOW_COMP_HPP
20 #define FLOW_COMP_HPP
21 
22 #include <memory>
23 
24 #include <opm/material/constraintsolvers/PTFlash.hpp>
25 #include <opm/material/fluidsystems/GenericOilGasWaterFluidSystem.hpp>
26 
30 
31 #include <opm/simulators/flow/Main.hpp>
34 
36 
37 #include <flowexperimental/comp/EmptyModel.hpp>
38 #include <flowexperimental/comp/wells/CompWellModel.hpp>
39 
40 // // the current code use eclnewtonmethod adding other conditions to proceed_ should do the trick for KA
41 // // adding linearshe sould be chaning the update_ function in the same class with condition that the error is reduced.
42 // the trick is to be able to recalculate the residual from here.
43 // unsure where the timestepping is done from suggestedtime??
44 // suggestTimeStep is taken from newton solver in problem.limitTimestep
45 namespace Opm {
46 
47 template<int numComp, bool EnableWater>
48 int dispatchFlowComp(int argc, char** argv);
49 
50 } // namespace Opm
51 
52 namespace Opm::Properties {
53 
54 template <class TypeTag, class MyTypeTag>
55 struct DiscNewtonMethod;
56 
57 template <class TypeTag, class MyTypeTag>
58 struct WellModel;
59 
60 template <class TypeTag, class MyTypeTag>
61 struct TracerModel;
62 
63 namespace TTag {
64 
65 template<int NumComp, bool EnableWater>
67  using InheritsFrom = std::tuple<FlowBaseProblemComp, FlashModel>;
68 };
69 
70 }
71 
72 template<class TypeTag, int NumComp, bool EnableWater>
73 struct SparseMatrixAdapter<TypeTag, TTag::FlowCompProblem<NumComp, EnableWater>>
74 {
75 private:
77  enum { numEq = getPropValue<TypeTag, Properties::NumEq>() };
79 
80 public:
81  using type = typename Linear::IstlSparseMatrixAdapter<Block>;
82 };
83 
84 // NOTE: Do NOT override NewtonMethod here.
85 // The inherited model configuration decides the solver implementation.
86 
87 #if 0
88 template<class TypeTag>
89 struct SolidEnergyLaw<TypeTag, TTag::FlowCompProblem>
90 {
91 private:
94 
95 public:
96  using EclThermalLawManager = ::Opm::EclThermalLawManager<Scalar, FluidSystem>;
97 
98  using type = typename EclThermalLawManager::SolidEnergyLaw;
99 };
100 
101 // Set the material law for thermal conduction
102 template<class TypeTag>
103 struct ThermalConductionLaw<TypeTag, TTag::FlowCompProblem>
104 {
105 private:
108 
109 public:
110  using EclThermalLawManager = ::Opm::EclThermalLawManager<Scalar, FluidSystem>;
111 
112  using type = typename EclThermalLawManager::ThermalConductionLaw;
113 };
114 
115 
116 template <class TypeTag>
117 struct SpatialDiscretizationSplice<TypeTag, TTag::FlowCompProblem>
118 {
119  using type = TTag::EcfvDiscretization;
120 };
121 
122 template <class TypeTag>
123 struct LocalLinearizerSplice<TypeTag, TTag::FlowCompProblem>
124 {
125  using type = TTag::AutoDiffLocalLinearizer;
126 };
127 #endif
128 
129 // Set the problem property
130 template <class TypeTag, int NumComp, bool EnableWater>
131 struct Problem<TypeTag, TTag::FlowCompProblem<NumComp, EnableWater>>
132 {
134 };
135 
136 template<class TypeTag, int NumComp, bool EnableWater>
137 struct AquiferModel<TypeTag, TTag::FlowCompProblem<NumComp, EnableWater>> {
138  using type = EmptyModel<TypeTag>;
139 };
140 
141 template<class TypeTag, int NumComp, bool EnableWater>
142 struct WellModel<TypeTag, TTag::FlowCompProblem<NumComp, EnableWater>> {
144 };
145 
146 template<class TypeTag, int NumComp, bool EnableWater>
147 struct TracerModel<TypeTag, TTag::FlowCompProblem<NumComp, EnableWater>> {
148  using type = EmptyModel<TypeTag>;
149 };
150 
151 
152 template <class TypeTag, int NumComp, bool EnableWater>
153 struct FlashSolver<TypeTag, TTag::FlowCompProblem<NumComp, EnableWater>> {
154 private:
158 
159 public:
160  using type = Opm::PTFlash<Scalar, FluidSystem>;
161 };
162 
163 
164 template <class TypeTag, class MyTypeTag>
165 struct NumComp { using type = UndefinedProperty; };
166 
167 // TODO: this is unfortunate, have to check why we need to hard-code it
168 template <class TypeTag, int NumComp_, bool EnableWater_>
169 struct NumComp<TypeTag, TTag::FlowCompProblem<NumComp_, EnableWater_>> {
170  static constexpr int value = NumComp_;
171 };
172 
173 template <class TypeTag, class MyTypeTag>
175 
176 template <class TypeTag, int NumComp_, bool EnableWater_>
177 struct EnableDummyWater<TypeTag, TTag::FlowCompProblem<NumComp_, EnableWater_>> {
178  static constexpr bool value = EnableWater_;
179 };
180 #if 0
181 struct Temperature { using type = UndefinedProperty; };
182 
183  template <class TypeTag>
184  struct Temperature<TypeTag, TTag::FlowCompProblem> {
185  using type = GetPropType<TypeTag, Scalar>;
186  static constexpr type value = 423.25;
187  };
188 #endif
189 
190 template <class TypeTag, int NumComp_, bool EnableWater_>
191 struct FluidSystem<TypeTag, TTag::FlowCompProblem<NumComp_, EnableWater_>>
192 {
193 private:
195  static constexpr int num_comp = getPropValue<TypeTag, Properties::NumComp>();
196  static constexpr bool enable_water = getPropValue<TypeTag, Properties::EnableDummyWater>();
197 
198 public:
199  using type = Opm::GenericOilGasWaterFluidSystem<Scalar, num_comp, enable_water>;
200 };
201 template<class TypeTag, int NumComp, bool EnableWater>
202 struct EnableMech<TypeTag, TTag::FlowCompProblem<NumComp, EnableWater>> {
203  static constexpr bool value = false;
204 };
205 
206 template<class TypeTag, int NumComp, bool EnableWater>
207 struct EnableDisgasInWater<TypeTag, TTag::FlowCompProblem<NumComp, EnableWater>> {
208  static constexpr bool value = false;
209 };
210 
211 template<class TypeTag, int NumComp, bool EnableWater>
212 struct Stencil<TypeTag, TTag::FlowCompProblem<NumComp, EnableWater>>
213 {
214 private:
217 
218 public:
220 };
221 
222 template<class TypeTag, int NumComp, bool EnableWater>
223 struct EnableApiTracking<TypeTag, TTag::FlowCompProblem<NumComp, EnableWater>> {
224  static constexpr bool value = false;
225 };
226 
227 template<class TypeTag, int NumComp, bool EnableWater>
228 struct EnableSaltPrecipitation<TypeTag, TTag::FlowCompProblem<NumComp, EnableWater>> {
229  static constexpr bool value = false;
230 };
231 template<class TypeTag, int NumComp, bool EnableWater>
232 struct EnablePolymerMW<TypeTag, TTag::FlowCompProblem<NumComp, EnableWater>> {
233  static constexpr bool value = false;
234 };
235 
236 template<class TypeTag, int NumComp, bool EnableWater>
237 struct EnablePolymer<TypeTag, TTag::FlowCompProblem<NumComp, EnableWater>> {
238  static constexpr bool value = false;
239 };
240 
241 template<class TypeTag, int NumComp, bool EnableWater>
242 struct EnableDispersion<TypeTag, TTag::FlowCompProblem<NumComp, EnableWater>> {
243  static constexpr bool value = false;
244 };
245 
246 template<class TypeTag, int NumComp, bool EnableWater>
247 struct EnableBrine<TypeTag, TTag::FlowCompProblem<NumComp, EnableWater>> {
248  static constexpr bool value = false;
249 };
250 template<class TypeTag, int NumComp, bool EnableWater>
251 struct EnableVapwat<TypeTag, TTag::FlowCompProblem<NumComp, EnableWater>> {
252  static constexpr bool value = false;
253 };
254 
255 template<class TypeTag, int NumComp, bool EnableWater>
256 struct EnableSolvent<TypeTag, TTag::FlowCompProblem<NumComp, EnableWater>> {
257  static constexpr bool value = false;
258 };
259 template<class TypeTag, int NumComp, bool EnableWater>
260 struct EnableFoam<TypeTag, TTag::FlowCompProblem<NumComp, EnableWater>> {
261  static constexpr bool value = false;
262 };
263 template<class TypeTag, int NumComp, bool EnableWater>
264 struct EnableExtbo<TypeTag, TTag::FlowCompProblem<NumComp, EnableWater>> {
265  static constexpr bool value = false;
266 };
267 template<class TypeTag, int NumComp, bool EnableWater>
268 struct EnableBioeffects<TypeTag, TTag::FlowCompProblem<NumComp, EnableWater>> {
269  static constexpr bool value = false;
270 };
271 
272 template<class TypeTag, int NumComp, bool EnableWater>
273 struct EnableDebuggingChecks<TypeTag, TTag::FlowCompProblem<NumComp, EnableWater>>{
274  static constexpr bool value = false;
275 };
276 
277 // disable thermal flux boundaries by default
278 #if 0
279 template<class TypeTag>
280 struct EnableThermalFluxBoundaries<TypeTag, TTag::FlowCompProblem> {
281  static constexpr bool value = false;
282 };
283 #endif
284 
285 } // namespace Opm::Properties
286 
287 // dispatchFlowComp() is only declared here; each (numComp, EnableWater)
288 // combination is defined as an explicit specialization in its own translation
289 // unit (flow_comp_dispatch<N>.cpp / flow_comp_dispatch<N>_2p.cpp). Keeping the
290 // definition out of this header limits each translation unit to a single
291 // instantiation of the simulator stack, so per-process compile memory stays
292 // bounded and the configurations compile in parallel.
293 
294 #endif
Definition: flow_comp.hpp:174
The multi-dimensional Newton method.
Definition: FlowBaseProblemProperties.hpp:103
The class describing the stencil of the spatial discretization.
Definition: fvbaseproperties.hh:76
Implements a generic linear solver abstraction.
Definition: blackoilproperties.hh:86
Enable dispersive fluxes?
Definition: multiphasebaseproperties.hh:95
typename Properties::Detail::GetPropImpl< TypeTag, Property >::type::type GetPropType
get the type alias defined in the property (equivalent to old macro GET_PROP_TYPE(...))
Definition: propertysystem.hh:233
Definition: FlowBaseProblemProperties.hpp:68
Enable the ECL-blackoil extension for polymer.
Definition: blackoilproperties.hh:51
A compositional multi-phase model based on flash-calculations
Represents the stencil (finite volume geometry) of a single element in the ECFV discretization.
Definition: ecfvstencil.hh:68
Definition: FlowBaseProblemProperties.hpp:73
Base class for specifying auxiliary equations.
Enable the ECL-blackoil extension for disolution of gas into water.
Definition: blackoilproperties.hh:79
Enable the ECL-blackoil extension for water evaporation.
Definition: blackoilproperties.hh:75
a tag to mark properties as undefined
Definition: propertysystem.hh:38
Definition: matrixblock.hh:228
This problem simulates an input file given in the data format used by the commercial ECLiPSE simulato...
Definition: FlowProblemComp.hpp:59
The class that allows to manipulate sparse matrices.
Definition: linalgproperties.hh:50
Enable the ECL-blackoil extension for salt precipitation.
Definition: blackoilproperties.hh:71
Structs needed for tpfalinearizer and its gpuparams struct extracted to be defined in one place that ...
Definition: blackoilbioeffectsmodules.hh:45
Definition: FlowBaseProblemProperties.hpp:94
Enable the ECL-blackoil extension for solvents. ("Second gas")
Definition: blackoilproperties.hh:43
The fluid systems including the information about the phases.
Definition: multiphasebaseproperties.hh:79
Enable the ECL-blackoil extension for foam.
Definition: blackoilproperties.hh:63
Enable the ECL-blackoil extension for extended BO. ("Second gas" - alternative approach) ...
Definition: blackoilproperties.hh:47
Definition: FlowBaseProblemProperties.hpp:98
Enable the ECL-blackoil extension for bioeffects (biofilm/MICP)
Definition: blackoilproperties.hh:83
Property to specify the type of scalar values.
Definition: basicproperties.hh:76
The type of the problem.
Definition: fvbaseproperties.hh:87
Definition: flow_comp.hpp:165
A sparse matrix interface backend for BCRSMatrix from dune-istl.
Definition: istlsparsematrixadapter.hh:42
Definition: EmptyModel.hpp:33
Definition: FlowBaseProblemProperties.hpp:79
Definition: flow_comp.hpp:66
Definition: CompWellModel.hpp:51
Enable the ECL-blackoil extension for salt.
Definition: blackoilproperties.hh:67
The material law for the energy stored in the solid matrix.
Definition: multiphasebaseproperties.hh:63
This problem simulates an input file given in the data format used by the commercial ECLiPSE simulato...
Definition: blackoilmodel.hh:75
The type of the flash constraint solver.
Definition: flashproperties.hh:39
Enable the tracking polymer molecular weight tracking and related functionalities.
Definition: blackoilproperties.hh:55