Make solver object a member of SimulatorFullyImplicitBlackoilEbos.

This commit is contained in:
Atgeirr Flø Rasmussen 2023-06-14 09:20:25 +02:00
parent ed591239a7
commit 7f3635145b
2 changed files with 17 additions and 15 deletions

View File

@ -1064,11 +1064,6 @@ namespace Opm {
return convergence_reports_;
}
std::vector<StepReport> getStepReportsDestructively() const
{
return std::move(this->convergence_reports_);
}
protected:
// --------- Data members ---------

View File

@ -362,7 +362,9 @@ public:
// Run a multiple steps of the solver depending on the time step control.
solverTimer_->start();
auto solver = createSolver(wellModel_());
if (!solver_) {
solver_ = createSolver(wellModel_());
}
ebosSimulator_.startNextEpisode(
ebosSimulator_.startTime()
@ -375,8 +377,7 @@ public:
loadStep_ = -1;
ebosSimulator_.model().invalidateAndUpdateIntensiveQuantities(/*timeIdx=*/0);
}
solver->model().beginReportStep();
solver_->model().beginReportStep();
bool enableTUNING = EWOMS_GET_PARAM(TypeTag, bool, EnableTuning);
// If sub stepping is enabled allow the solver to sub cycle
@ -398,13 +399,13 @@ public:
events.hasEvent(ScheduleEvents::INJECTION_TYPE_CHANGED) ||
events.hasEvent(ScheduleEvents::WELL_SWITCHED_INJECTOR_PRODUCER) ||
events.hasEvent(ScheduleEvents::WELL_STATUS_CHANGE);
auto stepReport = adaptiveTimeStepping_->step(timer, *solver, event, nullptr);
auto stepReport = adaptiveTimeStepping_->step(timer, *solver_, event, nullptr);
report_ += stepReport;
//Pass simulation report to eclwriter for summary output
ebosSimulator_.problem().setSimulationReport(report_);
} else {
// solve for complete report step
auto stepReport = solver->step(timer);
auto stepReport = solver_->step(timer);
report_ += stepReport;
if (terminalOutput_) {
std::ostringstream ss;
@ -421,7 +422,7 @@ public:
ebosSimulator_.problem().writeOutput();
report_.success.output_write_time += perfTimer.stop();
solver->model().endReportStep();
solver_->model().endReportStep();
// take time that was used to solve system for this reportStep
solverTimer_->stop();
@ -430,10 +431,10 @@ public:
report_.success.solver_time += solverTimer_->secsSinceStart();
if (this->grid().comm().rank() == 0) {
// Destructively grab the step convergence reports. The solver
// object and the model object contained therein are about to go
// out of scope.
this->writeConvergenceOutput(solver->model().getStepReportsDestructively());
// Grab the step convergence reports that are new since last we were here.
const auto& reps = solver_->model().stepReports();
this->writeConvergenceOutput(std::vector<StepReport>{reps.begin() + already_reported_steps_, reps.end()});
already_reported_steps_ = reps.size();
}
// Increment timer, remember well state.
@ -486,6 +487,9 @@ public:
serializer(adaptiveTimeStepping_);
}
const Model& model() const
{ return solver_->model(); }
protected:
std::unique_ptr<Solver> createSolver(WellModel& wellModel)
@ -702,12 +706,15 @@ protected:
ModelParameters modelParam_;
SolverParameters solverParam_;
std::unique_ptr<Solver> solver_;
// Observed objects.
PhaseUsage phaseUsage_;
// Misc. data
bool terminalOutput_;
SimulatorReport report_;
std::size_t already_reported_steps_ = 0;
std::unique_ptr<time::StopWatch> solverTimer_;
std::unique_ptr<time::StopWatch> totalTimer_;
std::unique_ptr<TimeStepper> adaptiveTimeStepping_;