23#ifndef OPM_FLOW_GENERIC_PROBLEM_IMPL_HPP
24#define OPM_FLOW_GENERIC_PROBLEM_IMPL_HPP
26#ifndef OPM_FLOW_GENERIC_PROBLEM_HPP
31#include <dune/common/parametertree.hh>
33#include <opm/common/ErrorMacros.hpp>
34#include <opm/common/utility/TimeService.hpp>
36#include <opm/input/eclipse/EclipseState/EclipseState.hpp>
37#include <opm/input/eclipse/EclipseState/Tables/OverburdTable.hpp>
38#include <opm/input/eclipse/EclipseState/Tables/RockwnodTable.hpp>
39#include <opm/input/eclipse/Schedule/Schedule.hpp>
40#include <opm/input/eclipse/Units/Units.hpp>
51#include <boost/date_time.hpp>
53#include <fmt/format.h>
54#include <fmt/ranges.h>
61template<
class Gr
idView,
class Flu
idSystem>
64 const Schedule& schedule,
65 const GridView& gridView)
69 , lookUpData_(gridView)
87 if (Parameters::IsSet<Parameters::NumPressurePointsEquil>()) {
90 throw std::invalid_argument {
91 fmt::format(
"--num-pressure-points-equil must be at least 1, "
99 throw std::invalid_argument {
100 fmt::format(
"EQLDIMS item 2, the number of depth nodes in the "
101 "equilibration pressure tables, must be at least 1, "
110template<
class Gr
idView,
class Flu
idSystem>
114 const Schedule& schedule,
115 const GridView& gridView)
131template<
class Gr
idView,
class Flu
idSystem>
142 "Usage: "+std::string(argv[0]) +
" [OPTIONS] [DECK_FILENAME]\n"
146template<
class Gr
idView,
class Flu
idSystem>
151 return briefDescription_;
154template<
class Gr
idView,
class Flu
idSystem>
157 std::function<std::array<int,3>(
const unsigned)> ijkIndex)
159 const auto& rock_config = eclState_.getSimulationConfig().rock_config();
163 const auto& comp = rock_config.comp();
165 std::ranges::transform(comp, std::back_inserter(rockParams_),
169 static_cast<Scalar>(c.pref),
170 static_cast<Scalar>(c.compressibility)
176 if (rock_config.store()) {
177 OpmLog::warning(
"ROCKOPTS item 2 set to STORE, ROCK item 1 replaced with initial (equilibrated) pressures");
181 readRockCompactionParameters_();
183 unsigned numElem = gridView_.size(0);
184 if (eclState_.fieldProps().has_int(rock_config.rocknum_property())) {
186 std::function<void(
int,
int)> valueCheck = [&ijkIndex,&rock_config,
this](
int fieldPropValue,
int coarseElemIdx)
188 auto fmtError = [fieldPropValue, coarseElemIdx,&ijkIndex,&rock_config](
const char* type, std::size_t size)
190 return fmt::format(
"{} table index {} for elem {} read from {}"
191 " is out of bounds for number of tables {}",
192 type, fieldPropValue,
193 ijkIndex(coarseElemIdx),
194 rock_config.rocknum_property(), size);
196 if (!rockCompPoroMult_.empty() &&
197 fieldPropValue >
static_cast<int>(rockCompPoroMult_.size())) {
198 throw std::runtime_error(fmtError(
"Rock compaction",
199 rockCompPoroMult_.size()));
201 if (!rockCompPoroMultWc_.empty() &&
202 fieldPropValue >
static_cast<int>(rockCompPoroMultWc_.size())) {
203 throw std::runtime_error(fmtError(
"Rock water compaction",
204 rockCompPoroMultWc_.size()));
208 rockTableIdx_ = this->lookUpData_.template assignFieldPropsIntOnLeaf<short unsigned int>(eclState_.fieldProps(),
209 rock_config.rocknum_property(),
215 const auto& overburdTables = eclState_.getTableManager().getOverburdTables();
216 if (!overburdTables.empty() && !rock_config.store()) {
217 overburdenPressure_.resize(numElem,0.0);
218 std::size_t numRocktabTables = rock_config.num_rock_tables();
220 if (overburdTables.size() != numRocktabTables)
221 throw std::runtime_error(fmt::format(
"{} OVERBURD tables is expected, but {} is provided",
222 numRocktabTables, overburdTables.size()));
224 std::vector<Tabulated1DFunction<Scalar>> overburdenTables(numRocktabTables);
225 for (std::size_t regionIdx = 0; regionIdx < numRocktabTables; ++regionIdx) {
226 const OverburdTable& overburdTable = overburdTables.template getTable<OverburdTable>(regionIdx);
227 overburdenTables[regionIdx].setXYContainers(overburdTable.getDepthColumn(),overburdTable.getOverburdenPressureColumn());
230 for (std::size_t elemIdx = 0; elemIdx < numElem; ++ elemIdx) {
231 unsigned tableIdx = 0;
232 if (!rockTableIdx_.empty()) {
233 tableIdx = rockTableIdx_[elemIdx];
235 overburdenPressure_[elemIdx] =
236 overburdenTables[tableIdx].eval(cellCenterDepths[elemIdx],
true);
239 else if (!overburdTables.empty() && rock_config.store()) {
240 OpmLog::warning(
"ROCKOPTS item 2 set to STORE, OVERBURD ignored!");
244template<
class Gr
idView,
class Flu
idSystem>
248 const auto& rock_config = eclState_.getSimulationConfig().rock_config();
250 if (!rock_config.active())
253 unsigned numElem = gridView_.size(0);
254 switch (rock_config.hysteresis_mode()) {
255 case RockConfig::Hysteresis::REVERS:
257 case RockConfig::Hysteresis::IRREVERS:
260 minRefPressure_.resize(numElem, 1e99);
262 case RockConfig::Hysteresis::HYSTER:
266 minRefPressure_.resize(numElem, 1e99);
269 throw std::runtime_error(
"Not support ROCKOMP hysteresis option ");
272 std::size_t numRocktabTables = rock_config.num_rock_tables();
273 bool waterCompaction = rock_config.water_compaction();
275 if (waterCompaction && rock_config.hysteresis_mode() == RockConfig::Hysteresis::HYSTER)
276 throw std::runtime_error(
"ROCKCOMP: combining WATER_COMPACTION with HYSTERESIS=HYSTER is not supported");
278 if (!waterCompaction && rock_config.hysteresis_mode() == RockConfig::Hysteresis::HYSTER) {
279 const auto& rocktabhTables = eclState_.getTableManager().getRocktabhTables();
280 if (rocktabhTables.size() != numRocktabTables)
281 throw std::runtime_error(
"ROCKCOMP HYSTERESIS is set to HYSTER. " +
std::to_string(numRocktabTables)
282 +
" ROCKTABH tables is expected, but " +
std::to_string(rocktabhTables.size()) +
" is provided");
287 rockCompPoroMult_.resize(numRocktabTables);
288 rockCompTransMult_.resize(numRocktabTables);
289 rockCompPoroMultElastic_.resize(numRocktabTables);
290 rockCompTransMultElastic_.resize(numRocktabTables);
291 for (std::size_t regionIdx = 0; regionIdx < numRocktabTables; ++regionIdx) {
292 const auto& rocktabhTable = rocktabhTables[regionIdx];
294 const auto& deflation = rocktabhTable.deflationCurve();
295 rockCompPoroMult_[regionIdx].setXYContainers(deflation.getColumn(0), deflation.getColumn(1));
296 rockCompTransMult_[regionIdx].setXYContainers(deflation.getColumn(0), deflation.getColumn(2));
300 const std::size_t numCurves = rocktabhTable.numElasticCurves();
301 for (std::size_t curveIdx = 0; curveIdx < numCurves; ++curveIdx) {
302 const auto& curve = rocktabhTable.elasticCurve(curveIdx);
303 const auto& pressure = curve.getColumn(0);
304 const auto& poro = curve.getColumn(1);
305 const auto& trans = curve.getColumn(2);
307 poroBuilder.appendXPos(pressure[0]);
308 transBuilder.appendXPos(pressure[0]);
309 for (std::size_t rowIdx = 0; rowIdx < curve.numRows(); ++rowIdx) {
310 poroBuilder.appendSamplePoint(curveIdx, pressure[rowIdx], poro[rowIdx]);
311 transBuilder.appendSamplePoint(curveIdx, pressure[rowIdx], trans[rowIdx]);
314 rockCompPoroMultElastic_[regionIdx] = std::move(poroBuilder).build();
315 rockCompTransMultElastic_[regionIdx] = std::move(transBuilder).build();
317 }
else if (!waterCompaction) {
318 const auto& rocktabTables = eclState_.getTableManager().getRocktabTables();
319 if (rocktabTables.size() != numRocktabTables)
320 throw std::runtime_error(
"ROCKCOMP is activated." +
std::to_string(numRocktabTables)
321 +
" ROCKTAB tables is expected, but " +
std::to_string(rocktabTables.size()) +
" is provided");
323 rockCompPoroMult_.resize(numRocktabTables);
324 rockCompTransMult_.resize(numRocktabTables);
325 for (std::size_t regionIdx = 0; regionIdx < numRocktabTables; ++regionIdx) {
326 const auto& rocktabTable = rocktabTables.template getTable<RocktabTable>(regionIdx);
327 const auto& pressureColumn = rocktabTable.getPressureColumn();
328 const auto& poroColumn = rocktabTable.getPoreVolumeMultiplierColumn();
329 const auto& transColumn = rocktabTable.getTransmissibilityMultiplierColumn();
330 rockCompPoroMult_[regionIdx].setXYContainers(pressureColumn, poroColumn);
331 rockCompTransMult_[regionIdx].setXYContainers(pressureColumn, transColumn);
334 const auto& rock2dTables = eclState_.getTableManager().getRock2dTables();
335 const auto& rock2dtrTables = eclState_.getTableManager().getRock2dtrTables();
336 const auto& rockwnodTables = eclState_.getTableManager().getRockwnodTables();
337 maxWaterSaturation_.resize(numElem, 0.0);
339 if (rock2dTables.size() != numRocktabTables)
340 throw std::runtime_error(fmt::format(
"Water compation option is selected in ROCKCOMP."
341 " {} ROCK2D tables is expected, but {} is provided",
342 numRocktabTables, rock2dTables.size()));
344 if (rockwnodTables.size() != numRocktabTables)
345 throw std::runtime_error(fmt::format(
"Water compation option is selected in ROCKCOMP."
346 " {} ROCKWNOD tables is expected, but {} is provided",
347 numRocktabTables, rockwnodTables.size()));
349 rockCompPoroMultWc_.resize(numRocktabTables);
350 for (std::size_t regionIdx = 0; regionIdx < numRocktabTables; ++regionIdx) {
351 const RockwnodTable& rockwnodTable = rockwnodTables.template getTable<RockwnodTable>(regionIdx);
352 const auto& rock2dTable = rock2dTables[regionIdx];
354 if (rockwnodTable.getSaturationColumn().size() != rock2dTable.sizeMultValues())
355 throw std::runtime_error(
"Number of entries in ROCKWNOD and ROCK2D needs to match.");
358 for (std::size_t xIdx = 0; xIdx < rock2dTable.size(); ++xIdx) {
359 builder.appendXPos(rock2dTable.getPressureValue(xIdx));
360 for (std::size_t yIdx = 0; yIdx < rockwnodTable.getSaturationColumn().size(); ++yIdx)
361 builder.appendSamplePoint(xIdx,
362 rockwnodTable.getSaturationColumn()[yIdx],
363 rock2dTable.getPvmultValue(xIdx, yIdx));
365 rockCompPoroMultWc_[regionIdx] = std::move(builder).build();
368 if (!rock2dtrTables.empty()) {
369 rockCompTransMultWc_.resize(numRocktabTables);
370 for (std::size_t regionIdx = 0; regionIdx < numRocktabTables; ++regionIdx) {
371 const RockwnodTable& rockwnodTable = rockwnodTables.template getTable<RockwnodTable>(regionIdx);
372 const auto& rock2dtrTable = rock2dtrTables[regionIdx];
374 if (rockwnodTable.getSaturationColumn().size() != rock2dtrTable.sizeMultValues())
375 throw std::runtime_error(
"Number of entries in ROCKWNOD and ROCK2DTR needs to match.");
377 TabulatedTwoDFunctionBuilder builder{TabulatedTwoDFunction::InterpolationPolicy::Vertical};
378 for (std::size_t xIdx = 0; xIdx < rock2dtrTable.size(); ++xIdx) {
379 builder.appendXPos(rock2dtrTable.getPressureValue(xIdx));
380 for (std::size_t yIdx = 0; yIdx < rockwnodTable.getSaturationColumn().size(); ++yIdx)
381 builder.appendSamplePoint(xIdx,
382 rockwnodTable.getSaturationColumn()[yIdx],
383 rock2dtrTable.getTransMultValue(xIdx, yIdx));
385 rockCompTransMultWc_[regionIdx] = std::move(builder).build();
391template<
class Gr
idView,
class Flu
idSystem>
396 if (this->rockParams_.empty())
399 unsigned tableIdx = 0;
400 if (!this->rockTableIdx_.empty()) {
401 tableIdx = this->rockTableIdx_[globalSpaceIdx];
403 return this->rockParams_[tableIdx].compressibility;
406template<
class Gr
idView,
class Flu
idSystem>
409porosity(
unsigned globalSpaceIdx,
unsigned timeIdx)
const
411 return this->referencePorosity_[timeIdx][globalSpaceIdx];
414template<
class Gr
idView,
class Flu
idSystem>
420 const auto biot = biotCoeff(elementIdx);
421 const auto lameParam = lame(elementIdx);
422 return biot * biot / lameParam;
425template <
class Gr
idView,
class Flu
idSystem>
431 const auto biotT = biotTemp(elementIdx);
432 const auto biotC = biotCoeff(elementIdx);
433 const auto lameParam = lame(elementIdx);
434 return biotC * biotT / lameParam;
437template<
class Gr
idView,
class Flu
idSystem>
440lame(
unsigned elementIdx)
const
443 const auto& fp = eclState_.fieldProps();
444 if (fp.has_double(
"LAME")) {
445 lameParam = this->lookUpData_.fieldPropDouble(this->eclState_.fieldProps(),
"LAME", elementIdx);
447 else if (fp.has_double(
"YMODULE") && fp.has_double(
"SMODULUS")) {
448 const auto& yModulus = this->lookUpData_.fieldPropDouble(this->eclState_.fieldProps(),
"YMODULE", elementIdx);
449 const auto& sModulus = this->lookUpData_.fieldPropDouble(this->eclState_.fieldProps(),
"SMODULUS", elementIdx);
450 lameParam = sModulus * (yModulus - 2 * sModulus) / (3 * sModulus - yModulus);
452 else if (fp.has_double(
"YMODULE") && fp.has_double(
"PRATIO")) {
453 const auto& yModulus = this->lookUpData_.fieldPropDouble(this->eclState_.fieldProps(),
"YMODULE", elementIdx);
454 const auto& pRatio = this->lookUpData_.fieldPropDouble(this->eclState_.fieldProps(),
"PRATIO", elementIdx);
455 lameParam = yModulus * pRatio / ((1 + pRatio) * (1 - 2 * pRatio));
457 else if (fp.has_double(
"SMODULUS") && fp.has_double(
"PRATIO")) {
458 const auto& sModulus = this->lookUpData_.fieldPropDouble(this->eclState_.fieldProps(),
"SMODULUS", elementIdx);
459 const auto& pRatio = this->lookUpData_.fieldPropDouble(this->eclState_.fieldProps(),
"PRATIO", elementIdx);
460 lameParam = 2 * sModulus * pRatio / (1 - 2 * pRatio);
468template<
class Gr
idView,
class Flu
idSystem>
474 const auto& fp = eclState_.fieldProps();
475 if (fp.has_double(
"BIOTCOEF")) {
476 biotC = this->lookUpData_.fieldPropDouble(this->eclState_.fieldProps(),
"BIOTCOEF", elementIdx);
478 else if (fp.has_double(
"POELCOEF") && fp.has_double(
"PRATIO")) {
479 const auto& poelC = this->lookUpData_.fieldPropDouble(this->eclState_.fieldProps(),
"POELCOEF", elementIdx);
480 const auto& pRatio = this->lookUpData_.fieldPropDouble(this->eclState_.fieldProps(),
"PRATIO", elementIdx);
481 biotC = poelC * (1 - pRatio) / (1 - 2 * pRatio);
489template <
class Gr
idView,
class Flu
idSystem>
494 const auto& fp = eclState_.fieldProps();
497 if (!fp.has_double(
"THERMEXR") && !fp.has_double(
"THELCOEF")) {
504 if (fp.has_double(
"THERMEXR") && !fp.has_double(
"THELCOEF")) {
505 const auto thermexr = this->lookUpData_.fieldPropDouble(fp,
"THERMEXR", elementIdx);
507 if (fp.has_double(
"LAME") && fp.has_double(
"SMODULUS")) {
508 const auto lamParam = lame(elementIdx);
509 const auto sMod = this->lookUpData_.fieldPropDouble(fp,
"SMODULUS", elementIdx);
510 biotT = thermexr * (3.0 * lamParam + 2.0 * sMod);
511 }
else if (fp.has_double(
"YMODULE") && fp.has_double(
"PRATIO")) {
512 const auto yMod = this->lookUpData_.fieldPropDouble(fp,
"YMODULE", elementIdx);
513 const auto pRatio = this->lookUpData_.fieldPropDouble(fp,
"PRATIO", elementIdx);
514 biotT = thermexr * yMod / (1.0 - 2.0 * pRatio);
515 }
else if (fp.has_double(
"LAME") && fp.has_double(
"PRATIO")) {
516 const auto lamParam = lame(elementIdx);
517 const auto pRatio = this->lookUpData_.fieldPropDouble(fp,
"PRATIO", elementIdx);
519 thermexr * lamParam * (1.0 / pRatio - 2.0 * pRatio - 1.0) / (1.0 - 2.0 * pRatio);
520 }
else if (fp.has_double(
"SMODULUS") && fp.has_double(
"PRATIO")) {
521 const auto sMod = this->lookUpData_.fieldPropDouble(fp,
"SMODULUS", elementIdx);
522 const auto pRatio = this->lookUpData_.fieldPropDouble(fp,
"PRATIO", elementIdx);
523 biotT = thermexr * 2.0 * sMod * (1 + pRatio) / (1.0 - 2.0 * pRatio);
524 }
else if (fp.has_double(
"YMODULE") && fp.has_double(
"SMODULUS")) {
525 const auto yMod = this->lookUpData_.fieldPropDouble(fp,
"YMODULE", elementIdx);
526 const auto sMod = this->lookUpData_.fieldPropDouble(fp,
"SMODULUS", elementIdx);
527 biotT = thermexr * yMod * sMod / (3.0 * sMod - yMod);
529 OPM_THROW(std::runtime_error,
530 "THERMEXR requires one of (LAME, SMODULUS), (YMODULE, PRATIO), "
531 "(LAME, PRATIO), (SMODULUS, PRATIO) or (YMODULE, SMODULUS) "
532 "to compute the Biot temperature coefficient. "
533 "(YMODULE, LAME) is not supported.");
536 }
else if (!fp.has_double(
"THERMEXR") && fp.has_double(
"THELCOEF")) {
537 const auto thelcoef = this->lookUpData_.fieldPropDouble(fp,
"THELCOEF", elementIdx);
539 if (fp.has_double(
"LAME") && fp.has_double(
"SMODULUS")) {
540 const auto lamParam = lame(elementIdx);
541 const auto sMod = this->lookUpData_.fieldPropDouble(fp,
"SMODULUS", elementIdx);
542 biotT = thelcoef * (lamParam + 2 * sMod) / (2 * sMod);
543 }
else if (fp.has_double(
"PRATIO")) {
544 const auto pRatio = this->lookUpData_.fieldPropDouble(fp,
"PRATIO", elementIdx);
545 biotT = thelcoef * (1 - pRatio) / (1 - 2 * pRatio);
546 }
else if (fp.has_double(
"YMODULE") && fp.has_double(
"SMODULUS")) {
547 const auto yMod = this->lookUpData_.fieldPropDouble(fp,
"YMODULE", elementIdx);
548 const auto sMod = this->lookUpData_.fieldPropDouble(fp,
"SMODULUS", elementIdx);
549 biotT = thelcoef * (4.0 * sMod - yMod) / (6.0 * sMod - 2.0 * yMod);
551 OPM_THROW(std::runtime_error,
552 "THELCOEF requires one of (LAME, SMODULUS), (YMODULE, SMODULUS) "
553 "to compute the Biot temperature coefficient. "
554 "(YMODULE, LAME) is not supported.");
557 OPM_THROW(std::runtime_error,
558 "THERMEXR and THELCOEF cannot both be specified for the "
559 "Biot temperature coefficient");
565template<
class Gr
idView,
class Flu
idSystem>
568updateNum(
const std::string& name, std::vector<T>& numbers, std::size_t num_regions)
570 if (!eclState_.fieldProps().has_int(name))
573 std::function<void(T,
int)> valueCheck = [num_regions,name](T fieldPropValue, [[maybe_unused]]
int fieldPropIdx) {
574 if (fieldPropValue >
static_cast<int>(num_regions)) {
575 throw std::runtime_error(fmt::format(
"Values larger than maximum number of regions {} provided in {}",
578 if (fieldPropValue <= 0) {
579 throw std::runtime_error(
"zero or negative values provided for region array: " + name);
583 numbers = this->lookUpData_.template assignFieldPropsIntOnLeaf<T>(eclState_.fieldProps(), name,
587template<
class Gr
idView,
class Flu
idSystem>
591 const auto num_regions = eclState_.getTableManager().getTabdims().getNumPVTTables();
592 updateNum(
"PVTNUM", pvtnum_, num_regions);
595template<
class Gr
idView,
class Flu
idSystem>
599 const auto num_regions = eclState_.getTableManager().getTabdims().getNumSatTables();
600 updateNum(
"SATNUM", satnum_, num_regions);
603template<
class Gr
idView,
class Flu
idSystem>
607 const auto num_regions = 1;
608 updateNum(
"MISCNUM", miscnum_, num_regions);
611template<
class Gr
idView,
class Flu
idSystem>
615 const auto num_regions = 1;
616 updateNum(
"PLMIXNUM", plmixnum_, num_regions);
619template<
class Gr
idView,
class Flu
idSystem>
623 const auto& oilVaporizationControl = schedule_[episodeIdx].oilvap();
624 return (oilVaporizationControl.getType() == OilVaporizationProperties::OilVaporization::VAPPARS);
627template<
class Gr
idView,
class Flu
idSystem>
632 if (enableExperiments && gridView_.comm().rank() == 0 && episodeIdx >= 0) {
635 std::ostringstream ss;
636 boost::posix_time::time_facet* facet =
new boost::posix_time::time_facet(
"%d-%b-%Y");
637 boost::posix_time::ptime curDateTime =
638 boost::posix_time::from_time_t(TimeService::to_time_t(schedule_.simTime(episodeIdx)));
639 ss.imbue(std::locale(std::locale::classic(), facet));
640 ss <<
"Report step " << episodeIdx + 1
641 <<
"/" << schedule_.size() - 1
642 <<
" at day " << schedule_.seconds(episodeIdx)/(24*3600)
643 <<
"/" << schedule_.seconds(schedule_.size() - 1)/(24*3600)
644 <<
", date = " << curDateTime.date()
646 OpmLog::info(ss.str());
649 const auto& events = schedule_[episodeIdx].events();
652 if (episodeIdx > 0 && enableTuning_ && events.hasEvent(ScheduleEvents::TUNING_CHANGE))
654 const auto& sched_state = schedule_[episodeIdx];
655 const auto& tuning = sched_state.tuning();
656 initialTimeStepSize_ = sched_state.max_next_tstep(enableTuning_);
657 maxTimeStepAfterWellEvent_ = tuning.TMAXWC;
664template<
class Gr
idView,
class Flu
idSystem>
674 if (enableExperiments && gridView_.comm().rank() == 0 && episodeIdx >= 0) {
675 std::ostringstream ss;
676 boost::posix_time::time_facet* facet =
new boost::posix_time::time_facet(
"%d-%b-%Y");
677 boost::posix_time::ptime date = boost::posix_time::from_time_t(startTime) +
678 boost::posix_time::milliseconds(
static_cast<long long>(time / prefix::milli));
679 ss.imbue(std::locale(std::locale::classic(), facet));
680 ss <<
"\nTime step " << timeStepIndex <<
", stepsize "
681 << unit::convert::to(timeStepSize, unit::day) <<
" days,"
682 <<
" at day " << (double)unit::convert::to(time, unit::day)
683 <<
"/" << (double)unit::convert::to(endTime, unit::day)
684 <<
", date = " << date;
685 OpmLog::info(ss.str());
689template<
class Gr
idView,
class Flu
idSystem>
693 FluidSystem::initFromState(eclState_, schedule_);
696template<
class Gr
idView,
class Flu
idSystem>
701 bool enablePolymerMolarWeight,
702 bool enableBioeffects,
711 if ((enableSolvent || enablePolymer || enablePolymerMolarWeight ||
712 enableBioeffects || enableMICP) &&
713 (eclState_.getLgrs().size() > 0))
715 throw std::runtime_error(
716 "Local grid refinement (LGR/CARFIN) is only supported for black-oil "
717 "runs. It is not supported together with the solvent, polymer, "
718 "biofilm or MICP extensions.");
721 auto getArray = [](
const std::vector<double>& input)
723 if constexpr (std::is_same_v<Scalar,double>) {
726 return std::vector<Scalar>{input.begin(), input.end()};
731 if (eclState_.fieldProps().has_double(
"SSOL")) {
732 solventSaturation_ = getArray(eclState_.fieldProps().get_double(
"SSOL"));
734 solventSaturation_.resize(numDof, 0.0);
737 solventRsw_.resize(numDof, 0.0);
741 if (eclState_.fieldProps().has_double(
"SPOLY")) {
742 polymer_.concentration = getArray(eclState_.fieldProps().get_double(
"SPOLY"));
744 polymer_.concentration.resize(numDof, 0.0);
748 if (enablePolymerMolarWeight) {
749 if (eclState_.fieldProps().has_double(
"SPOLYMW")) {
750 polymer_.moleWeight = getArray(eclState_.fieldProps().get_double(
"SPOLYMW"));
752 polymer_.moleWeight.resize(numDof, 0.0);
756 if (enableBioeffects) {
757 if (eclState_.fieldProps().has_double(
"SMICR")) {
758 bioeffects_.microbialConcentration = getArray(eclState_.fieldProps().get_double(
"SMICR"));
760 bioeffects_.microbialConcentration.resize(numDof, 0.0);
762 if (eclState_.fieldProps().has_double(
"SBIOF")) {
763 bioeffects_.biofilmVolumeFraction = getArray(eclState_.fieldProps().get_double(
"SBIOF"));
765 bioeffects_.biofilmVolumeFraction.resize(numDof, 0.0);
768 if (eclState_.fieldProps().has_double(
"SOXYG")) {
769 bioeffects_.oxygenConcentration = getArray(eclState_.fieldProps().get_double(
"SOXYG"));
771 bioeffects_.oxygenConcentration.resize(numDof, 0.0);
773 if (eclState_.fieldProps().has_double(
"SUREA")) {
774 bioeffects_.ureaConcentration = getArray(eclState_.fieldProps().get_double(
"SUREA"));
776 bioeffects_.ureaConcentration.resize(numDof, 0.0);
778 if (eclState_.fieldProps().has_double(
"SCALC")) {
779 bioeffects_.calciteVolumeFraction = getArray(eclState_.fieldProps().get_double(
"SCALC"));
781 bioeffects_.calciteVolumeFraction.resize(numDof, 0.0);
787template<
class Gr
idView,
class Flu
idSystem>
792 if (maxWaterSaturation_.empty())
795 return maxWaterSaturation_[globalDofIdx];
798template<
class Gr
idView,
class Flu
idSystem>
803 if (minRefPressure_.empty())
806 return minRefPressure_[globalDofIdx];
809template<
class Gr
idView,
class Flu
idSystem>
814 if (overburdenPressure_.empty())
817 return overburdenPressure_[elementIdx];
820template<
class Gr
idView,
class Flu
idSystem>
825 if (solventSaturation_.empty())
828 return solventSaturation_[elemIdx];
831template<
class Gr
idView,
class Flu
idSystem>
836 if (solventRsw_.empty())
839 return solventRsw_[elemIdx];
844template<
class Gr
idView,
class Flu
idSystem>
849 if (polymer_.concentration.empty()) {
853 return polymer_.concentration[elemIdx];
856template<
class Gr
idView,
class Flu
idSystem>
861 if (polymer_.moleWeight.empty()) {
865 return polymer_.moleWeight[elemIdx];
868template<
class Gr
idView,
class Flu
idSystem>
873 if (bioeffects_.microbialConcentration.empty()) {
877 return bioeffects_.microbialConcentration[elemIdx];
880template<
class Gr
idView,
class Flu
idSystem>
885 if (bioeffects_.oxygenConcentration.empty()) {
889 return bioeffects_.oxygenConcentration[elemIdx];
892template<
class Gr
idView,
class Flu
idSystem>
897 if (bioeffects_.ureaConcentration.empty()) {
901 return bioeffects_.ureaConcentration[elemIdx];
904template<
class Gr
idView,
class Flu
idSystem>
909 if (bioeffects_.biofilmVolumeFraction.empty()) {
913 return bioeffects_.biofilmVolumeFraction[elemIdx];
916template<
class Gr
idView,
class Flu
idSystem>
921 if (bioeffects_.calciteVolumeFraction.empty()) {
925 return bioeffects_.calciteVolumeFraction[elemIdx];
928template<
class Gr
idView,
class Flu
idSystem>
935 return pvtnum_[elemIdx];
938template<
class Gr
idView,
class Flu
idSystem>
945 return satnum_[elemIdx];
948template<
class Gr
idView,
class Flu
idSystem>
952 if (miscnum_.empty())
955 return miscnum_[elemIdx];
958template<
class Gr
idView,
class Flu
idSystem>
962 if (plmixnum_.empty())
965 return plmixnum_[elemIdx];
968template<
class Gr
idView,
class Flu
idSystem>
973 if (polymer_.maxAdsorption.empty()) {
977 return polymer_.maxAdsorption[elemIdx];
980template<
class Gr
idView,
class Flu
idSystem>
Defines some fundamental parameters for all models.
This problem simulates an input file given in the data format used by the commercial ECLiPSE simulato...
Definition: FlowGenericProblem.hpp:62
Scalar maxPolymerAdsorption(unsigned elemIdx) const
Returns the max polymer adsorption value.
Definition: FlowGenericProblem_impl.hpp:971
unsigned pvtRegionIndex(unsigned elemIdx) const
Returns the index the relevant PVT region given a cell index.
Definition: FlowGenericProblem_impl.hpp:930
Scalar oxygenConcentration(unsigned elemIdx) const
Returns the initial oxygen concentration for a given a cell index.
Definition: FlowGenericProblem_impl.hpp:883
Scalar microbialConcentration(unsigned elemIdx) const
Returns the initial microbial concentration for a given a cell index.
Definition: FlowGenericProblem_impl.hpp:871
PolymerSolutionContainer< Scalar > polymer_
Definition: FlowGenericProblem.hpp:389
Scalar rockBiotTemp(unsigned elementIdx) const
Returns the rock compressibility of an element due to thermoelasticity.
Definition: FlowGenericProblem_impl.hpp:428
static std::string briefDescription()
Returns a human readable description of the problem for the help message.
Definition: FlowGenericProblem_impl.hpp:149
Scalar solventRsw(unsigned elemIdx) const
Returns the initial solvent dissolved in water for a given a cell index.
Definition: FlowGenericProblem_impl.hpp:834
Scalar overburdenPressure(unsigned elementIdx) const
Get the pressure of the overburden.
Definition: FlowGenericProblem_impl.hpp:812
void updateMiscnum_()
Definition: FlowGenericProblem_impl.hpp:605
Scalar porosity(unsigned globalSpaceIdx, unsigned timeIdx) const
Direct indexed access to the porosity.
Definition: FlowGenericProblem_impl.hpp:409
Scalar rockCompressibility(unsigned globalSpaceIdx) const
Definition: FlowGenericProblem_impl.hpp:394
Scalar initialTimeStepSize_
Definition: FlowGenericProblem.hpp:401
unsigned miscnumRegionIndex(unsigned elemIdx) const
Returns the index the relevant MISC region given a cell index.
Definition: FlowGenericProblem_impl.hpp:950
bool vapparsActive(int episodeIdx) const
Definition: FlowGenericProblem_impl.hpp:621
unsigned satnumRegionIndex(unsigned elemIdx) const
Returns the index the relevant saturation function region given a cell index.
Definition: FlowGenericProblem_impl.hpp:940
Scalar maxWaterSaturation(unsigned globalDofIdx) const
Returns an element's historic maximum water phase saturation that was observed during the simulation.
Definition: FlowGenericProblem_impl.hpp:790
std::vector< Scalar > solventSaturation_
Definition: FlowGenericProblem.hpp:394
void readRockCompactionParameters_()
Definition: FlowGenericProblem_impl.hpp:246
void updateSatnum_()
Definition: FlowGenericProblem_impl.hpp:597
void updatePvtnum_()
Definition: FlowGenericProblem_impl.hpp:589
bool enableDriftCompensation_
Definition: FlowGenericProblem.hpp:407
Scalar lame(unsigned elementIdx) const
Direct access to Lame's second parameter in an element.
Definition: FlowGenericProblem_impl.hpp:440
static FlowGenericProblem serializationTestObject(const EclipseState &eclState, const Schedule &schedule, const GridView &gridView)
Definition: FlowGenericProblem_impl.hpp:113
void beginTimeStep_(bool enableExperiments, int episodeIdx, int timeStepIndex, Scalar startTime, Scalar time, Scalar timeStepSize, Scalar endTime)
Definition: FlowGenericProblem_impl.hpp:666
Scalar calciteVolumeFraction(unsigned elemIdx) const
Returns the initial calcite volume fraction for a given a cell index.
Definition: FlowGenericProblem_impl.hpp:919
CO2H2SolutionContainer< Scalar > CO2H2_
Definition: FlowGenericProblem.hpp:397
unsigned plmixnumRegionIndex(unsigned elemIdx) const
Returns the index the relevant PLMIXNUM (for polymer module) region given a cell index.
Definition: FlowGenericProblem_impl.hpp:960
FlowGenericProblem(const EclipseState &eclState, const Schedule &schedule, const GridView &gridView)
Definition: FlowGenericProblem_impl.hpp:63
BioeffectsSolutionContainer< Scalar > bioeffects_
Definition: FlowGenericProblem.hpp:396
bool enableTuning_
Definition: FlowGenericProblem.hpp:400
Scalar solventSaturation(unsigned elemIdx) const
Returns the initial solvent saturation for a given a cell index.
Definition: FlowGenericProblem_impl.hpp:823
Scalar polymerMolecularWeight(const unsigned elemIdx) const
Returns the polymer molecule weight for a given cell index.
Definition: FlowGenericProblem_impl.hpp:859
void readRockParameters_(const std::vector< Scalar > &cellCenterDepths, std::function< std::array< int, 3 >(const unsigned)> ijkIndex)
Definition: FlowGenericProblem_impl.hpp:156
UniformXTabulated2DFunctionBuilder< Scalar > TabulatedTwoDFunctionBuilder
Definition: FlowGenericProblem.hpp:66
std::vector< Scalar > maxOilSaturation_
Definition: FlowGenericProblem.hpp:390
Scalar rockBiotComp(unsigned elementIdx) const
Returns the rock compressibility of an element due to poroelasticity.
Definition: FlowGenericProblem_impl.hpp:417
int numPressurePointsEquil_
Definition: FlowGenericProblem.hpp:405
Scalar minOilPressure(unsigned globalDofIdx) const
Returns an element's historic minimum pressure of the oil phase that was observed during the simulati...
Definition: FlowGenericProblem_impl.hpp:801
std::vector< Scalar > maxWaterSaturation_
Definition: FlowGenericProblem.hpp:391
void initFluidSystem_()
Definition: FlowGenericProblem_impl.hpp:691
bool operator==(const FlowGenericProblem &rhs) const
Definition: FlowGenericProblem_impl.hpp:982
Scalar maxTimeStepAfterWellEvent_
Definition: FlowGenericProblem.hpp:402
Scalar ureaConcentration(unsigned elemIdx) const
Returns the initial urea concentration for a given a cell index.
Definition: FlowGenericProblem_impl.hpp:895
std::vector< Scalar > minRefPressure_
Definition: FlowGenericProblem.hpp:392
bool beginEpisode_(bool enableExperiments, int episodeIdx)
Definition: FlowGenericProblem_impl.hpp:629
Scalar biofilmVolumeFraction(unsigned elemIdx) const
Returns the initial biofilm volume fraction for a given a cell index.
Definition: FlowGenericProblem_impl.hpp:907
std::vector< Scalar > solventRsw_
Definition: FlowGenericProblem.hpp:395
static std::string helpPreamble(int, const char **argv)
Returns the string that is printed before the list of command line parameters in the help message.
Definition: FlowGenericProblem_impl.hpp:134
std::vector< Scalar > overburdenPressure_
Definition: FlowGenericProblem.hpp:393
void readBlackoilExtentionsInitialConditions_(std::size_t numDof, bool enableSolvent, bool enablePolymer, bool enablePolymerMolarWeight, bool enableBioeffects, bool enableMICP)
Definition: FlowGenericProblem_impl.hpp:698
Scalar biotTemp(unsigned elementIdx) const
Direct access to Biot temperature coefficient in an element.
Definition: FlowGenericProblem_impl.hpp:492
Scalar biotCoeff(unsigned elementIdx) const
Direct access to Biot coefficient in an element.
Definition: FlowGenericProblem_impl.hpp:471
void updatePlmixnum_()
Definition: FlowGenericProblem_impl.hpp:613
bool explicitRockCompaction_
Definition: FlowGenericProblem.hpp:409
typename FluidSystem::Scalar Scalar
Definition: FlowGenericProblem.hpp:64
void updateNum(const std::string &name, std::vector< T > &numbers, std::size_t num_regions)
Read a region keyword as zero-based indices, checked against num_regions.
Definition: FlowGenericProblem_impl.hpp:568
Scalar polymerConcentration(unsigned elemIdx) const
Returns the initial polymer concentration for a given a cell index.
Definition: FlowGenericProblem_impl.hpp:847
Declare the properties used by the infrastructure code of the finite volume discretizations.
auto Get(bool errorIfNotRegistered=true)
Retrieve a runtime parameter.
Definition: parametersystem.hpp:198
Definition: blackoilbioeffectsmodules.hh:45
std::string to_string(const ConvergenceReport::ReservoirFailure::Type t)
This file provides the infrastructure to retrieve run-time parameters.
static BioeffectsSolutionContainer serializationTestObject()
static CO2H2SolutionContainer serializationTestObject()
Definition: FlowGenericProblem.hpp:69
Definition: EclTimeSteppingParams.hpp:49
static PolymerSolutionContainer serializationTestObject()