27#ifndef OPM_ECL_THERMAL_LAW_MANAGER_HPP
28#define OPM_ECL_THERMAL_LAW_MANAGER_HPP
31#error "Eclipse input support in opm-common is required to use the ECL thermal law manager!"
40#include <opm/input/eclipse/EclipseState/EclipseState.hpp>
41#include <opm/input/eclipse/EclipseState/Tables/TableManager.hpp>
55template <
class Scalar,
class Flu
idSystem>
69 solidEnergyApproach_ = SolidEnergyLawParams::undefinedApproach;
70 thermalConductivityApproach_ = ThermalConductionLawParams::undefinedApproach;
75 const auto& fp = eclState.fieldProps();
76 const auto& tableManager = eclState.getTableManager();
77 bool has_heatcr = fp.has_double(
"HEATCR");
78 bool has_thconr = fp.has_double(
"THCONR");
79 bool has_thc = fp.has_double(
"THCROCK") || fp.has_double(
"THCOIL") || fp.has_double(
"THCGAS") || fp.has_double(
"THCWATER");
82 initHeatcr_(eclState, numElems);
83 else if (tableManager.hasTables(
"SPECROCK"))
84 initSpecrock_(eclState, numElems);
86 initNullRockEnergy_();
89 initThconr_(eclState, numElems);
91 initThc_(eclState, numElems);
98 switch (solidEnergyApproach_) {
99 case SolidEnergyLawParams::heatcrApproach:
100 assert(elemIdx < solidEnergyLawParams_.size());
101 return solidEnergyLawParams_[elemIdx];
103 case SolidEnergyLawParams::specrockApproach:
105 assert(elemIdx < elemToSatnumIdx_.size());
106 unsigned satnumIdx = elemToSatnumIdx_[elemIdx];
107 assert(satnumIdx < solidEnergyLawParams_.size());
108 return solidEnergyLawParams_[satnumIdx];
111 case SolidEnergyLawParams::nullApproach:
112 return solidEnergyLawParams_[0];
115 throw std::runtime_error(
"Attempting to retrieve solid energy storage parameters "
116 "without a known approach being defined by the deck.");
122 switch (thermalConductivityApproach_) {
123 case ThermalConductionLawParams::thconrApproach:
124 case ThermalConductionLawParams::thcApproach:
125 assert(elemIdx < thermalConductionLawParams_.size());
126 return thermalConductionLawParams_[elemIdx];
128 case ThermalConductionLawParams::nullApproach:
129 return thermalConductionLawParams_[0];
132 throw std::runtime_error(
"Attempting to retrieve thermal conduction parameters without "
133 "a known approach being defined by the deck.");
141 void initHeatcr_(
const EclipseState& eclState,
144 solidEnergyApproach_ = SolidEnergyLawParams::heatcrApproach;
147 HeatcrLawParams::setReferenceTemperature(FluidSystem::surfaceTemperature);
149 const auto& fp = eclState.fieldProps();
150 const std::vector<double>& heatcrData = fp.get_double(
"HEATCR");
151 const std::vector<double>& heatcrtData = fp.get_double(
"HEATCRT");
152 solidEnergyLawParams_.resize(numElems);
153 for (
unsigned elemIdx = 0; elemIdx < numElems; ++elemIdx) {
154 auto& elemParam = solidEnergyLawParams_[elemIdx];
155 elemParam.setSolidEnergyApproach(SolidEnergyLawParams::heatcrApproach);
156 auto& heatcrElemParams = elemParam.template getRealParams<SolidEnergyLawParams::heatcrApproach>();
158 heatcrElemParams.setReferenceRockHeatCapacity(heatcrData[elemIdx]);
159 heatcrElemParams.setDRockHeatCapacity_dT(heatcrtData[elemIdx]);
160 heatcrElemParams.finalize();
161 elemParam.finalize();
168 void initSpecrock_(
const EclipseState& eclState,
171 solidEnergyApproach_ = SolidEnergyLawParams::specrockApproach;
174 const auto& fp = eclState.fieldProps();
175 const std::vector<int>& satnumData = fp.get_int(
"SATNUM");
176 elemToSatnumIdx_.resize(numElems);
177 for (
unsigned elemIdx = 0; elemIdx < numElems; ++ elemIdx) {
180 elemToSatnumIdx_[elemIdx] = satnumData[elemIdx] - 1;
183 unsigned numSatRegions = eclState.runspec().tabdims().getNumSatTables();
184 const auto& tableManager = eclState.getTableManager();
185 solidEnergyLawParams_.resize(numSatRegions);
186 for (
unsigned satnumIdx = 0; satnumIdx < numSatRegions; ++satnumIdx) {
187 const auto& specrockTable = tableManager.getSpecrockTables()[satnumIdx];
189 auto& multiplexerParams = solidEnergyLawParams_[satnumIdx];
191 multiplexerParams.setSolidEnergyApproach(SolidEnergyLawParams::specrockApproach);
193 auto& specrockParams = multiplexerParams.template getRealParams<SolidEnergyLawParams::specrockApproach>();
194 const auto& temperatureColumn = specrockTable.getColumn(
"TEMPERATURE");
195 const auto& cvRockColumn = specrockTable.getColumn(
"CV_ROCK");
196 specrockParams.setHeatCapacities(temperatureColumn, cvRockColumn);
197 specrockParams.finalize();
199 multiplexerParams.finalize();
206 void initNullRockEnergy_()
208 solidEnergyApproach_ = SolidEnergyLawParams::nullApproach;
210 solidEnergyLawParams_.resize(1);
211 solidEnergyLawParams_[0].finalize();
217 void initThconr_(
const EclipseState& eclState,
220 thermalConductivityApproach_ = ThermalConductionLawParams::thconrApproach;
222 const auto& fp = eclState.fieldProps();
223 std::vector<double> thconrData;
224 std::vector<double> thconsfData;
225 if (fp.has_double(
"THCONR"))
226 thconrData = fp.get_double(
"THCONR");
228 if (fp.has_double(
"THCONSF"))
229 thconsfData = fp.get_double(
"THCONSF");
231 thermalConductionLawParams_.resize(numElems);
232 for (
unsigned elemIdx = 0; elemIdx < numElems; ++elemIdx) {
233 auto& elemParams = thermalConductionLawParams_[elemIdx];
234 elemParams.setThermalConductionApproach(ThermalConductionLawParams::thconrApproach);
235 auto& thconrElemParams = elemParams.template getRealParams<ThermalConductionLawParams::thconrApproach>();
237 double thconr = thconrData.empty() ? 0.0 : thconrData[elemIdx];
238 double thconsf = thconsfData.empty() ? 0.0 : thconsfData[elemIdx];
239 thconrElemParams.setReferenceTotalThermalConductivity(thconr);
240 thconrElemParams.setDTotalThermalConductivity_dSg(thconsf);
242 thconrElemParams.finalize();
243 elemParams.finalize();
250 void initThc_(
const EclipseState& eclState,
253 thermalConductivityApproach_ = ThermalConductionLawParams::thcApproach;
255 const auto& fp = eclState.fieldProps();
256 std::vector<double> thcrockData;
257 std::vector<double> thcoilData;
258 std::vector<double> thcgasData;
259 std::vector<double> thcwaterData = fp.get_double(
"THCWATER");
261 if (fp.has_double(
"THCROCK"))
262 thcrockData = fp.get_double(
"THCROCK");
264 if (fp.has_double(
"THCOIL"))
265 thcoilData = fp.get_double(
"THCOIL");
267 if (fp.has_double(
"THCGAS"))
268 thcgasData = fp.get_double(
"THCGAS");
270 if (fp.has_double(
"THCWATER"))
271 thcwaterData = fp.get_double(
"THCWATER");
273 const std::vector<double>& poroData = fp.get_double(
"PORO");
275 thermalConductionLawParams_.resize(numElems);
276 for (
unsigned elemIdx = 0; elemIdx < numElems; ++elemIdx) {
277 auto& elemParams = thermalConductionLawParams_[elemIdx];
278 elemParams.setThermalConductionApproach(ThermalConductionLawParams::thcApproach);
279 auto& thcElemParams = elemParams.template getRealParams<ThermalConductionLawParams::thcApproach>();
281 thcElemParams.setPorosity(poroData[elemIdx]);
282 double thcrock = thcrockData.empty() ? 0.0 : thcrockData[elemIdx];
283 double thcoil = thcoilData.empty() ? 0.0 : thcoilData[elemIdx];
284 double thcgas = thcgasData.empty() ? 0.0 : thcgasData[elemIdx];
285 double thcwater = thcwaterData.empty() ? 0.0 : thcwaterData[elemIdx];
286 thcElemParams.setThcrock(thcrock);
287 thcElemParams.setThcoil(thcoil);
288 thcElemParams.setThcgas(thcgas);
289 thcElemParams.setThcwater(thcwater);
291 thcElemParams.finalize();
292 elemParams.finalize();
301 thermalConductivityApproach_ = ThermalConductionLawParams::nullApproach;
303 thermalConductionLawParams_.resize(1);
304 thermalConductionLawParams_[0].finalize();
308 typename ThermalConductionLawParams::ThermalConductionApproach thermalConductivityApproach_;
309 typename SolidEnergyLawParams::SolidEnergyApproach solidEnergyApproach_;
311 std::vector<unsigned> elemToSatnumIdx_;
313 std::vector<SolidEnergyLawParams> solidEnergyLawParams_;
314 std::vector<ThermalConductionLawParams> thermalConductionLawParams_;
Provides the energy storage relation of rock.
Definition: EclSolidEnergyLawMultiplexer.hpp:50
ParamsT Params
Definition: EclSolidEnergyLawMultiplexer.hpp:58
Implements the total thermal conductivity and rock enthalpy relations used by ECL.
Definition: EclThermalConductionLawMultiplexer.hpp:50
ParamsT Params
Definition: EclThermalConductionLawMultiplexer.hpp:58
Provides an simple way to create and manage the thermal law objects for a complete ECL deck.
Definition: EclThermalLawManager.hpp:57
typename SolidEnergyLawParams::HeatcrLawParams HeatcrLawParams
Definition: EclThermalLawManager.hpp:61
EclThermalLawManager()
Definition: EclThermalLawManager.hpp:67
typename SolidEnergyLaw::Params SolidEnergyLawParams
Definition: EclThermalLawManager.hpp:60
const ThermalConductionLawParams & thermalConductionLawParams(unsigned elemIdx) const
Definition: EclThermalLawManager.hpp:120
typename ThermalConductionLaw::Params ThermalConductionLawParams
Definition: EclThermalLawManager.hpp:65
const SolidEnergyLawParams & solidEnergyLawParams(unsigned elemIdx) const
Definition: EclThermalLawManager.hpp:96
void initParamsForElements(const EclipseState &eclState, size_t numElems)
Definition: EclThermalLawManager.hpp:73
typename SolidEnergyLawParams::SpecrockLawParams SpecrockLawParams
Definition: EclThermalLawManager.hpp:62
Definition: Air_Mesitylene.hpp:34