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  Copyright (C) 2013 by Andreas Lauser
5 
6  This file is part of the Open Porous Media project (OPM).
7 
8  OPM is free software: you can redistribute it and/or modify
9  it under the terms of the GNU General Public License as published by
10  the Free Software Foundation, either version 2 of the License, or
11  (at your option) any later version.
12 
13  OPM is distributed in the hope that it will be useful,
14  but WITHOUT ANY WARRANTY; without even the implied warranty of
15  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  GNU General Public License for more details.
17 
18  You should have received a copy of the GNU General Public License
19  along with OPM. If not, see <http://www.gnu.org/licenses/>.
20 */
25 #ifndef OPM_ECL_MULTIPLEXER_MATERIAL_PARAMS_HPP
26 #define OPM_ECL_MULTIPLEXER_MATERIAL_PARAMS_HPP
27 
28 #include "EclStone1Material.hpp"
29 #include "EclStone2Material.hpp"
30 #include "EclDefaultMaterial.hpp"
31 #include "EclTwoPhaseMaterial.hpp"
32 
33 #include <type_traits>
34 #include <cassert>
35 #include <memory>
36 
37 namespace Opm {
38 
44 };
45 
53 template<class Traits, class GasOilMaterialLawT, class OilWaterMaterialLawT>
54 class EclMultiplexerMaterialParams : public Traits
55 {
56  typedef typename Traits::Scalar Scalar;
57  enum { numPhases = 3 };
58 
63 
64  typedef typename Stone1Material::Params Stone1Params;
65  typedef typename Stone2Material::Params Stone2Params;
66  typedef typename DefaultMaterial::Params DefaultParams;
67  typedef typename TwoPhaseMaterial::Params TwoPhaseParams;
68 
69 public:
74  {
75  realParams_ = 0;
76 
77 #ifndef NDEBUG
78  finalized_ = false;
79 #endif
80  }
81 
83  {
84  realParams_ = 0;
85 
86 #ifndef NDEBUG
87  finalized_ = false;
88 #endif
89  }
90 
92  {
93  switch (approach()) {
94  case EclStone1Approach:
95  delete static_cast<Stone1Params*>(realParams_);
96  break;
97 
98  case EclStone2Approach:
99  delete static_cast<Stone2Params*>(realParams_);
100  break;
101 
102  case EclDefaultApproach:
103  delete static_cast<DefaultParams*>(realParams_);
104  break;
105 
106  case EclTwoPhaseApproach:
107  delete static_cast<TwoPhaseParams*>(realParams_);
108  break;
109  }
110  }
111 
115  void finalize()
116  {
117 #ifndef NDEBUG
118  finalized_ = true;
119 #endif
120  }
121 
123  {
124  assert(realParams_ == 0);
125  approach_ = newApproach;
126 
127  switch (approach()) {
128  case EclStone1Approach:
129  realParams_ = new Stone1Params;
130  break;
131 
132  case EclStone2Approach:
133  realParams_ = new Stone2Params;
134  break;
135 
136  case EclDefaultApproach:
137  realParams_ = new DefaultParams;
138  break;
139 
140  case EclTwoPhaseApproach:
141  realParams_ = new TwoPhaseParams;
142  break;
143  }
144  }
145 
147  { return approach_; }
148 
149  // get the parameter object for the Stone1 case
150  template <EclMultiplexerApproach approachV>
151  typename std::enable_if<approachV == EclStone1Approach, Stone1Params>::type&
153  {
154  assert(approach() == approachV);
155  return *static_cast<Stone1Params*>(realParams_);
156  }
157 
158  template <EclMultiplexerApproach approachV>
159  typename std::enable_if<approachV == EclStone1Approach, const Stone1Params>::type&
161  {
162  assert(approach() == approachV);
163  return *static_cast<const Stone1Params*>(realParams_);
164  }
165 
166  // get the parameter object for the Stone2 case
167  template <EclMultiplexerApproach approachV>
168  typename std::enable_if<approachV == EclStone2Approach, Stone2Params>::type&
170  {
171  assert(approach() == approachV);
172  return *static_cast<Stone2Params*>(realParams_);
173  }
174 
175  template <EclMultiplexerApproach approachV>
176  typename std::enable_if<approachV == EclStone2Approach, const Stone2Params>::type&
178  {
179  assert(approach() == approachV);
180  return *static_cast<const Stone2Params*>(realParams_);
181  }
182 
183  // get the parameter object for the default case
184  template <EclMultiplexerApproach approachV>
185  typename std::enable_if<approachV == EclDefaultApproach, DefaultParams>::type&
187  {
188  assert(approach() == approachV);
189  return *static_cast<DefaultParams*>(realParams_);
190  }
191 
192  template <EclMultiplexerApproach approachV>
193  typename std::enable_if<approachV == EclDefaultApproach, const DefaultParams>::type&
195  {
196  assert(approach() == approachV);
197  return *static_cast<const DefaultParams*>(realParams_);
198  }
199 
200  // get the parameter object for the twophase case
201  template <EclMultiplexerApproach approachV>
202  typename std::enable_if<approachV == EclTwoPhaseApproach, TwoPhaseParams>::type&
204  {
205  assert(approach() == approachV);
206  return *static_cast<TwoPhaseParams*>(realParams_);
207  }
208 
209  template <EclMultiplexerApproach approachV>
210  typename std::enable_if<approachV == EclTwoPhaseApproach, const TwoPhaseParams>::type&
212  {
213  assert(approach() == approachV);
214  return *static_cast<const TwoPhaseParams*>(realParams_);
215  }
216 
217 private:
218 #ifndef NDEBUG
219  void assertFinalized_() const
220  { assert(finalized_); }
221 
222  bool finalized_;
223 #else
224  void assertFinalized_() const
225  { }
226 #endif
227 
228  EclMultiplexerApproach approach_;
229  void* realParams_;
230 };
231 } // namespace Opm
232 
233 #endif
Implements the second phase capillary pressure/relperm law suggested by Stone as used by the ECLipse ...
Multiplexer implementation for the parameters required by the multiplexed three-phase material law...
Definition: EclMultiplexerMaterialParams.hpp:54
EclMultiplexerApproach approach() const
Definition: EclMultiplexerMaterialParams.hpp:146
Definition: Air_Mesitylene.hpp:31
std::enable_if< approachV==EclTwoPhaseApproach, TwoPhaseParams >::type & getRealParams()
Definition: EclMultiplexerMaterialParams.hpp:203
std::enable_if< approachV==EclStone2Approach, const Stone2Params >::type & getRealParams() const
Definition: EclMultiplexerMaterialParams.hpp:177
std::enable_if< approachV==EclStone1Approach, Stone1Params >::type & getRealParams()
Definition: EclMultiplexerMaterialParams.hpp:152
Definition: EclMultiplexerMaterialParams.hpp:42
void finalize()
Finish the initialization of the parameter object.
Definition: EclMultiplexerMaterialParams.hpp:115
Implements the default three phase capillary pressure law used by the ECLipse simulator.
Definition: EclDefaultMaterial.hpp:59
EclTwoPhaseApproach
Definition: EclTwoPhaseMaterialParams.hpp:33
Implements a multiplexer class that provides ECL saturation functions for twophase simulations...
Definition: EclTwoPhaseMaterial.hpp:55
Definition: EclMultiplexerMaterialParams.hpp:41
EclMultiplexerMaterialParams()
The multiplexer constructor.
Definition: EclMultiplexerMaterialParams.hpp:73
std::enable_if< approachV==EclStone2Approach, Stone2Params >::type & getRealParams()
Definition: EclMultiplexerMaterialParams.hpp:169
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 ...
Definition: EclStone1Material.hpp:60
Implements the second phase capillary pressure/relperm law suggested by Stone as used by the ECLipse ...
Definition: EclStone2Material.hpp:59
EclMultiplexerApproach
Definition: EclMultiplexerMaterialParams.hpp:39
std::enable_if< approachV==EclDefaultApproach, const DefaultParams >::type & getRealParams() const
Definition: EclMultiplexerMaterialParams.hpp:194
EclMultiplexerMaterialParams(const EclMultiplexerMaterialParams &)
Definition: EclMultiplexerMaterialParams.hpp:82
~EclMultiplexerMaterialParams()
Definition: EclMultiplexerMaterialParams.hpp:91
std::enable_if< approachV==EclTwoPhaseApproach, const TwoPhaseParams >::type & getRealParams() const
Definition: EclMultiplexerMaterialParams.hpp:211
std::enable_if< approachV==EclStone1Approach, const Stone1Params >::type & getRealParams() const
Definition: EclMultiplexerMaterialParams.hpp:160
Implements a multiplexer class that provides ECL saturation functions for twophase simulations...
void setApproach(EclMultiplexerApproach newApproach)
Definition: EclMultiplexerMaterialParams.hpp:122
std::enable_if< approachV==EclDefaultApproach, DefaultParams >::type & getRealParams()
Definition: EclMultiplexerMaterialParams.hpp:186
Definition: EclMultiplexerMaterialParams.hpp:40
Implements the default three phase capillary pressure law used by the ECLipse simulator.