opm-common
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 
40 enum class EclThermalConductionApproach {
41  Undefined,
42  Thconr, // keywords: THCONR, THCONSF
43  Thc, // keywords: THCROCK, THCOIL, THCGAS, THCWATER
44  Null, // (no keywords)
45 };
46 
51 template <class ScalarT>
53 {
54  using ParamPointerType = void*;
55 
56 public:
57  using Scalar = ScalarT;
58 
61 
63  { destroy_(); }
64 
65  void setThermalConductionApproach(EclThermalConductionApproach newApproach)
66  {
67  destroy_();
68 
69  thermalConductionApproach_ = newApproach;
70  switch (thermalConductionApproach()) {
71  case EclThermalConductionApproach::Undefined:
72  throw std::logic_error("Cannot set the approach for thermal conduction to 'undefined'!");
73 
74  case EclThermalConductionApproach::Thconr:
75  realParams_ = new ThconrLawParams;
76  break;
77 
78  case EclThermalConductionApproach::Thc:
79  realParams_ = new ThcLawParams;
80  break;
81 
82  case EclThermalConductionApproach::Null:
83  realParams_ = nullptr;
84  break;
85  }
86  }
87 
88  EclThermalConductionApproach thermalConductionApproach() const
89  { return thermalConductionApproach_; }
90 
91  // get the parameter object for the THCONR case
92  template <EclThermalConductionApproach approachV>
93  typename std::enable_if<approachV == EclThermalConductionApproach::Thconr, ThconrLawParams>::type&
94  getRealParams()
95  {
96  assert(thermalConductionApproach() == approachV);
97  return *static_cast<ThconrLawParams*>(realParams_);
98  }
99 
100  template <EclThermalConductionApproach approachV>
101  typename std::enable_if<approachV == EclThermalConductionApproach::Thconr, const ThconrLawParams>::type&
102  getRealParams() const
103  {
104  assert(thermalConductionApproach() == approachV);
105  return *static_cast<const ThconrLawParams*>(realParams_);
106  }
107 
108  // get the parameter object for the THC* case
109  template <EclThermalConductionApproach approachV>
110  typename std::enable_if<approachV == EclThermalConductionApproach::Thc, ThcLawParams>::type&
111  getRealParams()
112  {
113  assert(thermalConductionApproach() == approachV);
114  return *static_cast<ThcLawParams*>(realParams_);
115  }
116 
117  template <EclThermalConductionApproach approachV>
118  typename std::enable_if<approachV == EclThermalConductionApproach::Thc, const ThcLawParams>::type&
119  getRealParams() const
120  {
121  assert(thermalConductionApproach() == approachV);
122  return *static_cast<const ThcLawParams*>(realParams_);
123  }
124 
125 private:
126  void destroy_()
127  {
128  switch (thermalConductionApproach()) {
129  case EclThermalConductionApproach::Undefined:
130  break;
131 
132  case EclThermalConductionApproach::Thconr:
133  delete static_cast<ThconrLawParams*>(realParams_);
134  break;
135 
136  case EclThermalConductionApproach::Thc:
137  delete static_cast<ThcLawParams*>(realParams_);
138  break;
139 
140  case EclThermalConductionApproach::Null:
141  break;
142  }
143 
144  thermalConductionApproach_ = EclThermalConductionApproach::Undefined;
145  }
146 
147  EclThermalConductionApproach thermalConductionApproach_{EclThermalConductionApproach::Undefined};
148  ParamPointerType realParams_{nullptr};
149 };
150 
151 } // namespace Opm
152 
153 #endif
The default implementation of a parameter object for the ECL thermal law.
Definition: EclThermalConductionLawMultiplexerParams.hpp:52
This class implements a small container which holds the transmissibility mulitpliers for all the face...
Definition: Exceptions.hpp:30
Default implementation for asserting finalization of parameter objects.
The default implementation of a parameter object for the thermal conduction law based on the THCONR k...
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 THC* key...
Definition: EclThcLawParams.hpp:39
Default implementation for asserting finalization of parameter objects.
Definition: EnsureFinalized.hpp:48
The default implementation of a parameter object for the thermal conduction law based on the THCONR k...
Definition: EclThconrLawParams.hpp:39