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
31#include "EclThcLawParams.hpp"
32
34
35#include <cassert>
36#include <stdexcept>
37
38namespace Opm {
39
44template <class ScalarT>
46{
47 using ParamPointerType = void*;
48
49public:
50 using Scalar = ScalarT;
51
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
71 {
72 destroy_();
73
74 thermalConductionApproach_ = newApproach;
75 switch (thermalConductionApproach()) {
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
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&
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&
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&
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&
125 {
126 assert(thermalConductionApproach() == approachV);
127 return *static_cast<const ThcLawParams*>(realParams_);
128 }
129
130private:
131 void destroy_()
132 {
133 switch (thermalConductionApproach()) {
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...
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
std::enable_if< approachV==thcApproach, ThcLawParams >::type & getRealParams()
Definition: EclThermalConductionLawMultiplexerParams.hpp:116
EclThermalConductionLawMultiplexerParams()
Definition: EclThermalConductionLawMultiplexerParams.hpp:64
EclThconrLawParams< ScalarT > ThconrLawParams
Definition: EclThermalConductionLawMultiplexerParams.hpp:59
ThermalConductionApproach
Definition: EclThermalConductionLawMultiplexerParams.hpp:52
@ thconrApproach
Definition: EclThermalConductionLawMultiplexerParams.hpp:54
@ nullApproach
Definition: EclThermalConductionLawMultiplexerParams.hpp:56
@ undefinedApproach
Definition: EclThermalConductionLawMultiplexerParams.hpp:53
@ thcApproach
Definition: EclThermalConductionLawMultiplexerParams.hpp:55
~EclThermalConductionLawMultiplexerParams()
Definition: EclThermalConductionLawMultiplexerParams.hpp:67
std::enable_if< approachV==thconrApproach, constThconrLawParams >::type & getRealParams() const
Definition: EclThermalConductionLawMultiplexerParams.hpp:107
ThermalConductionApproach thermalConductionApproach() const
Definition: EclThermalConductionLawMultiplexerParams.hpp:93
EclThermalConductionLawMultiplexerParams(const EclThermalConductionLawMultiplexerParams &)=default
std::enable_if< approachV==thcApproach, constThcLawParams >::type & getRealParams() const
Definition: EclThermalConductionLawMultiplexerParams.hpp:124
ScalarT Scalar
Definition: EclThermalConductionLawMultiplexerParams.hpp:50
void setThermalConductionApproach(ThermalConductionApproach newApproach)
Definition: EclThermalConductionLawMultiplexerParams.hpp:70
std::enable_if< approachV==thconrApproach, ThconrLawParams >::type & getRealParams()
Definition: EclThermalConductionLawMultiplexerParams.hpp:99
EclThcLawParams< ScalarT > ThcLawParams
Definition: EclThermalConductionLawMultiplexerParams.hpp:60
Default implementation for asserting finalization of parameter objects.
Definition: EnsureFinalized.hpp:47
Definition: Air_Mesitylene.hpp:34