Merge pull request #391 from akva2/noecl_avoid_global

changed: avoid allocating long vectors of zeros
This commit is contained in:
Arne Morten Kvarving 2020-02-24 13:13:27 +01:00 committed by GitHub
commit 2f838a4268

View File

@ -223,9 +223,8 @@ private:
thermalConductivityApproach_ = ThermalConductionLawParams::thconrApproach;
const auto& fp = eclState.fieldProps();
auto global_size = eclState.getInputGrid().getCartesianSize();
std::vector<double> thconrData(global_size, 0);
std::vector<double> thconsfData(global_size, 0);
std::vector<double> thconrData;
std::vector<double> thconsfData;
if (fp.has_double("THCONR"))
thconrData = fp.get_global_double("THCONR");
@ -240,8 +239,10 @@ private:
auto& thconrElemParams = elemParams.template getRealParams<ThermalConductionLawParams::thconrApproach>();
int cartElemIdx = compressedToCartesianElemIdx[elemIdx];
thconrElemParams.setReferenceTotalThermalConductivity(thconrData[cartElemIdx]);
thconrElemParams.setDTotalThermalConductivity_dSg(thconsfData[cartElemIdx]);
double thconr = thconrData.empty() ? 0.0 : thconrData[cartElemIdx];
double thconsf = thconsfData.empty() ? 0.0 : thconsfData[cartElemIdx];
thconrElemParams.setReferenceTotalThermalConductivity(thconr);
thconrElemParams.setDTotalThermalConductivity_dSg(thconsf);
thconrElemParams.finalize();
elemParams.finalize();
@ -257,10 +258,9 @@ private:
thermalConductivityApproach_ = ThermalConductionLawParams::thcApproach;
const auto& fp = eclState.fieldProps();
auto global_size = eclState.getInputGrid().getCartesianSize();
std::vector<double> thcrockData(global_size,0);
std::vector<double> thcoilData(global_size,0);
std::vector<double> thcgasData(global_size,0);
std::vector<double> thcrockData;
std::vector<double> thcoilData;
std::vector<double> thcgasData;
std::vector<double> thcwaterData = fp.get_global_double("THCWATER");
if (fp.has_double("THCROCK"))
@ -286,10 +286,14 @@ private:
int cartElemIdx = compressedToCartesianElemIdx[elemIdx];
thcElemParams.setPorosity(poroData[cartElemIdx]);
thcElemParams.setThcrock(thcrockData[cartElemIdx]);
thcElemParams.setThcoil(thcoilData[cartElemIdx]);
thcElemParams.setThcgas(thcgasData[cartElemIdx]);
thcElemParams.setThcwater(thcwaterData[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.setThcrock(thcrock);
thcElemParams.setThcoil(thcoil);
thcElemParams.setThcgas(thcgas);
thcElemParams.setThcwater(thcwater);
thcElemParams.finalize();
elemParams.finalize();