My Project
Loading...
Searching...
No Matches
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
41enum class EclSolidEnergyApproach {
42 Undefined,
43 Heatcr, // keywords: HEATCR, HEATCRT, STCOND
44 Specrock, // keyword: SPECROCK
45 Null // (no keywords)
46};
47
52template <class ScalarT>
54{
55 using ParamPointerType = void*;
56
57public:
58 using Scalar = ScalarT;
59
62
64
66 { solidEnergyApproach_ = EclSolidEnergyApproach::Undefined; }
67
69 { destroy_(); }
70
71 void setSolidEnergyApproach(EclSolidEnergyApproach newApproach)
72 {
73 destroy_();
74
75 solidEnergyApproach_ = newApproach;
76 switch (solidEnergyApproach()) {
77 case EclSolidEnergyApproach::Undefined:
78 throw std::logic_error("Cannot set the approach for solid energy storage to 'undefined'!");
79
80 case EclSolidEnergyApproach::Heatcr:
81 realParams_ = new HeatcrLawParams;
82 break;
83
84 case EclSolidEnergyApproach::Specrock:
85 realParams_ = new SpecrockLawParams;
86 break;
87
88 case EclSolidEnergyApproach::Null:
89 realParams_ = nullptr;
90 break;
91 }
92 }
93
94 EclSolidEnergyApproach solidEnergyApproach() const
95 { return solidEnergyApproach_; }
96
97 // get the parameter object for the HEATCR case
98 template <EclSolidEnergyApproach approachV>
99 typename std::enable_if<approachV == EclSolidEnergyApproach::Heatcr, HeatcrLawParams>::type&
100 getRealParams()
101 {
102 assert(solidEnergyApproach() == approachV);
103 return *static_cast<HeatcrLawParams*>(realParams_);
104 }
105
106 template <EclSolidEnergyApproach approachV>
107 typename std::enable_if<approachV == EclSolidEnergyApproach::Heatcr, const HeatcrLawParams>::type&
108 getRealParams() const
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 <EclSolidEnergyApproach approachV>
116 typename std::enable_if<approachV == EclSolidEnergyApproach::Specrock, SpecrockLawParams>::type&
117 getRealParams()
118 {
119 assert(solidEnergyApproach() == approachV);
120 return *static_cast<SpecrockLawParams*>(realParams_);
121 }
122
123 template <EclSolidEnergyApproach approachV>
124 typename std::enable_if<approachV == EclSolidEnergyApproach::Specrock, const SpecrockLawParams>::type&
125 getRealParams() const
126 {
127 assert(solidEnergyApproach() == approachV);
128 return *static_cast<const SpecrockLawParams*>(realParams_);
129 }
130
131private:
132 void destroy_()
133 {
134 switch (solidEnergyApproach()) {
135 case EclSolidEnergyApproach::Undefined:
136 break;
137
138 case EclSolidEnergyApproach::Heatcr:
139 delete static_cast<HeatcrLawParams*>(realParams_);
140 break;
141
142 case EclSolidEnergyApproach::Specrock:
143 delete static_cast<SpecrockLawParams*>(realParams_);
144 break;
145
146 case EclSolidEnergyApproach::Null:
147 break;
148 }
149
150 solidEnergyApproach_ = EclSolidEnergyApproach::Undefined;
151 }
152
153 EclSolidEnergyApproach solidEnergyApproach_;
154 ParamPointerType realParams_;
155};
156
157} // namespace Opm
158
159#endif
The default implementation of a parameter object for the ECL thermal law.
The default implementation of a parameter object for the ECL thermal law based on SPECROCK.
Default implementation for asserting finalization of parameter objects.
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:54
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
This class implements a small container which holds the transmissibility mulitpliers for all the face...
Definition Exceptions.hpp:30