240 throw std::runtime_error(
"Not support ROCKOMP hysteresis option ");
243 std::size_t numRocktabTables = rock_config.num_rock_tables();
244 bool waterCompaction = rock_config.water_compaction();
246 if (!waterCompaction) {
247 const auto& rocktabTables = eclState_.getTableManager().getRocktabTables();
248 if (rocktabTables.size() != numRocktabTables)
249 throw std::runtime_error(
"ROCKCOMP is activated." + std::to_string(numRocktabTables)
250 +
" ROCKTAB tables is expected, but " + std::to_string(rocktabTables.size()) +
" is provided");
252 rockCompPoroMult_.resize(numRocktabTables);
253 rockCompTransMult_.resize(numRocktabTables);
254 for (std::size_t regionIdx = 0; regionIdx < numRocktabTables; ++regionIdx) {
255 const auto& rocktabTable = rocktabTables.template getTable<RocktabTable>(regionIdx);
256 const auto& pressureColumn = rocktabTable.getPressureColumn();
257 const auto& poroColumn = rocktabTable.getPoreVolumeMultiplierColumn();
258 const auto& transColumn = rocktabTable.getTransmissibilityMultiplierColumn();
259 rockCompPoroMult_[regionIdx].setXYContainers(pressureColumn, poroColumn);
260 rockCompTransMult_[regionIdx].setXYContainers(pressureColumn, transColumn);
263 const auto& rock2dTables = eclState_.getTableManager().getRock2dTables();
264 const auto& rock2dtrTables = eclState_.getTableManager().getRock2dtrTables();
265 const auto& rockwnodTables = eclState_.getTableManager().getRockwnodTables();
266 maxWaterSaturation_.resize(numElem, 0.0);
268 if (rock2dTables.size() != numRocktabTables)
269 throw std::runtime_error(
"Water compation option is selected in ROCKCOMP." + std::to_string(numRocktabTables)
270 +
" ROCK2D tables is expected, but " + std::to_string(rock2dTables.size()) +
" is provided");
272 if (rockwnodTables.size() != numRocktabTables)
273 throw std::runtime_error(
"Water compation option is selected in ROCKCOMP." + std::to_string(numRocktabTables)
274 +
" ROCKWNOD tables is expected, but " + std::to_string(rockwnodTables.size()) +
" is provided");
276 rockCompPoroMultWc_.resize(numRocktabTables, TabulatedTwoDFunction(TabulatedTwoDFunction::InterpolationPolicy::Vertical));
277 for (std::size_t regionIdx = 0; regionIdx < numRocktabTables; ++regionIdx) {
278 const RockwnodTable& rockwnodTable = rockwnodTables.template getTable<RockwnodTable>(regionIdx);
279 const auto& rock2dTable = rock2dTables[regionIdx];
281 if (rockwnodTable.getSaturationColumn().size() != rock2dTable.sizeMultValues())
282 throw std::runtime_error(
"Number of entries in ROCKWNOD and ROCK2D needs to match.");
284 for (std::size_t xIdx = 0; xIdx < rock2dTable.size(); ++xIdx) {
285 rockCompPoroMultWc_[regionIdx].appendXPos(rock2dTable.getPressureValue(xIdx));
286 for (std::size_t yIdx = 0; yIdx < rockwnodTable.getSaturationColumn().size(); ++yIdx)
287 rockCompPoroMultWc_[regionIdx].appendSamplePoint(xIdx,
288 rockwnodTable.getSaturationColumn()[yIdx],
289 rock2dTable.getPvmultValue(xIdx, yIdx));
293 if (!rock2dtrTables.empty()) {
294 rockCompTransMultWc_.resize(numRocktabTables, TabulatedTwoDFunction(TabulatedTwoDFunction::InterpolationPolicy::Vertical));
295 for (std::size_t regionIdx = 0; regionIdx < numRocktabTables; ++regionIdx) {
296 const RockwnodTable& rockwnodTable = rockwnodTables.template getTable<RockwnodTable>(regionIdx);
297 const auto& rock2dtrTable = rock2dtrTables[regionIdx];
299 if (rockwnodTable.getSaturationColumn().size() != rock2dtrTable.sizeMultValues())
300 throw std::runtime_error(
"Number of entries in ROCKWNOD and ROCK2DTR needs to match.");
302 for (std::size_t xIdx = 0; xIdx < rock2dtrTable.size(); ++xIdx) {
303 rockCompTransMultWc_[regionIdx].appendXPos(rock2dtrTable.getPressureValue(xIdx));
304 for (std::size_t yIdx = 0; yIdx < rockwnodTable.getSaturationColumn().size(); ++yIdx)
305 rockCompTransMultWc_[regionIdx].appendSamplePoint(xIdx,
306 rockwnodTable.getSaturationColumn()[yIdx],
307 rock2dtrTable.getTransMultValue(xIdx, yIdx));
314template<
class Gr
idView,
class Flu
idSystem>
315typename FlowGenericProblem<GridView,FluidSystem>::Scalar
319 if (this->rockParams_.empty())
322 unsigned tableIdx = 0;
323 if (!this->rockTableIdx_.empty()) {
324 tableIdx = this->rockTableIdx_[globalSpaceIdx];
326 return this->rockParams_[tableIdx].compressibility;
329template<
class Gr
idView,
class Flu
idSystem>
330typename FlowGenericProblem<GridView,FluidSystem>::Scalar
332porosity(
unsigned globalSpaceIdx,
unsigned timeIdx)
const
334 return this->referencePorosity_[timeIdx][globalSpaceIdx];
337template<
class Gr
idView,
class Flu
idSystem>
338typename FlowGenericProblem<GridView,FluidSystem>::Scalar
340rockFraction(
unsigned elementIdx,
unsigned timeIdx)
const
346 auto porosity = this->lookUpData_.fieldPropDouble(eclState_.fieldProps(),
"PORO", elementIdx);
347 return referencePorosity(elementIdx, timeIdx) / porosity * (1 - porosity);
350template<
class Gr
idView,
class Flu
idSystem>
353updateNum(
const std::string& name, std::vector<T>& numbers, std::size_t num_regions)
355 if (!eclState_.fieldProps().has_int(name))
358 std::function<void(T,
int)> valueCheck = [num_regions,name](T fieldPropValue, [[maybe_unused]]
int fieldPropIdx) {
359 if ( fieldPropValue > (
int)num_regions) {
360 throw std::runtime_error(
"Values larger than maximum number of regions "
361 + std::to_string(num_regions) +
" provided in " + name);
363 if ( fieldPropValue <= 0) {
364 throw std::runtime_error(
"zero or negative values provided for region array: " + name);
368 numbers = this->lookUpData_.template assignFieldPropsIntOnLeaf<T>(eclState_.fieldProps(), name,
372template<
class Gr
idView,
class Flu
idSystem>
373void FlowGenericProblem<GridView,FluidSystem>::
376 const auto num_regions = eclState_.getTableManager().getTabdims().getNumPVTTables();
377 updateNum(
"PVTNUM", pvtnum_, num_regions);
380template<
class Gr
idView,
class Flu
idSystem>
381void FlowGenericProblem<GridView,FluidSystem>::
384 const auto num_regions = eclState_.getTableManager().getTabdims().getNumSatTables();
385 updateNum(
"SATNUM", satnum_, num_regions);
388template<
class Gr
idView,
class Flu
idSystem>
389void FlowGenericProblem<GridView,FluidSystem>::
392 const auto num_regions = 1;
393 updateNum(
"MISCNUM", miscnum_, num_regions);
396template<
class Gr
idView,
class Flu
idSystem>
397void FlowGenericProblem<GridView,FluidSystem>::
400 const auto num_regions = 1;
401 updateNum(
"PLMIXNUM", plmixnum_, num_regions);
404template<
class Gr
idView,
class Flu
idSystem>
405bool FlowGenericProblem<GridView,FluidSystem>::
406vapparsActive(
int episodeIdx)
const
408 const auto& oilVaporizationControl = schedule_[episodeIdx].oilvap();
409 return (oilVaporizationControl.getType() == OilVaporizationProperties::OilVaporization::VAPPARS);
412template<
class Gr
idView,
class Flu
idSystem>
413bool FlowGenericProblem<GridView,FluidSystem>::
414beginEpisode_(
bool enableExperiments,
417 if (enableExperiments && gridView_.comm().rank() == 0 && episodeIdx >= 0) {
420 std::ostringstream ss;
421 boost::posix_time::time_facet* facet =
new boost::posix_time::time_facet(
"%d-%b-%Y");
422 boost::posix_time::ptime curDateTime =
423 boost::posix_time::from_time_t(schedule_.simTime(episodeIdx));
424 ss.imbue(std::locale(std::locale::classic(), facet));
425 ss <<
"Report step " << episodeIdx + 1
426 <<
"/" << schedule_.size() - 1
427 <<
" at day " << schedule_.seconds(episodeIdx)/(24*3600)
428 <<
"/" << schedule_.seconds(schedule_.size() - 1)/(24*3600)
429 <<
", date = " << curDateTime.date()
431 OpmLog::info(ss.str());
434 const auto& events = schedule_[episodeIdx].events();
437 if (episodeIdx > 0 && enableTuning_ && events.hasEvent(ScheduleEvents::TUNING_CHANGE))
439 const auto& sched_state = schedule_[episodeIdx];
440 const auto& tuning = sched_state.tuning();
441 initialTimeStepSize_ = sched_state.max_next_tstep(enableTuning_);
442 maxTimeStepAfterWellEvent_ = tuning.TMAXWC;
449template<
class Gr
idView,
class Flu
idSystem>
450void FlowGenericProblem<GridView,FluidSystem>::
451beginTimeStep_(
bool enableExperiments,
459 if (enableExperiments && gridView_.comm().rank() == 0 && episodeIdx >= 0) {
460 std::ostringstream ss;
461 boost::posix_time::time_facet* facet =
new boost::posix_time::time_facet(
"%d-%b-%Y");
462 boost::posix_time::ptime date = boost::posix_time::from_time_t(startTime) + boost::posix_time::milliseconds(
static_cast<long long>(time / prefix::milli));
463 ss.imbue(std::locale(std::locale::classic(), facet));
464 ss <<
"\nTime step " << timeStepIndex <<
", stepsize "
465 << unit::convert::to(timeStepSize, unit::day) <<
" days,"
466 <<
" at day " << (double)unit::convert::to(time, unit::day)
467 <<
"/" << (double)unit::convert::to(endTime, unit::day)
468 <<
", date = " << date;
469 OpmLog::info(ss.str());
473template<
class Gr
idView,
class Flu
idSystem>
474void FlowGenericProblem<GridView,FluidSystem>::
477 FluidSystem::initFromState(eclState_, schedule_);
480template<
class Gr
idView,
class Flu
idSystem>
481void FlowGenericProblem<GridView,FluidSystem>::
482readBlackoilExtentionsInitialConditions_(std::size_t numDof,
485 bool enablePolymerMolarWeight,
486 bool enableBioeffects,
489 auto getArray = [](
const std::vector<double>& input)
491 if constexpr (std::is_same_v<Scalar,double>) {
494 return std::vector<Scalar>{input.begin(), input.end()};
499 if (eclState_.fieldProps().has_double(
"SSOL")) {
500 solventSaturation_ = getArray(eclState_.fieldProps().get_double(
"SSOL"));
502 solventSaturation_.resize(numDof, 0.0);
505 solventRsw_.resize(numDof, 0.0);
509 if (eclState_.fieldProps().has_double(
"SPOLY")) {
510 polymer_.concentration = getArray(eclState_.fieldProps().get_double(
"SPOLY"));
512 polymer_.concentration.resize(numDof, 0.0);
516 if (enablePolymerMolarWeight) {
517 if (eclState_.fieldProps().has_double(
"SPOLYMW")) {
518 polymer_.moleWeight = getArray(eclState_.fieldProps().get_double(
"SPOLYMW"));
520 polymer_.moleWeight.resize(numDof, 0.0);
524 if (enableBioeffects) {
525 if (eclState_.fieldProps().has_double(
"SMICR")) {
526 bioeffects_.microbialConcentration = getArray(eclState_.fieldProps().get_double(
"SMICR"));
528 bioeffects_.microbialConcentration.resize(numDof, 0.0);
530 if (eclState_.fieldProps().has_double(
"SBIOF")) {
531 bioeffects_.biofilmVolumeFraction = getArray(eclState_.fieldProps().get_double(
"SBIOF"));
533 bioeffects_.biofilmVolumeFraction.resize(numDof, 0.0);
536 if (eclState_.fieldProps().has_double(
"SOXYG")) {
537 bioeffects_.oxygenConcentration = getArray(eclState_.fieldProps().get_double(
"SOXYG"));
539 bioeffects_.oxygenConcentration.resize(numDof, 0.0);
541 if (eclState_.fieldProps().has_double(
"SUREA")) {
542 bioeffects_.ureaConcentration = getArray(eclState_.fieldProps().get_double(
"SUREA"));
544 bioeffects_.ureaConcentration.resize(numDof, 0.0);
546 if (eclState_.fieldProps().has_double(
"SCALC")) {
547 bioeffects_.calciteVolumeFraction = getArray(eclState_.fieldProps().get_double(
"SCALC"));
549 bioeffects_.calciteVolumeFraction.resize(numDof, 0.0);
555template<
class Gr
idView,
class Flu
idSystem>
556typename FlowGenericProblem<GridView,FluidSystem>::Scalar
560 if (maxWaterSaturation_.empty())
563 return maxWaterSaturation_[globalDofIdx];
566template<
class Gr
idView,
class Flu
idSystem>
567typename FlowGenericProblem<GridView,FluidSystem>::Scalar
571 if (minRefPressure_.empty())
574 return minRefPressure_[globalDofIdx];
577template<
class Gr
idView,
class Flu
idSystem>
578typename FlowGenericProblem<GridView,FluidSystem>::Scalar
582 if (overburdenPressure_.empty())
585 return overburdenPressure_[elementIdx];
588template<
class Gr
idView,
class Flu
idSystem>
589typename FlowGenericProblem<GridView,FluidSystem>::Scalar
593 if (solventSaturation_.empty())
596 return solventSaturation_[elemIdx];
599template<
class Gr
idView,
class Flu
idSystem>
600typename FlowGenericProblem<GridView,FluidSystem>::Scalar
604 if (solventRsw_.empty())
607 return solventRsw_[elemIdx];
612template<
class Gr
idView,
class Flu
idSystem>
613typename FlowGenericProblem<GridView,FluidSystem>::Scalar
617 if (polymer_.concentration.empty()) {
621 return polymer_.concentration[elemIdx];
624template<
class Gr
idView,
class Flu
idSystem>
625typename FlowGenericProblem<GridView,FluidSystem>::Scalar
629 if (polymer_.moleWeight.empty()) {
633 return polymer_.moleWeight[elemIdx];
636template<
class Gr
idView,
class Flu
idSystem>
637typename FlowGenericProblem<GridView,FluidSystem>::Scalar
641 if (bioeffects_.microbialConcentration.empty()) {
648template<
class Gr
idView,
class Flu
idSystem>
649typename FlowGenericProblem<GridView,FluidSystem>::Scalar
653 if (bioeffects_.oxygenConcentration.empty()) {
660template<
class Gr
idView,
class Flu
idSystem>
661typename FlowGenericProblem<GridView,FluidSystem>::Scalar
665 if (bioeffects_.ureaConcentration.empty()) {
672template<
class Gr
idView,
class Flu
idSystem>
673typename FlowGenericProblem<GridView,FluidSystem>::Scalar
677 if (bioeffects_.biofilmVolumeFraction.empty()) {
684template<
class Gr
idView,
class Flu
idSystem>
685typename FlowGenericProblem<GridView,FluidSystem>::Scalar
689 if (bioeffects_.calciteVolumeFraction.empty()) {
696template<
class Gr
idView,
class Flu
idSystem>
703 return pvtnum_[elemIdx];
706template<
class Gr
idView,
class Flu
idSystem>
713 return satnum_[elemIdx];
716template<
class Gr
idView,
class Flu
idSystem>
720 if (miscnum_.empty())
723 return miscnum_[elemIdx];
726template<
class Gr
idView,
class Flu
idSystem>
730 if (plmixnum_.empty())
733 return plmixnum_[elemIdx];
736template<
class Gr
idView,
class Flu
idSystem>
737typename FlowGenericProblem<GridView,FluidSystem>::Scalar
741 if (polymer_.maxAdsorption.empty()) {
745 return polymer_.maxAdsorption[elemIdx];
748template<
class Gr
idView,
class Flu
idSystem>
752 return this->maxWaterSaturation_ == rhs.maxWaterSaturation_ &&
753 this->minRefPressure_ == rhs.minRefPressure_ &&
754 this->overburdenPressure_ == rhs.overburdenPressure_ &&
755 this->solventSaturation_ == rhs.solventSaturation_ &&
756 this->solventRsw_ == rhs.solventRsw_ &&
757 this->polymer_ == rhs.polymer_ &&
758 this->bioeffects_ == rhs.bioeffects_;