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