Skip to content

Commit

Permalink
Make Sources Buildable on Current Master
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
bska committed Dec 17, 2024
1 parent daea2da commit 53656d0
Show file tree
Hide file tree
Showing 4 changed files with 126 additions and 70 deletions.
47 changes: 43 additions & 4 deletions CMakeLists_files.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -904,17 +935,21 @@ 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
opm/simulators/linalg/parallelistlbackend.hh
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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
2 changes: 0 additions & 2 deletions opm/models/blackoil/blackoilintensivequantities.hh
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,6 @@
#include <cstring>
#include <utility>

#include <fmt/format.h>

namespace Opm {
/*!
* \ingroup BlackOilModel
Expand Down
66 changes: 32 additions & 34 deletions opm/simulators/flow/OutputBlackoilModule.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -844,6 +844,7 @@ class OutputBlackOilModule : public GenericOutputBlackoilModule<GetPropType<Type
return;

const auto& problem = elemCtx.simulator().problem();

for (unsigned dofIdx = 0; dofIdx < elemCtx.numPrimaryDof(/*timeIdx=*/0); ++dofIdx) {
// Adding block data
const auto globalDofIdx = elemCtx.globalSpaceIndex(dofIdx, /*timeIdx=*/0);
Expand Down Expand Up @@ -882,42 +883,28 @@ class OutputBlackOilModule : public GenericOutputBlackoilModule<GetPropType<Type
else if (FluidSystem::phaseIsActive(waterPhaseIdx))
val.second = getValue(fs.temperature(waterPhaseIdx));
}
else if (key.first == "BSTRSSXX")
{
const auto& model = problem.geoMechModel();
auto stress = model.stress(globalDofIdx,/*include_fracture*/true);
val.second = stress[0];
}
else if (key.first == "BSTRSSYY")
{
const auto& model = problem.geoMechModel();
auto stress = model.stress(globalDofIdx,/*include_fracture*/true);
val.second = stress[1];
}
else if (key.first == "BSTRSSZZ")
{
const auto& model = problem.geoMechModel();
auto stress = model.stress(globalDofIdx,/*include_fracture*/true);
val.second = stress[2];
}
else if (key.first == "BSTRSSXY")
{
const auto& model = problem.geoMechModel();
auto stress = model.stress(globalDofIdx,/*include_fracture*/true);
val.second = stress[5];
}
else if (key.first == "BSTRSSXZ")
{
const auto& model = problem.geoMechModel();
auto stress = model.stress(globalDofIdx,/*include_fracture*/true);
val.second = stress[4];
else if ((key.first == "BSTRSSXX") ||
(key.first == "BSTRSSYY") ||
(key.first == "BSTRSSZZ") ||
(key.first == "BSTRSSXY") ||
(key.first == "BSTRSSXZ") ||
(key.first == "BSTRSSYZ"))
{
if constexpr (HasGeoMech<RemoveCVR<decltype(problem)>>::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")
Expand Down Expand Up @@ -1311,6 +1298,17 @@ class OutputBlackOilModule : public GenericOutputBlackoilModule<GetPropType<Type
}

private:
template <typename T>
using RemoveCVR = std::remove_cv_t<std::remove_reference_t<T>>;

template <typename, class = void>
struct HasGeoMech : public std::false_type {};

template <typename Problem>
struct HasGeoMech<
Problem, std::void_t<decltype(std::declval<Problem>().geoMechModel())>
> : public std::true_type {};

bool isDefunctParallelWell(std::string wname) const override
{
if (simulator_.gridView().comm().size() == 1)
Expand Down
81 changes: 51 additions & 30 deletions opm/simulators/wells/BlackoilWellModel_impl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<TypeTag, Properties::EnablePolymerMW>() && well->isInjector()) {
well->updateWaterThroughput(dt, this->wellState());
if (getPropValue<TypeTag, Properties::EnablePolymerMW>()) {
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_) {
Expand Down Expand Up @@ -793,40 +803,51 @@ namespace Opm {
}
}

// update the rate converter with current averages pressures etc in
rateConverter_->template defineState<ElementContext>(simulator_);
// Update the rate converter with current averages pressures etc in.
this->rateConverter_->template defineState<ElementContext>(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();
}

Expand Down

0 comments on commit 53656d0

Please sign in to comment.