25#ifndef BLACK_OIL_MODEL_TPSA_HPP
26#define BLACK_OIL_MODEL_TPSA_HPP
28#include <opm/common/ErrorMacros.hpp>
29#include <opm/common/OpmLog/OpmLog.hpp>
31#include <opm/simulators/flow/BlackoilModel.hpp>
36#include <fmt/format.h>
44template <
class TypeTag>
53 using ModelParameters =
typename ParentType::ModelParameters;
64 const ModelParameters&
param,
66 const bool terminal_output)
67 : ParentType(simulator,
param, well_model, terminal_output)
81 template <
class NonlinearSolverType>
83 NonlinearSolverType& nonlinear_solver)
86 const auto& problem = this->simulator_.problem();
87 if (problem.fixedStressScheme()) {
90 else if (problem.laggedScheme()) {
94 std::string msg =
"Unknown Flow-TPSA coupling scheme!";
96 throw std::runtime_error(msg);
109 template <
class NonlinearSolverType>
111 NonlinearSolverType& nonlinear_solver)
114 const auto& [minSeqIter, maxSeqIter] = this->simulator_.problem().fixedStressParameters();
118 if (seqIter_ >= maxSeqIter) {
120 std::string msg = fmt::format(
"TPSA: Fixed-stress scheme reached max iterations (={})!", maxSeqIter);
121 OpmLog::warning(msg);
124 reportFlow.converged =
true;
132 this->simulator_.problem().geoMechModel().prepareTPSA();
141 const auto iteration = this->simulator_.problem().iterationContext().iteration();
142 if (reportFlow.converged && iteration >= this->param_.newton_min_iter_) {
151 && this->simulator_.problem().geoMechModel().newtonMethod().numLinearizations() == 1
152 && seqIter_ >= minSeqIter) {
154 std::string msg = fmt::format(
"TPSA: Fixed-stress scheme converged in {} iterations", seqIter_);
163 else if (!tpsaConv) {
167 throw std::runtime_error(
"TPSA: Fixed stress scheme update failed!");
171 reportFlow.converged =
false;
186 template <
class NonlinearSolverType>
188 NonlinearSolverType& nonlinear_solver)
194 const auto iteration = this->simulator_.problem().iterationContext().iteration();
195 if (reportFlow.converged && iteration >= this->param_.newton_min_iter_) {
197 this->simulator_.problem().geoMechModel().prepareTPSA();
204 throw std::runtime_error(
"TPSA: Lagged scheme update failed!");
221 return this->simulator_.problem().geoMechModel().newtonMethod().apply();
SimulatorReportSingle nonlinearIterationLaggedTPSA(const SimulatorTimerInterface &timer, NonlinearSolverType &nonlinear_solver)
Perform a nonlinear iteration updating Flow and TPSA geomechanics in a lagged scheme.
Definition BlackoilModelTPSA.hpp:187
SimulatorReportSingle nonlinearIteration(const SimulatorTimerInterface &timer, NonlinearSolverType &nonlinear_solver)
Perform a nonlinear iteration updating Flow and TPSA geomechanics.
Definition BlackoilModelTPSA.hpp:82
SimulatorReportSingle nonlinearIterationFixedStressTPSA(const SimulatorTimerInterface &timer, NonlinearSolverType &nonlinear_solver)
Perform a nonlinear iteration updating Flow and TPSA geomechanics in a fixed-stress,...
Definition BlackoilModelTPSA.hpp:110
bool solveTpsaEquations()
Solve TPSA geomechanics equations.
Definition BlackoilModelTPSA.hpp:218
BlackoilModelTPSA(Simulator &simulator, const ModelParameters ¶m, BlackoilWellModel< TypeTag > &well_model, const bool terminal_output)
Constructor.
Definition BlackoilModelTPSA.hpp:63
BlackoilModel(Simulator &simulator, const ModelParameters ¶m, BlackoilWellModel< TypeTag > &well_model, const bool terminal_output)
Construct the model.
Definition BlackoilModel_impl.hpp:78
const ModelParameters & param() const
Returns const reference to model parameters.
Definition BlackoilModel.hpp:329
SimulatorReportSingle nonlinearIteration(const SimulatorTimerInterface &timer, NonlinearSolverType &nonlinear_solver)
Called once per nonlinear iteration.
Definition BlackoilModel_impl.hpp:245
Class for handling the blackoil well model.
Definition BlackoilWellModel.hpp:98
Interface class for SimulatorTimer objects, to be improved.
Definition SimulatorTimerInterface.hpp:34
This file contains a set of helper functions used by VFPProd / VFPInj.
Definition blackoilbioeffectsmodules.hh:45
typename Properties::Detail::GetPropImpl< TypeTag, Property >::type::type GetPropType
get the type alias defined in the property (equivalent to old macro GET_PROP_TYPE(....
Definition propertysystem.hh:233
A struct for returning timing data from a simulator to its caller.
Definition SimulatorReport.hpp:34