BlackoilModel: rename ebosSimulator to simulator

This commit is contained in:
Arne Morten Kvarving 2024-02-06 10:05:36 +01:00
parent 3ae685d47c
commit 5e4c5e8174
3 changed files with 119 additions and 119 deletions

View File

@ -225,20 +225,20 @@ namespace Opm {
/// \param[in] linsolver linear solver /// \param[in] linsolver linear solver
/// \param[in] eclState eclipse state /// \param[in] eclState eclipse state
/// \param[in] terminal_output request output to cout/cerr /// \param[in] terminal_output request output to cout/cerr
BlackoilModel(Simulator& ebosSimulator, BlackoilModel(Simulator& simulator,
const ModelParameters& param, const ModelParameters& param,
BlackoilWellModel<TypeTag>& well_model, BlackoilWellModel<TypeTag>& well_model,
const bool terminal_output) const bool terminal_output)
: ebosSimulator_(ebosSimulator) : simulator_(simulator)
, grid_(ebosSimulator_.vanguard().grid()) , grid_(simulator_.vanguard().grid())
, phaseUsage_(phaseUsageFromDeck(eclState())) , phaseUsage_(phaseUsageFromDeck(eclState()))
, param_( param ) , param_( param )
, well_model_ (well_model) , well_model_ (well_model)
, rst_conv_(ebosSimulator_.problem().eclWriter()->collectToIORank().localIdxToGlobalIdxMapping(), , rst_conv_(simulator_.problem().eclWriter()->collectToIORank().localIdxToGlobalIdxMapping(),
grid_.comm()) grid_.comm())
, terminal_output_ (terminal_output) , terminal_output_ (terminal_output)
, current_relaxation_(1.0) , current_relaxation_(1.0)
, dx_old_(ebosSimulator_.model().numGridDof()) , dx_old_(simulator_.model().numGridDof())
{ {
// compute global sum of number of cells // compute global sum of number of cells
global_nc_ = detail::countGlobalCells(grid_); global_nc_ = detail::countGlobalCells(grid_);
@ -267,7 +267,7 @@ namespace Opm {
const EclipseState& eclState() const const EclipseState& eclState() const
{ return ebosSimulator_.vanguard().eclState(); } { return simulator_.vanguard().eclState(); }
/// Called once before each time step. /// Called once before each time step.
@ -277,24 +277,24 @@ namespace Opm {
SimulatorReportSingle report; SimulatorReportSingle report;
Dune::Timer perfTimer; Dune::Timer perfTimer;
perfTimer.start(); perfTimer.start();
// update the solution variables in ebos // update the solution variables in the model
if ( timer.lastStepFailed() ) { if ( timer.lastStepFailed() ) {
ebosSimulator_.model().updateFailed(); simulator_.model().updateFailed();
} else { } else {
ebosSimulator_.model().advanceTimeLevel(); simulator_.model().advanceTimeLevel();
} }
// Set the timestep size, episode index, and non-linear iteration index // Set the timestep size, episode index, and non-linear iteration index
// for ebos explicitly. ebos needs to know the report step/episode index // for the model explicitly. The model needs to know the report step/episode index
// because of timing dependent data despite the fact that flow uses its // because of timing dependent data despite the fact that flow uses its
// own time stepper. (The length of the episode does not matter, though.) // own time stepper. (The length of the episode does not matter, though.)
ebosSimulator_.setTime(timer.simulationTimeElapsed()); simulator_.setTime(timer.simulationTimeElapsed());
ebosSimulator_.setTimeStepSize(timer.currentStepLength()); simulator_.setTimeStepSize(timer.currentStepLength());
ebosSimulator_.model().newtonMethod().setIterationIndex(0); simulator_.model().newtonMethod().setIterationIndex(0);
ebosSimulator_.problem().beginTimeStep(); simulator_.problem().beginTimeStep();
unsigned numDof = ebosSimulator_.model().numGridDof(); unsigned numDof = simulator_.model().numGridDof();
wasSwitched_.resize(numDof); wasSwitched_.resize(numDof);
std::fill(wasSwitched_.begin(), wasSwitched_.end(), false); std::fill(wasSwitched_.begin(), wasSwitched_.end(), false);
@ -318,8 +318,8 @@ namespace Opm {
return -1; return -1;
}; };
const auto& schedule = ebosSimulator_.vanguard().schedule(); const auto& schedule = simulator_.vanguard().schedule();
rst_conv_.init(ebosSimulator_.vanguard().globalNumCells(), rst_conv_.init(simulator_.vanguard().globalNumCells(),
schedule[timer.reportStepNum()].rst_config(), schedule[timer.reportStepNum()].rst_config(),
{getIdx(FluidSystem::oilPhaseIdx), {getIdx(FluidSystem::oilPhaseIdx),
getIdx(FluidSystem::gasPhaseIdx), getIdx(FluidSystem::gasPhaseIdx),
@ -410,7 +410,7 @@ namespace Opm {
result = this->nlddSolver_->nonlinearIterationNldd(iteration, timer, nonlinear_solver); result = this->nlddSolver_->nonlinearIterationNldd(iteration, timer, nonlinear_solver);
} }
rst_conv_.update(ebosSimulator_.model().linearizer().residual()); rst_conv_.update(simulator_.model().linearizer().residual());
return result; return result;
} }
@ -435,7 +435,7 @@ namespace Opm {
report.total_newton_iterations = 1; report.total_newton_iterations = 1;
// Compute the nonlinear update. // Compute the nonlinear update.
unsigned nc = ebosSimulator_.model().numGridDof(); unsigned nc = simulator_.model().numGridDof();
BVector x(nc); BVector x(nc);
// Solve the linear system. // Solve the linear system.
@ -444,8 +444,8 @@ namespace Opm {
// Apply the Schur complement of the well model to // Apply the Schur complement of the well model to
// the reservoir linearized equations. // the reservoir linearized equations.
// Note that linearize may throw for MSwells. // Note that linearize may throw for MSwells.
wellModel().linearize(ebosSimulator().model().linearizer().jacobian(), wellModel().linearize(simulator().model().linearizer().jacobian(),
ebosSimulator().model().linearizer().residual()); simulator().model().linearizer().residual());
// ---- Solve linear system ---- // ---- Solve linear system ----
solveJacobianSystem(x); solveJacobianSystem(x);
@ -508,8 +508,8 @@ namespace Opm {
SimulatorReportSingle report; SimulatorReportSingle report;
Dune::Timer perfTimer; Dune::Timer perfTimer;
perfTimer.start(); perfTimer.start();
ebosSimulator_.problem().endTimeStep(); simulator_.problem().endTimeStep();
ebosSimulator_.problem().setConvData(rst_conv_.getData()); simulator_.problem().setConvData(rst_conv_.getData());
report.pre_post_time += perfTimer.stop(); report.pre_post_time += perfTimer.stop();
return report; return report;
} }
@ -519,10 +519,10 @@ namespace Opm {
const int iterationIdx) const int iterationIdx)
{ {
// -------- Mass balance equations -------- // -------- Mass balance equations --------
ebosSimulator_.model().newtonMethod().setIterationIndex(iterationIdx); simulator_.model().newtonMethod().setIterationIndex(iterationIdx);
ebosSimulator_.problem().beginIteration(); simulator_.problem().beginIteration();
ebosSimulator_.model().linearizer().linearizeDomain(); simulator_.model().linearizer().linearizeDomain();
ebosSimulator_.problem().endIteration(); simulator_.problem().endIteration();
return wellModel().lastReport(); return wellModel().lastReport();
} }
@ -532,11 +532,11 @@ namespace Opm {
Scalar resultDelta = 0.0; Scalar resultDelta = 0.0;
Scalar resultDenom = 0.0; Scalar resultDenom = 0.0;
const auto& elemMapper = ebosSimulator_.model().elementMapper(); const auto& elemMapper = simulator_.model().elementMapper();
const auto& gridView = ebosSimulator_.gridView(); const auto& gridView = simulator_.gridView();
for (const auto& elem : elements(gridView, Dune::Partitions::interior)) { for (const auto& elem : elements(gridView, Dune::Partitions::interior)) {
unsigned globalElemIdx = elemMapper.index(elem); unsigned globalElemIdx = elemMapper.index(elem);
const auto& priVarsNew = ebosSimulator_.model().solution(/*timeIdx=*/0)[globalElemIdx]; const auto& priVarsNew = simulator_.model().solution(/*timeIdx=*/0)[globalElemIdx];
Scalar pressureNew; Scalar pressureNew;
pressureNew = priVarsNew[Indices::pressureSwitchIdx]; pressureNew = priVarsNew[Indices::pressureSwitchIdx];
@ -562,7 +562,7 @@ namespace Opm {
saturationsNew[FluidSystem::oilPhaseIdx] = oilSaturationNew; saturationsNew[FluidSystem::oilPhaseIdx] = oilSaturationNew;
} }
const auto& priVarsOld = ebosSimulator_.model().solution(/*timeIdx=*/1)[globalElemIdx]; const auto& priVarsOld = simulator_.model().solution(/*timeIdx=*/1)[globalElemIdx];
Scalar pressureOld; Scalar pressureOld;
pressureOld = priVarsOld[Indices::pressureSwitchIdx]; pressureOld = priVarsOld[Indices::pressureSwitchIdx];
@ -613,7 +613,7 @@ namespace Opm {
/// Number of linear iterations used in last call to solveJacobianSystem(). /// Number of linear iterations used in last call to solveJacobianSystem().
int linearIterationsLastSolve() const int linearIterationsLastSolve() const
{ {
return ebosSimulator_.model().newtonMethod().linearSolver().iterations (); return simulator_.model().newtonMethod().linearSolver().iterations ();
} }
@ -629,9 +629,9 @@ namespace Opm {
void solveJacobianSystem(BVector& x) void solveJacobianSystem(BVector& x)
{ {
auto& ebosJac = ebosSimulator_.model().linearizer().jacobian().istlMatrix(); auto& ebosJac = simulator_.model().linearizer().jacobian().istlMatrix();
auto& ebosResid = ebosSimulator_.model().linearizer().residual(); auto& ebosResid = simulator_.model().linearizer().residual();
auto& ebosSolver = ebosSimulator_.model().newtonMethod().linearSolver(); auto& ebosSolver = simulator_.model().newtonMethod().linearSolver();
const int numSolvers = ebosSolver.numAvailableSolvers(); const int numSolvers = ebosSolver.numAvailableSolvers();
if ((numSolvers > 1) && (ebosSolver.getSolveCount() % 100 == 0)) { if ((numSolvers > 1) && (ebosSolver.getSolveCount() % 100 == 0)) {
@ -693,8 +693,8 @@ namespace Opm {
void updateSolution(const BVector& dx) void updateSolution(const BVector& dx)
{ {
OPM_TIMEBLOCK(updateSolution); OPM_TIMEBLOCK(updateSolution);
auto& ebosNewtonMethod = ebosSimulator_.model().newtonMethod(); auto& ebosNewtonMethod = simulator_.model().newtonMethod();
SolutionVector& solution = ebosSimulator_.model().solution(/*timeIdx=*/0); SolutionVector& solution = simulator_.model().solution(/*timeIdx=*/0);
ebosNewtonMethod.update_(/*nextSolution=*/solution, ebosNewtonMethod.update_(/*nextSolution=*/solution,
/*curSolution=*/solution, /*curSolution=*/solution,
@ -706,8 +706,8 @@ namespace Opm {
// if the solution is updated, the intensive quantities need to be recalculated // if the solution is updated, the intensive quantities need to be recalculated
{ {
OPM_TIMEBLOCK(invalidateAndUpdateIntensiveQuantities); OPM_TIMEBLOCK(invalidateAndUpdateIntensiveQuantities);
ebosSimulator_.model().invalidateAndUpdateIntensiveQuantities(/*timeIdx=*/0); simulator_.model().invalidateAndUpdateIntensiveQuantities(/*timeIdx=*/0);
ebosSimulator_.problem().eclWriter()->mutableEclOutputModule().invalidateLocalData(); simulator_.problem().eclWriter()->mutableEclOutputModule().invalidateLocalData();
} }
} }
@ -788,13 +788,13 @@ namespace Opm {
OPM_TIMEBLOCK(localConvergenceData); OPM_TIMEBLOCK(localConvergenceData);
double pvSumLocal = 0.0; double pvSumLocal = 0.0;
double numAquiferPvSumLocal = 0.0; double numAquiferPvSumLocal = 0.0;
const auto& ebosModel = ebosSimulator_.model(); const auto& ebosModel = simulator_.model();
const auto& ebosProblem = ebosSimulator_.problem(); const auto& ebosProblem = simulator_.problem();
const auto& ebosResid = ebosSimulator_.model().linearizer().residual(); const auto& ebosResid = simulator_.model().linearizer().residual();
ElementContext elemCtx(ebosSimulator_); ElementContext elemCtx(simulator_);
const auto& gridView = ebosSimulator().gridView(); const auto& gridView = simulator().gridView();
IsNumericalAquiferCell isNumericalAquiferCell(gridView.grid()); IsNumericalAquiferCell isNumericalAquiferCell(gridView.grid());
OPM_BEGIN_PARALLEL_TRY_CATCH(); OPM_BEGIN_PARALLEL_TRY_CATCH();
for (const auto& elem : elements(gridView, Dune::Partitions::interior)) { for (const auto& elem : elements(gridView, Dune::Partitions::interior)) {
@ -837,11 +837,11 @@ namespace Opm {
{ {
OPM_TIMEBLOCK(computeCnvErrorPv); OPM_TIMEBLOCK(computeCnvErrorPv);
double errorPV{}; double errorPV{};
const auto& ebosModel = ebosSimulator_.model(); const auto& ebosModel = simulator_.model();
const auto& ebosProblem = ebosSimulator_.problem(); const auto& ebosProblem = simulator_.problem();
const auto& ebosResid = ebosSimulator_.model().linearizer().residual(); const auto& ebosResid = simulator_.model().linearizer().residual();
const auto& gridView = ebosSimulator().gridView(); const auto& gridView = simulator().gridView();
ElementContext elemCtx(ebosSimulator_); ElementContext elemCtx(simulator_);
IsNumericalAquiferCell isNumericalAquiferCell(gridView.grid()); IsNumericalAquiferCell isNumericalAquiferCell(gridView.grid());
OPM_BEGIN_PARALLEL_TRY_CATCH(); OPM_BEGIN_PARALLEL_TRY_CATCH();
@ -1042,11 +1042,11 @@ namespace Opm {
return regionValues; return regionValues;
} }
const Simulator& ebosSimulator() const const Simulator& simulator() const
{ return ebosSimulator_; } { return simulator_; }
Simulator& ebosSimulator() Simulator& simulator()
{ return ebosSimulator_; } { return simulator_; }
/// return the statistics if the nonlinearIteration() method failed /// return the statistics if the nonlinearIteration() method failed
const SimulatorReportSingle& failureReport() const const SimulatorReportSingle& failureReport() const
@ -1071,10 +1071,10 @@ namespace Opm {
return; return;
} }
const auto& elementMapper = this->ebosSimulator().model().elementMapper(); const auto& elementMapper = this->simulator().model().elementMapper();
const auto& cartMapper = this->ebosSimulator().vanguard().cartesianIndexMapper(); const auto& cartMapper = this->simulator().vanguard().cartesianIndexMapper();
const auto& grid = this->ebosSimulator().vanguard().grid(); const auto& grid = this->simulator().vanguard().grid();
const auto& comm = grid.comm(); const auto& comm = grid.comm();
const auto nDigit = 1 + static_cast<int>(std::floor(std::log10(comm.size()))); const auto nDigit = 1 + static_cast<int>(std::floor(std::log10(comm.size())));
@ -1093,8 +1093,8 @@ namespace Opm {
protected: protected:
// --------- Data members --------- // --------- Data members ---------
Simulator& ebosSimulator_; Simulator& simulator_;
const Grid& grid_; const Grid& grid_;
const PhaseUsage phaseUsage_; const PhaseUsage phaseUsage_;
static constexpr bool has_solvent_ = getPropValue<TypeTag, Properties::EnableSolvent>(); static constexpr bool has_solvent_ = getPropValue<TypeTag, Properties::EnableSolvent>();
static constexpr bool has_extbo_ = getPropValue<TypeTag, Properties::EnableExtbo>(); static constexpr bool has_extbo_ = getPropValue<TypeTag, Properties::EnableExtbo>();
@ -1137,12 +1137,12 @@ namespace Opm {
void beginReportStep() void beginReportStep()
{ {
ebosSimulator_.problem().beginEpisode(); simulator_.problem().beginEpisode();
} }
void endReportStep() void endReportStep()
{ {
ebosSimulator_.problem().endEpisode(); simulator_.problem().endEpisode();
} }
template<class FluidState, class Residual> template<class FluidState, class Residual>

View File

@ -97,7 +97,7 @@ public:
//! \param param param Model parameters //! \param param param Model parameters
//! \param compNames Names of the solution components //! \param compNames Names of the solution components
BlackoilModelNldd(BlackoilModel<TypeTag>& model) BlackoilModelNldd(BlackoilModel<TypeTag>& model)
: model_(model), rank_(model_.ebosSimulator().vanguard().grid().comm().rank()) : model_(model), rank_(model_.simulator().vanguard().grid().comm().rank())
{ {
// Create partitions. // Create partitions.
const auto& [partition_vector, num_domains] = this->partitionCells(); const auto& [partition_vector, num_domains] = this->partitionCells();
@ -119,7 +119,7 @@ public:
// Iterate through grid once, setting the seeds of all partitions. // Iterate through grid once, setting the seeds of all partitions.
// Note: owned cells only! // Note: owned cells only!
const auto& grid = model_.ebosSimulator().vanguard().grid(); const auto& grid = model_.simulator().vanguard().grid();
std::vector<int> count(num_domains, 0); std::vector<int> count(num_domains, 0);
const auto& gridView = grid.leafGridView(); const auto& gridView = grid.leafGridView();
@ -157,7 +157,7 @@ public:
// TODO: The ISTLSolver constructor will make // TODO: The ISTLSolver constructor will make
// parallel structures appropriate for the full grid // parallel structures appropriate for the full grid
// only. This must be addressed before going parallel. // only. This must be addressed before going parallel.
const auto& eclState = model_.ebosSimulator().vanguard().eclState(); const auto& eclState = model_.simulator().vanguard().eclState();
FlowLinearSolverParameters loc_param; FlowLinearSolverParameters loc_param;
loc_param.template init<TypeTag>(eclState.getSimulationConfig().useCPR()); loc_param.template init<TypeTag>(eclState.getSimulationConfig().useCPR());
// Override solver type with umfpack if small domain. // Override solver type with umfpack if small domain.
@ -170,7 +170,7 @@ public:
} }
loc_param.linear_solver_print_json_definition_ = false; loc_param.linear_solver_print_json_definition_ = false;
const bool force_serial = true; const bool force_serial = true;
domain_linsolvers_.emplace_back(model_.ebosSimulator(), loc_param, force_serial); domain_linsolvers_.emplace_back(model_.simulator(), loc_param, force_serial);
} }
assert(int(domains_.size()) == num_domains); assert(int(domains_.size()) == num_domains);
@ -201,7 +201,7 @@ public:
// ----------- If not converged, do an NLDD iteration ----------- // ----------- If not converged, do an NLDD iteration -----------
auto& solution = model_.ebosSimulator().model().solution(0); auto& solution = model_.simulator().model().solution(0);
auto initial_solution = solution; auto initial_solution = solution;
auto locally_solved = initial_solution; auto locally_solved = initial_solution;
@ -242,7 +242,7 @@ public:
} }
// Communicate and log all messages. // Communicate and log all messages.
auto global_logger = gatherDeferredLogger(logger, model_.ebosSimulator().vanguard().grid().comm()); auto global_logger = gatherDeferredLogger(logger, model_.simulator().vanguard().grid().comm());
global_logger.logMessages(); global_logger.logMessages();
// Accumulate local solve data. // Accumulate local solve data.
@ -270,7 +270,7 @@ public:
if (model_.param().local_solve_approach_ == DomainSolveApproach::Jacobi) { if (model_.param().local_solve_approach_ == DomainSolveApproach::Jacobi) {
solution = locally_solved; solution = locally_solved;
model_.ebosSimulator().model().invalidateAndUpdateIntensiveQuantities(/*timeIdx=*/0); model_.simulator().model().invalidateAndUpdateIntensiveQuantities(/*timeIdx=*/0);
} }
#if HAVE_MPI #if HAVE_MPI
@ -281,9 +281,9 @@ public:
// here. We must therefore receive the updated solution on the // here. We must therefore receive the updated solution on the
// overlap cells and update their intensive quantities before // overlap cells and update their intensive quantities before
// we move on. // we move on.
const auto& comm = model_.ebosSimulator().vanguard().grid().comm(); const auto& comm = model_.simulator().vanguard().grid().comm();
if (comm.size() > 1) { if (comm.size() > 1) {
const auto* ccomm = model_.ebosSimulator().model().newtonMethod().linearSolver().comm(); const auto* ccomm = model_.simulator().model().newtonMethod().linearSolver().comm();
// Copy numerical values from primary vars. // Copy numerical values from primary vars.
ccomm->copyOwnerToAll(solution, solution); ccomm->copyOwnerToAll(solution, solution);
@ -300,7 +300,7 @@ public:
} }
// Update intensive quantities for our overlap values. // Update intensive quantities for our overlap values.
model_.ebosSimulator().model().invalidateAndUpdateIntensiveQuantitiesOverlap(/*timeIdx=*/0); model_.simulator().model().invalidateAndUpdateIntensiveQuantitiesOverlap(/*timeIdx=*/0);
// Make total counts of domains converged. // Make total counts of domains converged.
comm.sum(counts.data(), counts.size()); comm.sum(counts.data(), counts.size());
@ -334,10 +334,10 @@ public:
void writePartitions(const std::filesystem::path& odir) const void writePartitions(const std::filesystem::path& odir) const
{ {
const auto& elementMapper = this->model_.ebosSimulator().model().elementMapper(); const auto& elementMapper = this->model_.simulator().model().elementMapper();
const auto& cartMapper = this->model_.ebosSimulator().vanguard().cartesianIndexMapper(); const auto& cartMapper = this->model_.simulator().vanguard().cartesianIndexMapper();
const auto& grid = this->model_.ebosSimulator().vanguard().grid(); const auto& grid = this->model_.simulator().vanguard().grid();
const auto& comm = grid.comm(); const auto& comm = grid.comm();
const auto nDigit = 1 + static_cast<int>(std::floor(std::log10(comm.size()))); const auto nDigit = 1 + static_cast<int>(std::floor(std::log10(comm.size())));
@ -361,14 +361,14 @@ private:
[[maybe_unused]] const int global_iteration, [[maybe_unused]] const int global_iteration,
const bool initial_assembly_required) const bool initial_assembly_required)
{ {
auto& ebosSimulator = model_.ebosSimulator(); auto& modelSimulator = model_.simulator();
SimulatorReportSingle report; SimulatorReportSingle report;
Dune::Timer solveTimer; Dune::Timer solveTimer;
solveTimer.start(); solveTimer.start();
Dune::Timer detailTimer; Dune::Timer detailTimer;
ebosSimulator.model().newtonMethod().setIterationIndex(0); modelSimulator.model().newtonMethod().setIterationIndex(0);
// When called, if assembly has already been performed // When called, if assembly has already been performed
// with the initial values, we only need to check // with the initial values, we only need to check
@ -377,11 +377,11 @@ private:
int iter = 0; int iter = 0;
if (initial_assembly_required) { if (initial_assembly_required) {
detailTimer.start(); detailTimer.start();
ebosSimulator.model().newtonMethod().setIterationIndex(iter); modelSimulator.model().newtonMethod().setIterationIndex(iter);
// TODO: we should have a beginIterationLocal function() // TODO: we should have a beginIterationLocal function()
// only handling the well model for now // only handling the well model for now
ebosSimulator.problem().wellModel().assembleDomain(ebosSimulator.model().newtonMethod().numIterations(), modelSimulator.problem().wellModel().assembleDomain(modelSimulator.model().newtonMethod().numIterations(),
ebosSimulator.timeStepSize(), modelSimulator.timeStepSize(),
domain); domain);
// Assemble reservoir locally. // Assemble reservoir locally.
report += this->assembleReservoirDomain(domain); report += this->assembleReservoirDomain(domain);
@ -402,15 +402,15 @@ private:
detailTimer.reset(); detailTimer.reset();
detailTimer.start(); detailTimer.start();
model_.wellModel().linearizeDomain(domain, model_.wellModel().linearizeDomain(domain,
ebosSimulator.model().linearizer().jacobian(), modelSimulator.model().linearizer().jacobian(),
ebosSimulator.model().linearizer().residual()); modelSimulator.model().linearizer().residual());
const double tt1 = detailTimer.stop(); const double tt1 = detailTimer.stop();
report.assemble_time += tt1; report.assemble_time += tt1;
report.assemble_time_well += tt1; report.assemble_time_well += tt1;
// Local Newton loop. // Local Newton loop.
const int max_iter = model_.param().max_local_solve_iterations_; const int max_iter = model_.param().max_local_solve_iterations_;
const auto& grid = ebosSimulator.vanguard().grid(); const auto& grid = modelSimulator.vanguard().grid();
do { do {
// Solve local linear system. // Solve local linear system.
// Note that x has full size, we expect it to be nonzero only for in-domain cells. // Note that x has full size, we expect it to be nonzero only for in-domain cells.
@ -434,13 +434,13 @@ private:
detailTimer.reset(); detailTimer.reset();
detailTimer.start(); detailTimer.start();
++iter; ++iter;
ebosSimulator.model().newtonMethod().setIterationIndex(iter); modelSimulator.model().newtonMethod().setIterationIndex(iter);
// TODO: we should have a beginIterationLocal function() // TODO: we should have a beginIterationLocal function()
// only handling the well model for now // only handling the well model for now
// Assemble reservoir locally. // Assemble reservoir locally.
ebosSimulator.problem().wellModel().assembleDomain(ebosSimulator.model().newtonMethod().numIterations(), modelSimulator.problem().wellModel().assembleDomain(modelSimulator.model().newtonMethod().numIterations(),
ebosSimulator.timeStepSize(), modelSimulator.timeStepSize(),
domain); domain);
report += this->assembleReservoirDomain(domain); report += this->assembleReservoirDomain(domain);
report.assemble_time += detailTimer.stop(); report.assemble_time += detailTimer.stop();
@ -454,14 +454,14 @@ private:
detailTimer.reset(); detailTimer.reset();
detailTimer.start(); detailTimer.start();
model_.wellModel().linearizeDomain(domain, model_.wellModel().linearizeDomain(domain,
ebosSimulator.model().linearizer().jacobian(), modelSimulator.model().linearizer().jacobian(),
ebosSimulator.model().linearizer().residual()); modelSimulator.model().linearizer().residual());
const double tt2 = detailTimer.stop(); const double tt2 = detailTimer.stop();
report.assemble_time += tt2; report.assemble_time += tt2;
report.assemble_time_well += tt2; report.assemble_time_well += tt2;
} while (!convreport.converged() && iter <= max_iter); } while (!convreport.converged() && iter <= max_iter);
ebosSimulator.problem().endIteration(); modelSimulator.problem().endIteration();
report.converged = convreport.converged(); report.converged = convreport.converged();
report.total_newton_iterations = iter; report.total_newton_iterations = iter;
@ -475,26 +475,26 @@ private:
SimulatorReportSingle assembleReservoirDomain(const Domain& domain) SimulatorReportSingle assembleReservoirDomain(const Domain& domain)
{ {
// -------- Mass balance equations -------- // -------- Mass balance equations --------
model_.ebosSimulator().model().linearizer().linearizeDomain(domain); model_.simulator().model().linearizer().linearizeDomain(domain);
return model_.wellModel().lastReport(); return model_.wellModel().lastReport();
} }
//! \brief Solve the linearized system for a domain. //! \brief Solve the linearized system for a domain.
void solveJacobianSystemDomain(const Domain& domain, BVector& global_x) void solveJacobianSystemDomain(const Domain& domain, BVector& global_x)
{ {
const auto& ebosSimulator = model_.ebosSimulator(); const auto& modelSimulator = model_.simulator();
Dune::Timer perfTimer; Dune::Timer perfTimer;
perfTimer.start(); perfTimer.start();
const Mat& main_matrix = ebosSimulator.model().linearizer().jacobian().istlMatrix(); const Mat& main_matrix = modelSimulator.model().linearizer().jacobian().istlMatrix();
if (domain_matrices_[domain.index]) { if (domain_matrices_[domain.index]) {
Details::copySubMatrix(main_matrix, domain.cells, *domain_matrices_[domain.index]); Details::copySubMatrix(main_matrix, domain.cells, *domain_matrices_[domain.index]);
} else { } else {
domain_matrices_[domain.index] = std::make_unique<Mat>(Details::extractMatrix(main_matrix, domain.cells)); domain_matrices_[domain.index] = std::make_unique<Mat>(Details::extractMatrix(main_matrix, domain.cells));
} }
auto& jac = *domain_matrices_[domain.index]; auto& jac = *domain_matrices_[domain.index];
auto res = Details::extractVector(ebosSimulator.model().linearizer().residual(), auto res = Details::extractVector(modelSimulator.model().linearizer().residual(),
domain.cells); domain.cells);
auto x = res; auto x = res;
@ -515,9 +515,9 @@ private:
/// Apply an update to the primary variables. /// Apply an update to the primary variables.
void updateDomainSolution(const Domain& domain, const BVector& dx) void updateDomainSolution(const Domain& domain, const BVector& dx)
{ {
auto& ebosSimulator = model_.ebosSimulator(); auto& modelSimulator = model_.simulator();
auto& ebosNewtonMethod = ebosSimulator.model().newtonMethod(); auto& ebosNewtonMethod = modelSimulator.model().newtonMethod();
SolutionVector& solution = ebosSimulator.model().solution(/*timeIdx=*/0); SolutionVector& solution = modelSimulator.model().solution(/*timeIdx=*/0);
ebosNewtonMethod.update_(/*nextSolution=*/solution, ebosNewtonMethod.update_(/*nextSolution=*/solution,
/*curSolution=*/solution, /*curSolution=*/solution,
@ -528,7 +528,7 @@ private:
// residual // residual
// if the solution is updated, the intensive quantities need to be recalculated // if the solution is updated, the intensive quantities need to be recalculated
ebosSimulator.model().invalidateAndUpdateIntensiveQuantities(/*timeIdx=*/0, domain); modelSimulator.model().invalidateAndUpdateIntensiveQuantities(/*timeIdx=*/0, domain);
} }
//! \brief Get reservoir quantities on this process needed for convergence calculations. //! \brief Get reservoir quantities on this process needed for convergence calculations.
@ -538,16 +538,16 @@ private:
std::vector<Scalar>& B_avg, std::vector<Scalar>& B_avg,
std::vector<int>& maxCoeffCell) std::vector<int>& maxCoeffCell)
{ {
const auto& ebosSimulator = model_.ebosSimulator(); const auto& modelSimulator = model_.simulator();
double pvSumLocal = 0.0; double pvSumLocal = 0.0;
double numAquiferPvSumLocal = 0.0; double numAquiferPvSumLocal = 0.0;
const auto& ebosModel = ebosSimulator.model(); const auto& ebosModel = modelSimulator.model();
const auto& ebosProblem = ebosSimulator.problem(); const auto& ebosProblem = modelSimulator.problem();
const auto& ebosResid = ebosSimulator.model().linearizer().residual(); const auto& ebosResid = modelSimulator.model().linearizer().residual();
ElementContext elemCtx(ebosSimulator); ElementContext elemCtx(modelSimulator);
const auto& gridView = domain.view; const auto& gridView = domain.view;
const auto& elemEndIt = gridView.template end</*codim=*/0>(); const auto& elemEndIt = gridView.template end</*codim=*/0>();
IsNumericalAquiferCell isNumericalAquiferCell(gridView.grid()); IsNumericalAquiferCell isNumericalAquiferCell(gridView.grid());
@ -717,8 +717,8 @@ private:
//! \brief Returns subdomain ordered according to method and ordering measure. //! \brief Returns subdomain ordered according to method and ordering measure.
std::vector<int> getSubdomainOrder() std::vector<int> getSubdomainOrder()
{ {
const auto& ebosSimulator = model_.ebosSimulator(); const auto& modelSimulator = model_.simulator();
const auto& solution = ebosSimulator.model().solution(0); const auto& solution = modelSimulator.model().solution(0);
std::vector<int> domain_order(domains_.size()); std::vector<int> domain_order(domains_.size());
std::iota(domain_order.begin(), domain_order.end(), 0); std::iota(domain_order.begin(), domain_order.end(), 0);
@ -755,7 +755,7 @@ private:
} }
case DomainOrderingMeasure::Residual: { case DomainOrderingMeasure::Residual: {
// Use maximum residual to order domains. // Use maximum residual to order domains.
const auto& residual = ebosSimulator.model().linearizer().residual(); const auto& residual = modelSimulator.model().linearizer().residual();
const int num_vars = residual[0].size(); const int num_vars = residual[0].size();
for (const auto& domain : domains_) { for (const auto& domain : domains_) {
double maxres = 0.0; double maxres = 0.0;
@ -797,11 +797,11 @@ private:
auto local_solution = Details::extractVector(solution, domain.cells); auto local_solution = Details::extractVector(solution, domain.cells);
Details::setGlobal(local_solution, domain.cells, locally_solved); Details::setGlobal(local_solution, domain.cells, locally_solved);
Details::setGlobal(initial_local_solution, domain.cells, solution); Details::setGlobal(initial_local_solution, domain.cells, solution);
model_.ebosSimulator().model().invalidateAndUpdateIntensiveQuantities(/*timeIdx=*/0, domain); model_.simulator().model().invalidateAndUpdateIntensiveQuantities(/*timeIdx=*/0, domain);
} else { } else {
model_.wellModel().setPrimaryVarsDomain(domain, initial_local_well_primary_vars); model_.wellModel().setPrimaryVarsDomain(domain, initial_local_well_primary_vars);
Details::setGlobal(initial_local_solution, domain.cells, solution); Details::setGlobal(initial_local_solution, domain.cells, solution);
model_.ebosSimulator().model().invalidateAndUpdateIntensiveQuantities(/*timeIdx=*/0, domain); model_.simulator().model().invalidateAndUpdateIntensiveQuantities(/*timeIdx=*/0, domain);
} }
} }
@ -856,7 +856,7 @@ private:
} else { } else {
model_.wellModel().setPrimaryVarsDomain(domain, initial_local_well_primary_vars); model_.wellModel().setPrimaryVarsDomain(domain, initial_local_well_primary_vars);
Details::setGlobal(initial_local_solution, domain.cells, solution); Details::setGlobal(initial_local_solution, domain.cells, solution);
model_.ebosSimulator().model().invalidateAndUpdateIntensiveQuantities(/*timeIdx=*/0, domain); model_.simulator().model().invalidateAndUpdateIntensiveQuantities(/*timeIdx=*/0, domain);
} }
} }
@ -864,10 +864,10 @@ private:
const std::vector<Scalar>& B_avg, double dt) const const std::vector<Scalar>& B_avg, double dt) const
{ {
double errorPV{}; double errorPV{};
const auto& ebosSimulator = model_.ebosSimulator(); const auto& modelSimulator = model_.simulator();
const auto& ebosModel = ebosSimulator.model(); const auto& ebosModel = modelSimulator.model();
const auto& ebosProblem = ebosSimulator.problem(); const auto& ebosProblem = modelSimulator.problem();
const auto& ebosResid = ebosSimulator.model().linearizer().residual(); const auto& ebosResid = modelSimulator.model().linearizer().residual();
for (const int cell_idx : domain.cells) { for (const int cell_idx : domain.cells) {
const double pvValue = ebosProblem.referencePorosity(cell_idx, /*timeIdx=*/0) * const double pvValue = ebosProblem.referencePorosity(cell_idx, /*timeIdx=*/0) *
@ -890,7 +890,7 @@ private:
decltype(auto) partitionCells() const decltype(auto) partitionCells() const
{ {
const auto& grid = this->model_.ebosSimulator().vanguard().grid(); const auto& grid = this->model_.simulator().vanguard().grid();
using GridView = std::remove_cv_t<std::remove_reference_t<decltype(grid.leafGridView())>>; using GridView = std::remove_cv_t<std::remove_reference_t<decltype(grid.leafGridView())>>;
using Element = std::remove_cv_t<std::remove_reference_t<typename GridView::template Codim<0>::Entity>>; using Element = std::remove_cv_t<std::remove_reference_t<typename GridView::template Codim<0>::Entity>>;
@ -900,13 +900,13 @@ private:
auto zoltan_ctrl = ZoltanPartitioningControl<Element>{}; auto zoltan_ctrl = ZoltanPartitioningControl<Element>{};
zoltan_ctrl.domain_imbalance = param.local_domain_partition_imbalance_; zoltan_ctrl.domain_imbalance = param.local_domain_partition_imbalance_;
zoltan_ctrl.index = zoltan_ctrl.index =
[elementMapper = &this->model_.ebosSimulator().model().elementMapper()] [elementMapper = &this->model_.simulator().model().elementMapper()]
(const Element& element) (const Element& element)
{ {
return elementMapper->index(element); return elementMapper->index(element);
}; };
zoltan_ctrl.local_to_global = zoltan_ctrl.local_to_global =
[cartMapper = &this->model_.ebosSimulator().vanguard().cartesianIndexMapper()] [cartMapper = &this->model_.simulator().vanguard().cartesianIndexMapper()]
(const int elemIdx) (const int elemIdx)
{ {
return cartMapper->cartesianIndex(elemIdx); return cartMapper->cartesianIndex(elemIdx);
@ -915,7 +915,7 @@ private:
// Forming the list of wells is expensive, so do this only if needed. // Forming the list of wells is expensive, so do this only if needed.
const auto need_wells = param.local_domain_partition_method_ == "zoltan"; const auto need_wells = param.local_domain_partition_method_ == "zoltan";
const auto wells = need_wells const auto wells = need_wells
? this->model_.ebosSimulator().vanguard().schedule().getWellsatEnd() ? this->model_.simulator().vanguard().schedule().getWellsatEnd()
: std::vector<Well>{}; : std::vector<Well>{};
// If defaulted parameter for number of domains, choose a reasonable default. // If defaulted parameter for number of domains, choose a reasonable default.
@ -932,7 +932,7 @@ private:
std::vector<int> reconstitutePartitionVector() const std::vector<int> reconstitutePartitionVector() const
{ {
const auto& grid = this->model_.ebosSimulator().vanguard().grid(); const auto& grid = this->model_.simulator().vanguard().grid();
auto numD = std::vector<int>(grid.comm().size() + 1, 0); auto numD = std::vector<int>(grid.comm().size() + 1, 0);
numD[grid.comm().rank() + 1] = static_cast<int>(this->domains_.size()); numD[grid.comm().rank() + 1] = static_cast<int>(this->domains_.size());

View File

@ -364,8 +364,8 @@ std::set<std::string> consistentlyFailingWells(const std::vector<StepReport>& sr
suggestedNextTimestep_ = timestepAfterEvent_; suggestedNextTimestep_ = timestepAfterEvent_;
} }
auto& ebosSimulator = solver.model().ebosSimulator(); auto& modelSimulator = solver.model().simulator();
auto& ebosProblem = ebosSimulator.problem(); auto& ebosProblem = modelSimulator.problem();
// create adaptive step timer with previously used sub step size // create adaptive step timer with previously used sub step size
AdaptiveSimulatorTimer substepTimer(simulatorTimer, suggestedNextTimestep_, maxTimeStep_); AdaptiveSimulatorTimer substepTimer(simulatorTimer, suggestedNextTimestep_, maxTimeStep_);
@ -432,7 +432,7 @@ std::set<std::string> consistentlyFailingWells(const std::vector<StepReport>& sr
} }
//Pass substep to eclwriter for summary output //Pass substep to eclwriter for summary output
ebosSimulator.problem().setSubStepReport(substepReport); modelSimulator.problem().setSubStepReport(substepReport);
report += substepReport; report += substepReport;