From b9068ff2a3e9c2f1596b16d9d5547b0aec6ee5e1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?B=C3=A5rd=20Skaflestad?= Date: Mon, 16 Dec 2024 11:58:19 +0100 Subject: [PATCH] Make Sources Buildable on Current Master Not all 'problem's have a geomechanical model, so limit block level stress collection to those that do. While here, also install more headers to enable downstream/out-of-tree users of the main simulator classes. Finally, reduce scope of some objects and be (more) 'const' correct. --- CMakeLists_files.cmake | 47 ++++++++++- .../blackoil/blackoilintensivequantities.hh | 2 - opm/simulators/flow/OutputBlackoilModule.hpp | 66 ++++++++------- .../wells/BlackoilWellModel_impl.hpp | 81 ++++++++++++------- 4 files changed, 126 insertions(+), 70 deletions(-) diff --git a/CMakeLists_files.cmake b/CMakeLists_files.cmake index e3ece638bb1..3884cbf6657 100644 --- a/CMakeLists_files.cmake +++ b/CMakeLists_files.cmake @@ -573,9 +573,40 @@ list (APPEND TEST_DATA_FILES # originally generated with the command: # find opm -name '*.h*' -a ! -name '*-pch.hpp' -printf '\t%p\n' | sort list (APPEND PUBLIC_HEADER_FILES + flow/flow_blackoil.hpp + flow/flow_blackoil_legacyassembly.hpp + flow/flow_brine.hpp + flow/flow_brine_precsalt_vapwat.hpp + flow/flow_brine_saltprecipitation.hpp + flow/flow_energy.hpp + flow/flow_extbo.hpp + flow/flow_foam.hpp + flow/flow_gasoil.hpp + flow/flow_gasoil_energy.hpp + flow/flow_gasoildiffuse.hpp + flow/flow_gaswater.hpp + flow/flow_gaswater_brine.hpp + flow/flow_gaswater_dissolution.hpp + flow/flow_gaswater_dissolution_diffuse.hpp + flow/flow_gaswater_energy.hpp + flow/flow_gaswater_saltprec_energy.hpp + flow/flow_gaswater_saltprec_vapwat.hpp + flow/flow_gaswater_solvent.hpp + flow/flow_micp.hpp + flow/flow_oilwater.hpp + flow/flow_oilwater_brine.hpp + flow/flow_oilwater_polymer.hpp + flow/flow_oilwater_polymer_injectivity.hpp + flow/flow_onephase.hpp + flow/flow_onephase_energy.hpp + flow/flow_polymer.hpp + flow/flow_solvent.hpp + flow/flow_solvent_foam.hpp + opm/models/blackoil/blackoilboundaryratevector.hh opm/models/blackoil/blackoilbrinemodules.hh opm/models/blackoil/blackoilbrineparams.hpp + opm/models/blackoil/blackoilconvectivemixingmodule.hh opm/models/blackoil/blackoildarcyfluxmodule.hh opm/models/blackoil/blackoildiffusionmodule.hh opm/models/blackoil/blackoildispersionmodule.hh @@ -904,6 +935,7 @@ list (APPEND PUBLIC_HEADER_FILES opm/simulators/linalg/overlaptypes.hh opm/simulators/linalg/OwningBlockPreconditioner.hpp opm/simulators/linalg/OwningTwoLevelPreconditioner.hpp + opm/simulators/linalg/MILU.hpp opm/simulators/linalg/parallelamgbackend.hh opm/simulators/linalg/parallelbasebackend.hh opm/simulators/linalg/parallelbicgstabbackend.hh @@ -911,10 +943,13 @@ list (APPEND PUBLIC_HEADER_FILES opm/simulators/linalg/ParallelIstlInformation.hpp opm/simulators/linalg/ParallelOverlappingILU0.hpp opm/simulators/linalg/ParallelRestrictedAdditiveSchwarz.hpp - opm/simulators/linalg/PressureSolverPolicy.hpp - opm/simulators/linalg/PressureTransferPolicy.hpp + opm/simulators/linalg/PreconditionerFactoryGPUIncludeWrapper.hpp opm/simulators/linalg/PreconditionerFactory.hpp + opm/simulators/linalg/PreconditionerFactory_impl.hpp opm/simulators/linalg/PreconditionerWithUpdate.hpp + opm/simulators/linalg/PressureBhpTransferPolicy.hpp + opm/simulators/linalg/PressureSolverPolicy.hpp + opm/simulators/linalg/PressureTransferPolicy.hpp opm/simulators/linalg/PropertyTree.hpp opm/simulators/linalg/residreductioncriterion.hh opm/simulators/linalg/SmallDenseMatrixUtils.hpp @@ -951,6 +986,8 @@ list (APPEND PUBLIC_HEADER_FILES opm/simulators/utils/gatherDeferredLogger.hpp opm/simulators/utils/moduleVersion.hpp opm/simulators/utils/phaseUsageFromDeck.hpp + opm/simulators/utils/ParallelCommunication.hpp + opm/simulators/utils/ParallelSerialization.hpp opm/simulators/utils/readDeck.hpp opm/simulators/utils/satfunc/RelpermDiagnostics.hpp opm/simulators/wells/ALQState.hpp @@ -1013,14 +1050,16 @@ list (APPEND PUBLIC_HEADER_FILES opm/simulators/wells/WellGroupControls.hpp opm/simulators/wells/WellGroupHelpers.hpp opm/simulators/wells/WellHelpers.hpp - opm/simulators/wells/WellInterface.hpp + opm/simulators/wells/WellInterfaceFluidSystem.hpp opm/simulators/wells/WellInterfaceGeneric.hpp + opm/simulators/wells/WellInterface.hpp opm/simulators/wells/WellInterface_impl.hpp + opm/simulators/wells/WellInterfaceIndices.hpp opm/simulators/wells/WellProdIndexCalculator.hpp opm/simulators/wells/WellState.hpp opm/simulators/wells/WellTest.hpp opm/simulators/wells/WGState.hpp - ) +) if (USE_GPU_BRIDGE) list (APPEND PUBLIC_HEADER_FILES opm/simulators/linalg/gpubridge/amgclSolverBackend.hpp diff --git a/opm/models/blackoil/blackoilintensivequantities.hh b/opm/models/blackoil/blackoilintensivequantities.hh index 2de7bea2893..ea129abb717 100644 --- a/opm/models/blackoil/blackoilintensivequantities.hh +++ b/opm/models/blackoil/blackoilintensivequantities.hh @@ -56,8 +56,6 @@ #include #include -#include - namespace Opm { /*! * \ingroup BlackOilModel diff --git a/opm/simulators/flow/OutputBlackoilModule.hpp b/opm/simulators/flow/OutputBlackoilModule.hpp index ccc0203340d..52e7e6ef9e4 100644 --- a/opm/simulators/flow/OutputBlackoilModule.hpp +++ b/opm/simulators/flow/OutputBlackoilModule.hpp @@ -844,6 +844,7 @@ class OutputBlackOilModule : public GenericOutputBlackoilModule>::value) { + const auto stress = problem.geoMechModel() + .stress(globalDofIdx, /*include_fracture*/ true); + + if (key.first == "BSTRSSXX") { val.second = stress[0]; } + else if (key.first == "BSTRSSYY") { val.second = stress[1]; } + else if (key.first == "BSTRSSZZ") { val.second = stress[2]; } + else if (key.first == "BSTRSSXY") { val.second = stress[5]; } + else if (key.first == "BSTRSSXZ") { val.second = stress[4]; } + else { val.second = stress[3]; } } - else if (key.first == "BSTRSSYZ") - { - const auto& model = problem.geoMechModel(); - auto stress = model.stress(globalDofIdx,/*include_fracture*/true); - val.second = stress[3]; + else { + val.second = 0.0; } + } else if (key.first == "BWKR" || key.first == "BKRW") val.second = getValue(intQuants.relativePermeability(waterPhaseIdx)); else if (key.first == "BGKR" || key.first == "BKRG") @@ -1311,6 +1298,17 @@ class OutputBlackOilModule : public GenericOutputBlackoilModule + using RemoveCVR = std::remove_cv_t>; + + template + struct HasGeoMech : public std::false_type {}; + + template + struct HasGeoMech< + Problem, std::void_t().geoMechModel())> + > : public std::true_type {}; + bool isDefunctParallelWell(std::string wname) const override { if (simulator_.gridView().comm().size() == 1) diff --git a/opm/simulators/wells/BlackoilWellModel_impl.hpp b/opm/simulators/wells/BlackoilWellModel_impl.hpp index db8b06a4847..9e9404098dd 100644 --- a/opm/simulators/wells/BlackoilWellModel_impl.hpp +++ b/opm/simulators/wells/BlackoilWellModel_impl.hpp @@ -726,34 +726,44 @@ namespace Opm { { this->closed_this_step_.clear(); - // time step is finished and we are not any more at the beginning of an report step + // Time step ends and we are no longer at the beginning of a report + // step. this->report_step_starts_ = false; - const int reportStepIdx = simulator_.episodeIndex(); + const int reportStepIdx = this->simulator_.episodeIndex(); - DeferredLogger local_deferredLogger; - for (const auto& well : well_container_) { - if (getPropValue() && well->isInjector()) { - well->updateWaterThroughput(dt, this->wellState()); + if (getPropValue()) { + for (auto& wellPtr : this->well_container_) { + if (wellPtr->isInjector()) { + wellPtr->updateWaterThroughput(dt, this->wellState()); + } } } - // update connection transmissibility factor and d factor (if applicable) in the wellstate - for (const auto& well : well_container_) { - well->updateConnectionTransmissibilityFactor(simulator_, this->wellState().well(well->indexOfWell())); - well->updateConnectionDFactor(simulator_, this->wellState().well(well->indexOfWell())); + + // Update connection transmissibility factor and d factor (if + // applicable) in the wellstate. + for (auto& wellPtr : this->well_container_) { + auto& ws = this->wellState().well(wellPtr->indexOfWell()); + + wellPtr->updateConnectionTransmissibilityFactor(this->simulator_, ws); + wellPtr->updateConnectionDFactor(this->simulator_, ws); } + DeferredLogger local_deferredLogger{}; if (Indices::waterEnabled) { this->updateFiltrationModelsPostStep(dt, FluidSystem::waterPhaseIdx, local_deferredLogger); } - // WINJMULT: At the end of the time step, update the inj_multiplier saved in WellState for later use + // WINJMULT: At the end of the time step, update the inj_multiplier + // saved in WellState for later use. this->updateInjMult(local_deferredLogger); - // report well switching - for (const auto& well : well_container_) { - well->reportWellSwitching(this->wellState().well(well->indexOfWell()), local_deferredLogger); + // Report well switching. + for (auto& wellPtr : this->well_container_) { + wellPtr->reportWellSwitching(this->wellState().well(wellPtr->indexOfWell()), + local_deferredLogger); } - // report group switching + + // Report group switching. if (this->terminal_output_) { for (const auto& [name, ctrls] : this->switched_prod_groups_) { @@ -793,40 +803,51 @@ namespace Opm { } } - // update the rate converter with current averages pressures etc in - rateConverter_->template defineState(simulator_); + // Update the rate converter with current averages pressures etc in. + this->rateConverter_->template defineState(simulator_); - // calculate the well potentials + // Calculate the well potentials. try { this->updateWellPotentials(reportStepIdx, - /*onlyAfterEvent*/false, + /* onlyAfterEvent = */ false, simulator_.vanguard().summaryConfig(), local_deferredLogger); - } catch ( std::runtime_error& e ) { + } + catch (const std::runtime_error& e) { const std::string msg = "A zero well potential is returned for output purposes. "; local_deferredLogger.warning("WELL_POTENTIAL_CALCULATION_FAILED", msg); } updateWellTestState(simulationTime, this->wellTestState()); - // check group sales limits at the end of the timestep - const Group& fieldGroup = this->schedule_.getGroup("FIELD", reportStepIdx); - this->checkGEconLimits(fieldGroup, simulationTime, - simulator_.episodeIndex(), local_deferredLogger); - this->checkGconsaleLimits(fieldGroup, this->wellState(), - simulator_.episodeIndex(), local_deferredLogger); + // Check group sales limits at the end of the timestep. + { + const Group& fieldGroup = this->schedule_ + .getGroup("FIELD", reportStepIdx); + + this->checkGEconLimits(fieldGroup, + simulationTime, + reportStepIdx, + local_deferredLogger); + + this->checkGconsaleLimits(fieldGroup, + this->wellState(), + reportStepIdx, + local_deferredLogger); + } this->calculateProductivityIndexValues(local_deferredLogger); this->commitWGState(); - const Opm::Parallel::Communication& comm = grid().comm(); - DeferredLogger global_deferredLogger = gatherDeferredLogger(local_deferredLogger, comm); - if (this->terminal_output_) { + if (auto global_deferredLogger = + gatherDeferredLogger(local_deferredLogger, grid().comm()); + this->terminal_output_) + { global_deferredLogger.logMessages(); } - //reporting output temperatures + // Reporting output temperatures. this->computeWellTemperature(); }