My Project
Loading...
Searching...
No Matches
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
43enum class EclMultiplexerApproach {
44 Default,
45 Stone1,
46 Stone2,
47 TwoPhase,
48 OnePhase
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
108 void setApproach(EclMultiplexerApproach newApproach)
109 {
110 assert(realParams_ == 0);
111 approach_ = newApproach;
112
113 switch (approach()) {
114 case EclMultiplexerApproach::Stone1:
115 realParams_ = ParamPointerType(new Stone1Params, Deleter< Stone1Params > () );
116 break;
117
118 case EclMultiplexerApproach::Stone2:
119 realParams_ = ParamPointerType(new Stone2Params, Deleter< Stone2Params > () );
120 break;
121
122 case EclMultiplexerApproach::Default:
123 realParams_ = ParamPointerType(new DefaultParams, Deleter< DefaultParams > () );
124 break;
125
126 case EclMultiplexerApproach::TwoPhase:
127 realParams_ = ParamPointerType(new TwoPhaseParams, Deleter< TwoPhaseParams > () );
128 break;
129
130 case EclMultiplexerApproach::OnePhase:
131 // Do nothing, no parameters.
132 break;
133 }
134 }
135
136 EclMultiplexerApproach approach() const
137 { return approach_; }
138
139 // get the parameter object for the Stone1 case
140 template <EclMultiplexerApproach approachV>
141 typename std::enable_if<approachV == EclMultiplexerApproach::Stone1, Stone1Params>::type&
142 getRealParams()
143 {
144 assert(approach() == approachV);
145 return this->template castTo<Stone1Params>();
146 }
147
148 template <EclMultiplexerApproach approachV>
149 typename std::enable_if<approachV == EclMultiplexerApproach::Stone1, const Stone1Params>::type&
150 getRealParams() const
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::Stone2, Stone2Params>::type&
159 getRealParams()
160 {
161 assert(approach() == approachV);
162 return this->template castTo<Stone2Params>();
163 }
164
165 template <EclMultiplexerApproach approachV>
166 typename std::enable_if<approachV == EclMultiplexerApproach::Stone2, const Stone2Params>::type&
167 getRealParams() const
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::Default, DefaultParams>::type&
176 getRealParams()
177 {
178 assert(approach() == approachV);
179 return this->template castTo<DefaultParams>();
180 }
181
182 template <EclMultiplexerApproach approachV>
183 typename std::enable_if<approachV == EclMultiplexerApproach::Default, const DefaultParams>::type&
184 getRealParams() const
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::TwoPhase, TwoPhaseParams>::type&
193 getRealParams()
194 {
195 assert(approach() == approachV);
196 return this->template castTo<TwoPhaseParams>();
197 }
198
199 template <EclMultiplexerApproach approachV>
200 typename std::enable_if<approachV == EclMultiplexerApproach::TwoPhase, const TwoPhaseParams>::type&
201 getRealParams() const
202 {
203 assert(approach() == approachV);
204 return this->template castTo<TwoPhaseParams>();
205 }
206
207 template<class Serializer>
208 void serializeOp(Serializer& serializer)
209 {
210 switch (approach()) {
211 case EclMultiplexerApproach::Stone1:
212 serializer(castTo<Stone1Params>());
213 break;
214
215 case EclMultiplexerApproach::Stone2:
216 serializer(castTo<Stone2Params>());
217 break;
218
219 case EclMultiplexerApproach::Default:
220 serializer(castTo<DefaultParams>());
221 break;
222
223 case EclMultiplexerApproach::TwoPhase:
224 serializer(castTo<TwoPhaseParams>());
225 break;
226
227 case EclMultiplexerApproach::OnePhase:
228 // Do nothing, no parameters.
229 break;
230 }
231 }
232
233private:
234 template <class ParamT>
235 ParamT& castTo()
236 {
237 return *(static_cast<ParamT *> (realParams_.operator->()));
238 }
239
240 template <class ParamT>
241 const ParamT& castTo() const
242 {
243 return *(static_cast<const ParamT *> (realParams_.operator->()));
244 }
245
246 EclMultiplexerApproach approach_;
247 ParamPointerType realParams_;
248};
249} // namespace Opm
250
251#endif
Implements the default three phase capillary pressure law used by the ECLipse simulator.
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 ...
Implements a multiplexer class that provides ECL saturation functions for twophase simulations.
Default implementation for asserting finalization of parameter objects.
Implements the default three phase capillary pressure law used by the ECLipse simulator.
Definition EclDefaultMaterial.hpp:61
Multiplexer implementation for the parameters required by the multiplexed three-phase material law.
Definition EclMultiplexerMaterialParams.hpp:60
EclMultiplexerMaterialParams()
The multiplexer constructor.
Definition EclMultiplexerMaterialParams.hpp:91
Implements the second phase capillary pressure/relperm law suggested by Stone as used by the ECLipse ...
Definition EclStone1Material.hpp:60
Implements the second phase capillary pressure/relperm law suggested by Stone as used by the ECLipse ...
Definition EclStone2Material.hpp:61
Implements a multiplexer class that provides ECL saturation functions for twophase simulations.
Definition EclTwoPhaseMaterial.hpp:57
Default implementation for asserting finalization of parameter objects.
Definition EnsureFinalized.hpp:47
void finalize()
Mark the object as finalized.
Definition EnsureFinalized.hpp:75
This class implements a small container which holds the transmissibility mulitpliers for all the face...
Definition Exceptions.hpp:30