My Project
EclThermalConductionLawMultiplexerParams.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_THERMAL_CONDUCTION_LAW_MULTIPLEXER_PARAMS_HPP
28 #define OPM_ECL_THERMAL_CONDUCTION_LAW_MULTIPLEXER_PARAMS_HPP
29 
30 #include "EclThconrLawParams.hpp"
31 #include "EclThcLawParams.hpp"
32 
34 
35 #include <memory>
36 
37 namespace Opm {
38 
43 template <class ScalarT>
45 {
46  typedef void* ParamPointerType;
47 
48 public:
49  typedef ScalarT Scalar;
50 
51  enum ThermalConductionApproach {
52  undefinedApproach,
53  thconrApproach, // keywords: THCONR, THCONSF
54  thcApproach, // keywords: THCROCK, THCOIL, THCGAS, THCWATER
55  nullApproach, // (no keywords)
56  };
57 
60 
62 
64  { thermalConductionApproach_ = undefinedApproach; }
65 
67  { destroy_(); }
68 
69  void setThermalConductionApproach(ThermalConductionApproach newApproach)
70  {
71  destroy_();
72 
73  thermalConductionApproach_ = newApproach;
74  switch (thermalConductionApproach()) {
75  case undefinedApproach:
76  throw std::logic_error("Cannot set the approach for thermal conduction to 'undefined'!");
77 
78  case thconrApproach:
79  realParams_ = new ThconrLawParams;
80  break;
81 
82  case thcApproach:
83  realParams_ = new ThcLawParams;
84  break;
85 
86  case nullApproach:
87  realParams_ = nullptr;
88  break;
89  }
90  }
91 
92  ThermalConductionApproach thermalConductionApproach() const
93  { return thermalConductionApproach_; }
94 
95  // get the parameter object for the THCONR case
96  template <ThermalConductionApproach approachV>
97  typename std::enable_if<approachV == thconrApproach, ThconrLawParams>::type&
98  getRealParams()
99  {
100  assert(thermalConductionApproach() == approachV);
101  return *static_cast<ThconrLawParams*>(realParams_);
102  }
103 
104  template <ThermalConductionApproach approachV>
105  typename std::enable_if<approachV == thconrApproach, const ThconrLawParams>::type&
106  getRealParams() const
107  {
108  assert(thermalConductionApproach() == approachV);
109  return *static_cast<const ThconrLawParams*>(realParams_);
110  }
111 
112  // get the parameter object for the THC* case
113  template <ThermalConductionApproach approachV>
114  typename std::enable_if<approachV == thcApproach, ThcLawParams>::type&
115  getRealParams()
116  {
117  assert(thermalConductionApproach() == approachV);
118  return *static_cast<ThcLawParams*>(realParams_);
119  }
120 
121  template <ThermalConductionApproach approachV>
122  typename std::enable_if<approachV == thcApproach, const ThcLawParams>::type&
123  getRealParams() const
124  {
125  assert(thermalConductionApproach() == approachV);
126  return *static_cast<const ThcLawParams*>(realParams_);
127  }
128 
129 private:
130  void destroy_()
131  {
132  switch (thermalConductionApproach()) {
133  case undefinedApproach:
134  break;
135 
136  case thconrApproach:
137  delete static_cast<ThconrLawParams*>(realParams_);
138  break;
139 
140  case thcApproach:
141  delete static_cast<ThcLawParams*>(realParams_);
142  break;
143 
144  case nullApproach:
145  break;
146  }
147 
148  thermalConductionApproach_ = undefinedApproach;
149  }
150 
151  ThermalConductionApproach thermalConductionApproach_;
152  ParamPointerType realParams_;
153 };
154 
155 } // namespace Opm
156 
157 #endif
The default implementation of a parameter object for the thermal conduction law based on the THC* key...
The default implementation of a parameter object for the thermal conduction law based on the THCONR k...
Default implementation for asserting finalization of parameter objects.
The default implementation of a parameter object for the thermal conduction law based on the THC* key...
Definition: EclThcLawParams.hpp:40
The default implementation of a parameter object for the thermal conduction law based on the THCONR k...
Definition: EclThconrLawParams.hpp:40
The default implementation of a parameter object for the ECL thermal law.
Definition: EclThermalConductionLawMultiplexerParams.hpp:45
Default implementation for asserting finalization of parameter objects.
Definition: EnsureFinalized.hpp:47