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 { destroy_(); }
65
66 void setSolidEnergyApproach(EclSolidEnergyApproach newApproach)
67 {
68 destroy_();
69
70 solidEnergyApproach_ = newApproach;
71 switch (solidEnergyApproach()) {
72 case EclSolidEnergyApproach::Undefined:
73 throw std::logic_error("Cannot set the approach for solid energy storage to 'undefined'!");
74
75 case EclSolidEnergyApproach::Heatcr:
76 realParams_ = new HeatcrLawParams;
77 break;
78
79 case EclSolidEnergyApproach::Specrock:
80 realParams_ = new SpecrockLawParams;
81 break;
82
83 case EclSolidEnergyApproach::Null:
84 realParams_ = nullptr;
85 break;
86 }
87 }
88
89 EclSolidEnergyApproach solidEnergyApproach() const
90 { return solidEnergyApproach_; }
91
92 // get the parameter object for the HEATCR case
93 template <EclSolidEnergyApproach approachV>
94 typename std::enable_if<approachV == EclSolidEnergyApproach::Heatcr, HeatcrLawParams>::type&
95 getRealParams()
96 {
97 assert(solidEnergyApproach() == approachV);
98 return *static_cast<HeatcrLawParams*>(realParams_);
99 }
100
101 template <EclSolidEnergyApproach approachV>
102 typename std::enable_if<approachV == EclSolidEnergyApproach::Heatcr, const HeatcrLawParams>::type&
103 getRealParams() const
104 {
105 assert(solidEnergyApproach() == approachV);
106 return *static_cast<const HeatcrLawParams*>(realParams_);
107 }
108
109 // get the parameter object for the SPECROCK case
110 template <EclSolidEnergyApproach approachV>
111 typename std::enable_if<approachV == EclSolidEnergyApproach::Specrock, SpecrockLawParams>::type&
112 getRealParams()
113 {
114 assert(solidEnergyApproach() == approachV);
115 return *static_cast<SpecrockLawParams*>(realParams_);
116 }
117
118 template <EclSolidEnergyApproach approachV>
119 typename std::enable_if<approachV == EclSolidEnergyApproach::Specrock, const SpecrockLawParams>::type&
120 getRealParams() const
121 {
122 assert(solidEnergyApproach() == approachV);
123 return *static_cast<const SpecrockLawParams*>(realParams_);
124 }
125
126private:
127 void destroy_()
128 {
129 switch (solidEnergyApproach()) {
130 case EclSolidEnergyApproach::Undefined:
131 break;
132
133 case EclSolidEnergyApproach::Heatcr:
134 delete static_cast<HeatcrLawParams*>(realParams_);
135 break;
136
137 case EclSolidEnergyApproach::Specrock:
138 delete static_cast<SpecrockLawParams*>(realParams_);
139 break;
140
141 case EclSolidEnergyApproach::Null:
142 break;
143 }
144
145 solidEnergyApproach_ = EclSolidEnergyApproach::Undefined;
146 }
147
148 EclSolidEnergyApproach solidEnergyApproach_{EclSolidEnergyApproach::Undefined};
149 ParamPointerType realParams_{nullptr};
150};
151
152} // namespace Opm
153
154#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:49
This class implements a small container which holds the transmissibility mulitpliers for all the face...
Definition Exceptions.hpp:30