27 #ifndef OPM_ECL_MULTIPLEXER_MATERIAL_PARAMS_HPP 28 #define OPM_ECL_MULTIPLEXER_MATERIAL_PARAMS_HPP 37 #include <type_traits> 43 enum class EclMultiplexerApproach {
51 template <EclMultiplexerApproach ApproachArg>
54 static constexpr
auto approach = ApproachArg;
58 template <
typename ...Args>
60 template <EclMultiplexerApproach Value,
typename ...Args>
62 template <
typename ...Args>
73 template<
class Traits,
class GasOilMaterialLawT,
class OilWaterMaterialLawT,
class GasWaterMaterialLawT>
76 using Scalar =
typename Traits::Scalar;
77 enum { numPhases = 3 };
84 using Stone1Params =
typename Stone1Material::Params;
85 using Stone2Params =
typename Stone2Material::Params;
86 using DefaultParams =
typename DefaultMaterial::Params;
87 using TwoPhaseParams =
typename TwoPhaseMaterial::Params;
89 template <
class ParamT>
92 inline void operator () (
void* ptr )
94 delete static_cast< ParamT*
> (ptr);
98 using ParamPointerType = std::shared_ptr<void>;
113 setApproach( other.approach() );
119 setApproach( other.approach() );
123 void setApproach(EclMultiplexerApproach newApproach)
125 assert(realParams_ == 0);
126 approach_ = newApproach;
128 switch (approach()) {
129 case EclMultiplexerApproach::Stone1:
130 realParams_ = ParamPointerType(
new Stone1Params, Deleter< Stone1Params > () );
133 case EclMultiplexerApproach::Stone2:
134 realParams_ = ParamPointerType(
new Stone2Params, Deleter< Stone2Params > () );
137 case EclMultiplexerApproach::Default:
138 realParams_ = ParamPointerType(
new DefaultParams, Deleter< DefaultParams > () );
141 case EclMultiplexerApproach::TwoPhase:
142 realParams_ = ParamPointerType(
new TwoPhaseParams, Deleter< TwoPhaseParams > () );
145 case EclMultiplexerApproach::OnePhase:
151 EclMultiplexerApproach approach()
const 152 {
return approach_; }
155 template <EclMultiplexerApproach approachV>
156 typename std::enable_if<approachV == EclMultiplexerApproach::Stone1, Stone1Params>::type&
159 assert(approach() == approachV);
160 return this->
template castTo<Stone1Params>();
163 template <EclMultiplexerApproach approachV>
164 typename std::enable_if<approachV == EclMultiplexerApproach::Stone1, const Stone1Params>::type&
165 getRealParams()
const 167 assert(approach() == approachV);
168 return this->
template castTo<Stone1Params>();
172 template <EclMultiplexerApproach approachV>
173 typename std::enable_if<approachV == EclMultiplexerApproach::Stone2, Stone2Params>::type&
176 assert(approach() == approachV);
177 return this->
template castTo<Stone2Params>();
180 template <EclMultiplexerApproach approachV>
181 typename std::enable_if<approachV == EclMultiplexerApproach::Stone2, const Stone2Params>::type&
182 getRealParams()
const 184 assert(approach() == approachV);
185 return this->
template castTo<Stone2Params>();
189 template <EclMultiplexerApproach approachV>
190 typename std::enable_if<approachV == EclMultiplexerApproach::Default, DefaultParams>::type&
193 assert(approach() == approachV);
194 return this->
template castTo<DefaultParams>();
197 template <EclMultiplexerApproach approachV>
198 typename std::enable_if<approachV == EclMultiplexerApproach::Default, const DefaultParams>::type&
199 getRealParams()
const 201 assert(approach() == approachV);
202 return this->
template castTo<DefaultParams>();
206 template <EclMultiplexerApproach approachV>
207 typename std::enable_if<approachV == EclMultiplexerApproach::TwoPhase, TwoPhaseParams>::type&
210 assert(approach() == approachV);
211 return this->
template castTo<TwoPhaseParams>();
214 template <EclMultiplexerApproach approachV>
215 typename std::enable_if<approachV == EclMultiplexerApproach::TwoPhase, const TwoPhaseParams>::type&
216 getRealParams()
const 218 assert(approach() == approachV);
219 return this->
template castTo<TwoPhaseParams>();
222 template<
class Serializer>
223 void serializeOp(Serializer& serializer)
225 switch (approach()) {
226 case EclMultiplexerApproach::Stone1:
227 serializer(castTo<Stone1Params>());
230 case EclMultiplexerApproach::Stone2:
231 serializer(castTo<Stone2Params>());
234 case EclMultiplexerApproach::Default:
235 serializer(castTo<DefaultParams>());
238 case EclMultiplexerApproach::TwoPhase:
239 serializer(castTo<TwoPhaseParams>());
242 case EclMultiplexerApproach::OnePhase:
249 template <
class ParamT>
252 return *(
static_cast<ParamT *
> (realParams_.operator->()));
255 template <
class ParamT>
256 const ParamT& castTo()
const 258 return *(
static_cast<const ParamT *
> (realParams_.operator->()));
261 EclMultiplexerApproach approach_{EclMultiplexerApproach::Default};
262 ParamPointerType realParams_;
Implements a multiplexer class that provides ECL saturation functions for twophase simulations...
Definition: EclMultiplexerMaterialParams.hpp:59
Multiplexer implementation for the parameters required by the multiplexed three-phase material law...
Definition: EclMultiplexerMaterialParams.hpp:74
Implements the second phase capillary pressure/relperm law suggested by Stone as used by the ECLipse ...
Implements the second phase capillary pressure/relperm law suggested by Stone as used by the ECLipse ...
This class implements a small container which holds the transmissibility mulitpliers for all the face...
Definition: Exceptions.hpp:30
Implements the second phase capillary pressure/relperm law suggested by Stone as used by the ECLipse ...
Definition: EclStone2Material.hpp:60
Implements the second phase capillary pressure/relperm law suggested by Stone as used by the ECLipse ...
Definition: EclStone1Material.hpp:60
Default implementation for asserting finalization of parameter objects.
Definition: EclMultiplexerMaterialParams.hpp:52
OPM_HOST_DEVICE void finalize()
Mark the object as finalized.
Definition: EnsureFinalized.hpp:82
EclMultiplexerMaterialParams()
The multiplexer constructor.
Definition: EclMultiplexerMaterialParams.hpp:106
Default implementation for asserting finalization of parameter objects.
Definition: EnsureFinalized.hpp:48
Implements the default three phase capillary pressure law used by the ECLipse simulator.
Definition: EclDefaultMaterial.hpp:61
Implements a multiplexer class that provides ECL saturation functions for twophase simulations...
Definition: EclTwoPhaseMaterial.hpp:56
Implements the default three phase capillary pressure law used by the ECLipse simulator.