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>
42 #include <opm/input/eclipse/Deck/Deck.hpp>
52 template <
class Scalar,
class Flu
idSystem>
57 typedef typename SolidEnergyLaw::Params SolidEnergyLawParams;
58 typedef typename SolidEnergyLawParams::HeatcrLawParams HeatcrLawParams;
59 typedef typename SolidEnergyLawParams::SpecrockLawParams SpecrockLawParams;
62 typedef typename ThermalConductionLaw::Params ThermalConductionLawParams;
66 solidEnergyApproach_ = SolidEnergyLawParams::undefinedApproach;
67 thermalConductivityApproach_ = ThermalConductionLawParams::undefinedApproach;
70 void initParamsForElements(
const EclipseState& eclState,
size_t numElems)
72 const auto& fp = eclState.fieldProps();
73 const auto& tableManager = eclState.getTableManager();
74 bool has_heatcr = fp.has_double(
"HEATCR");
75 bool has_thconr = fp.has_double(
"THCONR");
76 bool has_thc = fp.has_double(
"THCROCK") || fp.has_double(
"THCOIL") || fp.has_double(
"THCGAS") || fp.has_double(
"THCWATER");
79 initHeatcr_(eclState, numElems);
80 else if (tableManager.hasTables(
"SPECROCK"))
81 initSpecrock_(eclState, numElems);
83 initNullRockEnergy_();
86 initThconr_(eclState, numElems);
88 initThc_(eclState, numElems);
93 const SolidEnergyLawParams& solidEnergyLawParams(
unsigned elemIdx)
const
95 switch (solidEnergyApproach_) {
96 case SolidEnergyLawParams::heatcrApproach:
97 assert(elemIdx < solidEnergyLawParams_.size());
98 return solidEnergyLawParams_[elemIdx];
100 case SolidEnergyLawParams::specrockApproach:
102 assert(elemIdx < elemToSatnumIdx_.size());
103 unsigned satnumIdx = elemToSatnumIdx_[elemIdx];
104 assert(satnumIdx < solidEnergyLawParams_.size());
105 return solidEnergyLawParams_[satnumIdx];
108 case SolidEnergyLawParams::nullApproach:
109 return solidEnergyLawParams_[0];
112 throw std::runtime_error(
"Attempting to retrieve solid energy storage parameters "
113 "without a known approach being defined by the deck.");
117 const ThermalConductionLawParams& thermalConductionLawParams(
unsigned elemIdx)
const
119 switch (thermalConductivityApproach_) {
120 case ThermalConductionLawParams::thconrApproach:
121 case ThermalConductionLawParams::thcApproach:
122 assert(elemIdx < thermalConductionLawParams_.size());
123 return thermalConductionLawParams_[elemIdx];
125 case ThermalConductionLawParams::nullApproach:
126 return thermalConductionLawParams_[0];
129 throw std::runtime_error(
"Attempting to retrieve thermal conduction parameters without "
130 "a known approach being defined by the deck.");
138 void initHeatcr_(
const EclipseState& eclState,
141 solidEnergyApproach_ = SolidEnergyLawParams::heatcrApproach;
144 HeatcrLawParams::setReferenceTemperature(FluidSystem::surfaceTemperature);
146 const auto& fp = eclState.fieldProps();
147 const std::vector<double>& heatcrData = fp.get_double(
"HEATCR");
148 const std::vector<double>& heatcrtData = fp.get_double(
"HEATCRT");
149 solidEnergyLawParams_.resize(numElems);
150 for (
unsigned elemIdx = 0; elemIdx < numElems; ++elemIdx) {
151 auto& elemParam = solidEnergyLawParams_[elemIdx];
152 elemParam.setSolidEnergyApproach(SolidEnergyLawParams::heatcrApproach);
153 auto& heatcrElemParams = elemParam.template getRealParams<SolidEnergyLawParams::heatcrApproach>();
155 heatcrElemParams.setReferenceRockHeatCapacity(heatcrData[elemIdx]);
156 heatcrElemParams.setDRockHeatCapacity_dT(heatcrtData[elemIdx]);
157 heatcrElemParams.finalize();
158 elemParam.finalize();
165 void initSpecrock_(
const EclipseState& eclState,
168 solidEnergyApproach_ = SolidEnergyLawParams::specrockApproach;
171 const auto& fp = eclState.fieldProps();
172 const std::vector<int>& satnumData = fp.get_int(
"SATNUM");
173 elemToSatnumIdx_.resize(numElems);
174 for (
unsigned elemIdx = 0; elemIdx < numElems; ++ elemIdx) {
177 elemToSatnumIdx_[elemIdx] = satnumData[elemIdx] - 1;
180 unsigned numSatRegions = eclState.runspec().tabdims().getNumSatTables();
181 const auto& tableManager = eclState.getTableManager();
182 solidEnergyLawParams_.resize(numSatRegions);
183 for (
unsigned satnumIdx = 0; satnumIdx < numSatRegions; ++satnumIdx) {
184 const auto& specrockTable = tableManager.getSpecrockTables()[satnumIdx];
186 auto& multiplexerParams = solidEnergyLawParams_[satnumIdx];
188 multiplexerParams.setSolidEnergyApproach(SolidEnergyLawParams::specrockApproach);
190 auto& specrockParams = multiplexerParams.template getRealParams<SolidEnergyLawParams::specrockApproach>();
191 const auto& temperatureColumn = specrockTable.getColumn(
"TEMPERATURE");
192 const auto& cvRockColumn = specrockTable.getColumn(
"CV_ROCK");
193 specrockParams.setHeatCapacities(temperatureColumn, cvRockColumn);
194 specrockParams.finalize();
196 multiplexerParams.finalize();
203 void initNullRockEnergy_()
205 solidEnergyApproach_ = SolidEnergyLawParams::nullApproach;
207 solidEnergyLawParams_.resize(1);
208 solidEnergyLawParams_[0].finalize();
214 void initThconr_(
const EclipseState& eclState,
217 thermalConductivityApproach_ = ThermalConductionLawParams::thconrApproach;
219 const auto& fp = eclState.fieldProps();
220 std::vector<double> thconrData;
221 std::vector<double> thconsfData;
222 if (fp.has_double(
"THCONR"))
223 thconrData = fp.get_double(
"THCONR");
225 if (fp.has_double(
"THCONSF"))
226 thconsfData = fp.get_double(
"THCONSF");
228 thermalConductionLawParams_.resize(numElems);
229 for (
unsigned elemIdx = 0; elemIdx < numElems; ++elemIdx) {
230 auto& elemParams = thermalConductionLawParams_[elemIdx];
231 elemParams.setThermalConductionApproach(ThermalConductionLawParams::thconrApproach);
232 auto& thconrElemParams = elemParams.template getRealParams<ThermalConductionLawParams::thconrApproach>();
234 double thconr = thconrData.empty() ? 0.0 : thconrData[elemIdx];
235 double thconsf = thconsfData.empty() ? 0.0 : thconsfData[elemIdx];
236 thconrElemParams.setReferenceTotalThermalConductivity(thconr);
237 thconrElemParams.setDTotalThermalConductivity_dSg(thconsf);
239 thconrElemParams.finalize();
240 elemParams.finalize();
247 void initThc_(
const EclipseState& eclState,
250 thermalConductivityApproach_ = ThermalConductionLawParams::thcApproach;
252 const auto& fp = eclState.fieldProps();
253 std::vector<double> thcrockData;
254 std::vector<double> thcoilData;
255 std::vector<double> thcgasData;
256 std::vector<double> thcwaterData = fp.get_double(
"THCWATER");
258 if (fp.has_double(
"THCROCK"))
259 thcrockData = fp.get_double(
"THCROCK");
261 if (fp.has_double(
"THCOIL"))
262 thcoilData = fp.get_double(
"THCOIL");
264 if (fp.has_double(
"THCGAS"))
265 thcgasData = fp.get_double(
"THCGAS");
267 if (fp.has_double(
"THCWATER"))
268 thcwaterData = fp.get_double(
"THCWATER");
270 const std::vector<double>& poroData = fp.get_double(
"PORO");
272 thermalConductionLawParams_.resize(numElems);
273 for (
unsigned elemIdx = 0; elemIdx < numElems; ++elemIdx) {
274 auto& elemParams = thermalConductionLawParams_[elemIdx];
275 elemParams.setThermalConductionApproach(ThermalConductionLawParams::thcApproach);
276 auto& thcElemParams = elemParams.template getRealParams<ThermalConductionLawParams::thcApproach>();
278 thcElemParams.setPorosity(poroData[elemIdx]);
279 double thcrock = thcrockData.empty() ? 0.0 : thcrockData[elemIdx];
280 double thcoil = thcoilData.empty() ? 0.0 : thcoilData[elemIdx];
281 double thcgas = thcgasData.empty() ? 0.0 : thcgasData[elemIdx];
282 double thcwater = thcwaterData.empty() ? 0.0 : thcwaterData[elemIdx];
283 thcElemParams.setThcrock(thcrock);
284 thcElemParams.setThcoil(thcoil);
285 thcElemParams.setThcgas(thcgas);
286 thcElemParams.setThcwater(thcwater);
288 thcElemParams.finalize();
289 elemParams.finalize();
298 thermalConductivityApproach_ = ThermalConductionLawParams::nullApproach;
300 thermalConductionLawParams_.resize(1);
301 thermalConductionLawParams_[0].finalize();
305 typename ThermalConductionLawParams::ThermalConductionApproach thermalConductivityApproach_;
306 typename SolidEnergyLawParams::SolidEnergyApproach solidEnergyApproach_;
308 std::vector<unsigned> elemToSatnumIdx_;
310 std::vector<SolidEnergyLawParams> solidEnergyLawParams_;
311 std::vector<ThermalConductionLawParams> thermalConductionLawParams_;
The default implementation of a parameter object for the ECL thermal law.
Provides the energy storage relation of rock.
The default implementation of a parameter object for the ECL thermal law.
Implements the total thermal conductivity and rock enthalpy relations used by ECL.
Provides the energy storage relation of rock.
Definition: EclSolidEnergyLawMultiplexer.hpp:49
Implements the total thermal conductivity and rock enthalpy relations used by ECL.
Definition: EclThermalConductionLawMultiplexer.hpp:49
Provides an simple way to create and manage the thermal law objects for a complete ECL deck.
Definition: EclThermalLawManager.hpp:54