EclSolidEnergyLawMultiplexerParams.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_SOLID_ENERGY_LAW_MULTIPLEXER_PARAMS_HPP
28#define OPM_ECL_SOLID_ENERGY_LAW_MULTIPLEXER_PARAMS_HPP
29
32
34
35#include <cassert>
36#include <stdexcept>
37#include <type_traits>
38
39namespace Opm {
40
45template <class ScalarT>
47{
48 using ParamPointerType = void*;
49
50public:
51 using Scalar = ScalarT;
52
55 heatcrApproach, // keywords: HEATCR, HEATCRT, STCOND
56 specrockApproach, // keyword: SPECROCK
57 nullApproach, // (no keywords)
58 };
59
62
64
66 { solidEnergyApproach_ = undefinedApproach; }
67
69 { destroy_(); }
70
72 {
73 destroy_();
74
75 solidEnergyApproach_ = newApproach;
76 switch (solidEnergyApproach()) {
78 throw std::logic_error("Cannot set the approach for solid energy storage to 'undefined'!");
79
80 case heatcrApproach:
81 realParams_ = new HeatcrLawParams;
82 break;
83
85 realParams_ = new SpecrockLawParams;
86 break;
87
88 case nullApproach:
89 realParams_ = nullptr;
90 break;
91 }
92 }
93
95 { return solidEnergyApproach_; }
96
97 // get the parameter object for the HEATCR case
98 template <SolidEnergyApproach approachV>
99 typename std::enable_if<approachV == heatcrApproach, HeatcrLawParams>::type&
101 {
102 assert(solidEnergyApproach() == approachV);
103 return *static_cast<HeatcrLawParams*>(realParams_);
104 }
105
106 template <SolidEnergyApproach approachV>
107 typename std::enable_if<approachV == heatcrApproach, const HeatcrLawParams>::type&
109 {
110 assert(solidEnergyApproach() == approachV);
111 return *static_cast<const HeatcrLawParams*>(realParams_);
112 }
113
114 // get the parameter object for the SPECROCK case
115 template <SolidEnergyApproach approachV>
116 typename std::enable_if<approachV == specrockApproach, SpecrockLawParams>::type&
118 {
119 assert(solidEnergyApproach() == approachV);
120 return *static_cast<SpecrockLawParams*>(realParams_);
121 }
122
123 template <SolidEnergyApproach approachV>
124 typename std::enable_if<approachV == specrockApproach, const SpecrockLawParams>::type&
126 {
127 assert(solidEnergyApproach() == approachV);
128 return *static_cast<const SpecrockLawParams*>(realParams_);
129 }
130
131private:
132 void destroy_()
133 {
134 switch (solidEnergyApproach()) {
136 break;
137
138 case heatcrApproach:
139 delete static_cast<HeatcrLawParams*>(realParams_);
140 break;
141
142 case specrockApproach:
143 delete static_cast<SpecrockLawParams*>(realParams_);
144 break;
145
146 case nullApproach:
147 break;
148 }
149
150 solidEnergyApproach_ = undefinedApproach;
151 }
152
153 SolidEnergyApproach solidEnergyApproach_;
154 ParamPointerType realParams_;
155};
156
157} // namespace Opm
158
159#endif
The default implementation of a parameter object for the ECL thermal law.
Definition: EclHeatcrLawParams.hpp:40
The default implementation of a parameter object for the ECL thermal law.
Definition: EclSolidEnergyLawMultiplexerParams.hpp:47
std::enable_if< approachV==heatcrApproach, constHeatcrLawParams >::type & getRealParams() const
Definition: EclSolidEnergyLawMultiplexerParams.hpp:108
std::enable_if< approachV==specrockApproach, SpecrockLawParams >::type & getRealParams()
Definition: EclSolidEnergyLawMultiplexerParams.hpp:117
EclHeatcrLawParams< ScalarT > HeatcrLawParams
Definition: EclSolidEnergyLawMultiplexerParams.hpp:60
EclSpecrockLawParams< ScalarT > SpecrockLawParams
Definition: EclSolidEnergyLawMultiplexerParams.hpp:61
SolidEnergyApproach
Definition: EclSolidEnergyLawMultiplexerParams.hpp:53
@ undefinedApproach
Definition: EclSolidEnergyLawMultiplexerParams.hpp:54
@ specrockApproach
Definition: EclSolidEnergyLawMultiplexerParams.hpp:56
@ heatcrApproach
Definition: EclSolidEnergyLawMultiplexerParams.hpp:55
@ nullApproach
Definition: EclSolidEnergyLawMultiplexerParams.hpp:57
ScalarT Scalar
Definition: EclSolidEnergyLawMultiplexerParams.hpp:51
SolidEnergyApproach solidEnergyApproach() const
Definition: EclSolidEnergyLawMultiplexerParams.hpp:94
EclSolidEnergyLawMultiplexerParams()
Definition: EclSolidEnergyLawMultiplexerParams.hpp:65
~EclSolidEnergyLawMultiplexerParams()
Definition: EclSolidEnergyLawMultiplexerParams.hpp:68
void setSolidEnergyApproach(SolidEnergyApproach newApproach)
Definition: EclSolidEnergyLawMultiplexerParams.hpp:71
std::enable_if< approachV==specrockApproach, constSpecrockLawParams >::type & getRealParams() const
Definition: EclSolidEnergyLawMultiplexerParams.hpp:125
EclSolidEnergyLawMultiplexerParams(const EclSolidEnergyLawMultiplexerParams &)=default
std::enable_if< approachV==heatcrApproach, HeatcrLawParams >::type & getRealParams()
Definition: EclSolidEnergyLawMultiplexerParams.hpp:100
The default implementation of a parameter object for the ECL thermal law based on SPECROCK.
Definition: EclSpecrockLawParams.hpp:43
Default implementation for asserting finalization of parameter objects.
Definition: EnsureFinalized.hpp:47
Definition: Air_Mesitylene.hpp:34