My Project
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 
30 #include "EclHeatcrLawParams.hpp"
31 #include "EclSpecrockLawParams.hpp"
32 
34 
35 #include <cassert>
36 #include <stdexcept>
37 #include <type_traits>
38 
39 namespace Opm {
40 
45 template <class ScalarT>
47 {
48  using ParamPointerType = void*;
49 
50 public:
51  using Scalar = ScalarT;
52 
53  enum SolidEnergyApproach {
54  undefinedApproach,
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 
71  void setSolidEnergyApproach(SolidEnergyApproach newApproach)
72  {
73  destroy_();
74 
75  solidEnergyApproach_ = newApproach;
76  switch (solidEnergyApproach()) {
77  case undefinedApproach:
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 
84  case specrockApproach:
85  realParams_ = new SpecrockLawParams;
86  break;
87 
88  case nullApproach:
89  realParams_ = nullptr;
90  break;
91  }
92  }
93 
94  SolidEnergyApproach solidEnergyApproach() const
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&
100  getRealParams()
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&
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 <SolidEnergyApproach approachV>
116  typename std::enable_if<approachV == specrockApproach, SpecrockLawParams>::type&
117  getRealParams()
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&
125  getRealParams() const
126  {
127  assert(solidEnergyApproach() == approachV);
128  return *static_cast<const SpecrockLawParams*>(realParams_);
129  }
130 
131 private:
132  void destroy_()
133  {
134  switch (solidEnergyApproach()) {
135  case undefinedApproach:
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.
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:47
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