use compressed field properties in EclThermalLawManager

This commit is contained in:
Arne Morten Kvarving 2020-01-28 11:16:52 +01:00
parent efdb6a4dfc
commit ac9207cba1

View File

@ -69,8 +69,7 @@ public:
thermalConductivityApproach_ = ThermalConductionLawParams::undefinedApproach;
}
void initParamsForElements(const Opm::EclipseState& eclState,
const std::vector<int>& compressedToCartesianElemIdx)
void initParamsForElements(const Opm::EclipseState& eclState, size_t numElems)
{
const auto& fp = eclState.fieldProps();
const auto& tableManager = eclState.getTableManager();
@ -79,16 +78,16 @@ public:
bool has_thc = fp.has_double("THCROCK") || fp.has_double("THCOIL") || fp.has_double("THCGAS") || fp.has_double("THCWATER");
if (has_heatcr)
initHeatcr_(eclState, compressedToCartesianElemIdx);
initHeatcr_(eclState, numElems);
else if (tableManager.hasTables("SPECROCK"))
initSpecrock_(eclState, compressedToCartesianElemIdx);
initSpecrock_(eclState, numElems);
else
initNullRockEnergy_();
if (has_thconr)
initThconr_(eclState, compressedToCartesianElemIdx);
initThconr_(eclState, numElems);
else if (has_thc)
initThc_(eclState, compressedToCartesianElemIdx);
initThc_(eclState, numElems);
else
initNullCond_();
}
@ -139,7 +138,7 @@ private:
* \brief Initialize the parameters for the solid energy law using using HEATCR and friends.
*/
void initHeatcr_(const Opm::EclipseState& eclState,
const std::vector<int>& compressedToCartesianElemIdx)
size_t numElems)
{
solidEnergyApproach_ = SolidEnergyLawParams::heatcrApproach;
// actually the value of the reference temperature does not matter for energy
@ -147,18 +146,16 @@ private:
HeatcrLawParams::setReferenceTemperature(FluidSystem::surfaceTemperature);
const auto& fp = eclState.fieldProps();
const std::vector<double>& heatcrData = fp.get_global_double("HEATCR");
const std::vector<double>& heatcrtData = fp.get_global_double("HEATCRT");
unsigned numElems = compressedToCartesianElemIdx.size();
const std::vector<double>& heatcrData = fp.get_double("HEATCR");
const std::vector<double>& heatcrtData = fp.get_double("HEATCRT");
solidEnergyLawParams_.resize(numElems);
for (unsigned elemIdx = 0; elemIdx < numElems; ++elemIdx) {
auto& elemParam = solidEnergyLawParams_[elemIdx];
elemParam.setSolidEnergyApproach(SolidEnergyLawParams::heatcrApproach);
auto& heatcrElemParams = elemParam.template getRealParams<SolidEnergyLawParams::heatcrApproach>();
unsigned cartesianElemIdx = compressedToCartesianElemIdx[elemIdx];
heatcrElemParams.setReferenceRockHeatCapacity(heatcrData[cartesianElemIdx]);
heatcrElemParams.setDRockHeatCapacity_dT(heatcrtData[cartesianElemIdx]);
heatcrElemParams.setReferenceRockHeatCapacity(heatcrData[elemIdx]);
heatcrElemParams.setDRockHeatCapacity_dT(heatcrtData[elemIdx]);
heatcrElemParams.finalize();
elemParam.finalize();
}
@ -168,20 +165,18 @@ private:
* \brief Initialize the parameters for the solid energy law using using SPECROCK and friends.
*/
void initSpecrock_(const Opm::EclipseState& eclState,
const std::vector<int>& compressedToCartesianElemIdx)
size_t numElems)
{
solidEnergyApproach_ = SolidEnergyLawParams::specrockApproach;
// initialize the element index -> SATNUM index mapping
const auto& fp = eclState.fieldProps();
const std::vector<int>& satnumData = fp.get_global_int("SATNUM");
elemToSatnumIdx_.resize(compressedToCartesianElemIdx.size());
for (unsigned elemIdx = 0; elemIdx < compressedToCartesianElemIdx.size(); ++ elemIdx) {
unsigned cartesianElemIdx = compressedToCartesianElemIdx[elemIdx];
const std::vector<int>& satnumData = fp.get_int("SATNUM");
elemToSatnumIdx_.resize(numElems);
for (unsigned elemIdx = 0; elemIdx < numElems; ++ elemIdx) {
// satnumData contains Fortran-style indices, i.e., they start with 1 instead
// of 0!
elemToSatnumIdx_[elemIdx] = satnumData[cartesianElemIdx] - 1;
elemToSatnumIdx_[elemIdx] = satnumData[elemIdx] - 1;
}
// internalize the SPECROCK table
unsigned numSatRegions = eclState.runspec().tabdims().getNumSatTables();
@ -219,7 +214,7 @@ private:
* \brief Initialize the parameters for the thermal conduction law using THCONR and friends.
*/
void initThconr_(const Opm::EclipseState& eclState,
const std::vector<int>& compressedToCartesianElemIdx)
size_t numElems)
{
thermalConductivityApproach_ = ThermalConductionLawParams::thconrApproach;
@ -227,21 +222,19 @@ private:
std::vector<double> thconrData;
std::vector<double> thconsfData;
if (fp.has_double("THCONR"))
thconrData = fp.get_global_double("THCONR");
thconrData = fp.get_double("THCONR");
if (fp.has_double("THCONSF"))
thconsfData = fp.get_global_double("THCONSF");
thconsfData = fp.get_double("THCONSF");
unsigned numElems = compressedToCartesianElemIdx.size();
thermalConductionLawParams_.resize(numElems);
for (unsigned elemIdx = 0; elemIdx < numElems; ++elemIdx) {
auto& elemParams = thermalConductionLawParams_[elemIdx];
elemParams.setThermalConductionApproach(ThermalConductionLawParams::thconrApproach);
auto& thconrElemParams = elemParams.template getRealParams<ThermalConductionLawParams::thconrApproach>();
int cartElemIdx = compressedToCartesianElemIdx[elemIdx];
double thconr = thconrData.empty() ? 0.0 : thconrData[cartElemIdx];
double thconsf = thconsfData.empty() ? 0.0 : thconsfData[cartElemIdx];
double thconr = thconrData.empty() ? 0.0 : thconrData[elemIdx];
double thconsf = thconsfData.empty() ? 0.0 : thconsfData[elemIdx];
thconrElemParams.setReferenceTotalThermalConductivity(thconr);
thconrElemParams.setDTotalThermalConductivity_dSg(thconsf);
@ -254,7 +247,7 @@ private:
* \brief Initialize the parameters for the thermal conduction law using THCROCK and friends.
*/
void initThc_(const Opm::EclipseState& eclState,
const std::vector<int>& compressedToCartesianElemIdx)
size_t numElems)
{
thermalConductivityApproach_ = ThermalConductionLawParams::thcApproach;
@ -262,35 +255,33 @@ private:
std::vector<double> thcrockData;
std::vector<double> thcoilData;
std::vector<double> thcgasData;
std::vector<double> thcwaterData = fp.get_global_double("THCWATER");
std::vector<double> thcwaterData = fp.get_double("THCWATER");
if (fp.has_double("THCROCK"))
thcrockData = fp.get_global_double("THCROCK");
thcrockData = fp.get_double("THCROCK");
if (fp.has_double("THCOIL"))
thcoilData = fp.get_global_double("THCOIL");
thcoilData = fp.get_double("THCOIL");
if (fp.has_double("THCGAS"))
thcgasData = fp.get_global_double("THCGAS");
thcgasData = fp.get_double("THCGAS");
if (fp.has_double("THCWATER"))
thcwaterData = fp.get_global_double("THCWATER");
thcwaterData = fp.get_double("THCWATER");
const std::vector<double>& poroData = fp.get_global_double("PORO");
const std::vector<double>& poroData = fp.get_double("PORO");
unsigned numElems = compressedToCartesianElemIdx.size();
thermalConductionLawParams_.resize(numElems);
for (unsigned elemIdx = 0; elemIdx < numElems; ++elemIdx) {
auto& elemParams = thermalConductionLawParams_[elemIdx];
elemParams.setThermalConductionApproach(ThermalConductionLawParams::thcApproach);
auto& thcElemParams = elemParams.template getRealParams<ThermalConductionLawParams::thcApproach>();
int cartElemIdx = compressedToCartesianElemIdx[elemIdx];
thcElemParams.setPorosity(poroData[cartElemIdx]);
double thcrock = thcrockData.empty() ? 0.0 : thcrockData[cartElemIdx];
double thcoil = thcoilData.empty() ? 0.0 : thcoilData[cartElemIdx];
double thcgas = thcgasData.empty() ? 0.0 : thcgasData[cartElemIdx];
double thcwater = thcwaterData.empty() ? 0.0 : thcwaterData[cartElemIdx];
thcElemParams.setPorosity(poroData[elemIdx]);
double thcrock = thcrockData.empty() ? 0.0 : thcrockData[elemIdx];
double thcoil = thcoilData.empty() ? 0.0 : thcoilData[elemIdx];
double thcgas = thcgasData.empty() ? 0.0 : thcgasData[elemIdx];
double thcwater = thcwaterData.empty() ? 0.0 : thcwaterData[elemIdx];
thcElemParams.setThcrock(thcrock);
thcElemParams.setThcoil(thcoil);
thcElemParams.setThcgas(thcgas);