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