EclMultiplexerMaterialParams.hpp
Go to the documentation of this file.
1// -*- mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
2// vi: set et ts=4 sw=4 sts=4:
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 2 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 Consult the COPYING file in the top-level source directory of this
20 module for the precise wording of the license and the list of
21 copyright holders.
22*/
27#ifndef OPM_ECL_MULTIPLEXER_MATERIAL_PARAMS_HPP
28#define OPM_ECL_MULTIPLEXER_MATERIAL_PARAMS_HPP
29
30#include "EclStone1Material.hpp"
31#include "EclStone2Material.hpp"
34
35#include <cassert>
36#include <memory>
37#include <type_traits>
38
40
41namespace Opm {
42
49};
50
58template<class Traits, class GasOilMaterialLawT, class OilWaterMaterialLawT, class GasWaterMaterialLawT>
59class EclMultiplexerMaterialParams : public Traits, public EnsureFinalized
60{
61 using Scalar = typename Traits::Scalar;
62 enum { numPhases = 3 };
63
68
69 using Stone1Params = typename Stone1Material::Params;
70 using Stone2Params = typename Stone2Material::Params;
71 using DefaultParams = typename DefaultMaterial::Params;
72 using TwoPhaseParams = typename TwoPhaseMaterial::Params;
73
74 template <class ParamT>
75 struct Deleter
76 {
77 inline void operator () ( void* ptr )
78 {
79 delete static_cast< ParamT* > (ptr);
80 }
81 };
82
83 using ParamPointerType = std::shared_ptr<void>;
84
85public:
87
92 {
93 }
94
96 : realParams_()
97 {
98 setApproach( other.approach() );
99 }
100
102 {
103 realParams_.reset();
104 setApproach( other.approach() );
105 return *this;
106 }
107
109 {
110 assert(realParams_ == 0);
111 approach_ = newApproach;
112
113 switch (approach()) {
115 realParams_ = ParamPointerType(new Stone1Params, Deleter< Stone1Params > () );
116 break;
117
119 realParams_ = ParamPointerType(new Stone2Params, Deleter< Stone2Params > () );
120 break;
121
123 realParams_ = ParamPointerType(new DefaultParams, Deleter< DefaultParams > () );
124 break;
125
127 realParams_ = ParamPointerType(new TwoPhaseParams, Deleter< TwoPhaseParams > () );
128 break;
129
131 // Do nothing, no parameters.
132 break;
133 }
134 }
135
137 { return approach_; }
138
139 // get the parameter object for the Stone1 case
140 template <EclMultiplexerApproach approachV>
141 typename std::enable_if<approachV == EclMultiplexerApproach::EclStone1Approach, Stone1Params>::type&
143 {
144 assert(approach() == approachV);
145 return this->template castTo<Stone1Params>();
146 }
147
148 template <EclMultiplexerApproach approachV>
149 typename std::enable_if<approachV == EclMultiplexerApproach::EclStone1Approach, const Stone1Params>::type&
151 {
152 assert(approach() == approachV);
153 return this->template castTo<Stone1Params>();
154 }
155
156 // get the parameter object for the Stone2 case
157 template <EclMultiplexerApproach approachV>
158 typename std::enable_if<approachV == EclMultiplexerApproach::EclStone2Approach, Stone2Params>::type&
160 {
161 assert(approach() == approachV);
162 return this->template castTo<Stone2Params>();
163 }
164
165 template <EclMultiplexerApproach approachV>
166 typename std::enable_if<approachV == EclMultiplexerApproach::EclStone2Approach, const Stone2Params>::type&
168 {
169 assert(approach() == approachV);
170 return this->template castTo<Stone2Params>();
171 }
172
173 // get the parameter object for the default case
174 template <EclMultiplexerApproach approachV>
175 typename std::enable_if<approachV == EclMultiplexerApproach::EclDefaultApproach, DefaultParams>::type&
177 {
178 assert(approach() == approachV);
179 return this->template castTo<DefaultParams>();
180 }
181
182 template <EclMultiplexerApproach approachV>
183 typename std::enable_if<approachV == EclMultiplexerApproach::EclDefaultApproach, const DefaultParams>::type&
185 {
186 assert(approach() == approachV);
187 return this->template castTo<DefaultParams>();
188 }
189
190 // get the parameter object for the twophase case
191 template <EclMultiplexerApproach approachV>
192 typename std::enable_if<approachV == EclMultiplexerApproach::EclTwoPhaseApproach, TwoPhaseParams>::type&
194 {
195 assert(approach() == approachV);
196 return this->template castTo<TwoPhaseParams>();
197 }
198
199 template <EclMultiplexerApproach approachV>
200 typename std::enable_if<approachV == EclMultiplexerApproach::EclTwoPhaseApproach, const TwoPhaseParams>::type&
202 {
203 assert(approach() == approachV);
204 return this->template castTo<TwoPhaseParams>();
205 }
206
207private:
208 template <class ParamT>
209 ParamT& castTo()
210 {
211 return *(static_cast<ParamT *> (realParams_.operator->()));
212 }
213
214 template <class ParamT>
215 const ParamT& castTo() const
216 {
217 return *(static_cast<const ParamT *> (realParams_.operator->()));
218 }
219
220 EclMultiplexerApproach approach_;
221 ParamPointerType realParams_;
222};
223} // namespace Opm
224
225#endif
Implements the default three phase capillary pressure law used by the ECLipse simulator.
Definition: EclDefaultMaterial.hpp:61
ParamsT Params
Definition: EclDefaultMaterial.hpp:89
Multiplexer implementation for the parameters required by the multiplexed three-phase material law.
Definition: EclMultiplexerMaterialParams.hpp:60
std::enable_if< approachV==EclMultiplexerApproach::EclStone2Approach, constStone2Params >::type & getRealParams() const
Definition: EclMultiplexerMaterialParams.hpp:167
std::enable_if< approachV==EclMultiplexerApproach::EclStone2Approach, Stone2Params >::type & getRealParams()
Definition: EclMultiplexerMaterialParams.hpp:159
std::enable_if< approachV==EclMultiplexerApproach::EclDefaultApproach, DefaultParams >::type & getRealParams()
Definition: EclMultiplexerMaterialParams.hpp:176
EclMultiplexerMaterialParams()
The multiplexer constructor.
Definition: EclMultiplexerMaterialParams.hpp:91
std::enable_if< approachV==EclMultiplexerApproach::EclTwoPhaseApproach, TwoPhaseParams >::type & getRealParams()
Definition: EclMultiplexerMaterialParams.hpp:193
std::enable_if< approachV==EclMultiplexerApproach::EclDefaultApproach, constDefaultParams >::type & getRealParams() const
Definition: EclMultiplexerMaterialParams.hpp:184
std::enable_if< approachV==EclMultiplexerApproach::EclStone1Approach, Stone1Params >::type & getRealParams()
Definition: EclMultiplexerMaterialParams.hpp:142
EclMultiplexerMaterialParams & operator=(const EclMultiplexerMaterialParams &other)
Definition: EclMultiplexerMaterialParams.hpp:101
EclMultiplexerMaterialParams(const EclMultiplexerMaterialParams &other)
Definition: EclMultiplexerMaterialParams.hpp:95
std::enable_if< approachV==EclMultiplexerApproach::EclTwoPhaseApproach, constTwoPhaseParams >::type & getRealParams() const
Definition: EclMultiplexerMaterialParams.hpp:201
std::enable_if< approachV==EclMultiplexerApproach::EclStone1Approach, constStone1Params >::type & getRealParams() const
Definition: EclMultiplexerMaterialParams.hpp:150
void setApproach(EclMultiplexerApproach newApproach)
Definition: EclMultiplexerMaterialParams.hpp:108
EclMultiplexerApproach approach() const
Definition: EclMultiplexerMaterialParams.hpp:136
Implements the second phase capillary pressure/relperm law suggested by Stone as used by the ECLipse ...
Definition: EclStone1Material.hpp:60
ParamsT Params
Definition: EclStone1Material.hpp:88
Implements the second phase capillary pressure/relperm law suggested by Stone as used by the ECLipse ...
Definition: EclStone2Material.hpp:61
ParamsT Params
Definition: EclStone2Material.hpp:89
Implements a multiplexer class that provides ECL saturation functions for twophase simulations.
Definition: EclTwoPhaseMaterial.hpp:57
ParamsT Params
Definition: EclTwoPhaseMaterial.hpp:82
Default implementation for asserting finalization of parameter objects.
Definition: EnsureFinalized.hpp:47
void finalize()
Mark the object as finalized.
Definition: EnsureFinalized.hpp:75
Definition: Air_Mesitylene.hpp:34
EclMultiplexerApproach
Definition: EclMultiplexerMaterialParams.hpp:43
EclTwoPhaseApproach
Definition: EclTwoPhaseMaterialParams.hpp:36