mirror of
https://github.com/OPM/opm-simulators.git
synced 2026-10-04 13:16:46 -05:00
Merge pull request #1026 from andlaus/flow_ebos-sync-with-flow_legacy
Flow ebos sync with flow legacy
This commit is contained in:
commit
5955cb07ba
3 files changed
+67
-44
No files matched your search
@@ -120,6 +120,7 @@ namespace Opm {
|
||||
typedef typename TTAG(EclFlowProblem) TypeTag;
|
||||
typedef typename GET_PROP_TYPE(TypeTag, Simulator) Simulator ;
|
||||
typedef typename GET_PROP_TYPE(TypeTag, Grid) Grid;
|
||||
typedef typename GET_PROP_TYPE(TypeTag, ElementContext) ElementContext;
|
||||
typedef typename GET_PROP_TYPE(TypeTag, SolutionVector) SolutionVector ;
|
||||
typedef typename GET_PROP_TYPE(TypeTag, PrimaryVariables) PrimaryVariables ;
|
||||
typedef typename GET_PROP_TYPE(TypeTag, FluidSystem) FluidSystem;
|
||||
@@ -1000,21 +1001,33 @@ namespace Opm {
|
||||
fip_.fip[i].resize(nc,0.0);
|
||||
}
|
||||
|
||||
for (int c = 0; c < nc; ++c) {
|
||||
const auto& intQuants = *ebosSimulator_.model().cachedIntensiveQuantities(c, /*timeIdx=*/0);
|
||||
ElementContext elemCtx(ebosSimulator_);
|
||||
auto elemIt = elemCtx.gridView().template begin</*codim=*/0>();
|
||||
const auto& elemEndIt = elemCtx.gridView().template end</*codim=*/0>();
|
||||
for (; elemIt != elemEndIt; ++elemIt) {
|
||||
const auto& elem = *elemIt;
|
||||
if (elem.partitionType() != Dune::InteriorEntity) {
|
||||
continue;
|
||||
}
|
||||
|
||||
elemCtx.updatePrimaryStencil(elem);
|
||||
elemCtx.updatePrimaryIntensiveQuantities(/*timeIdx=*/0);
|
||||
|
||||
const unsigned cellIdx = elemCtx.globalSpaceIndex(/*spaceIdx=*/0, /*timeIdx=*/0);
|
||||
const auto& intQuants = elemCtx.intensiveQuantities(/*spaceIdx=*/0, /*timeIdx=*/0);
|
||||
const auto& fs = intQuants.fluidState();
|
||||
|
||||
for (int phase = 0; phase < maxnp; ++phase) {
|
||||
const double& b = fs.invB(flowPhaseToEbosPhaseIdx(phase)).value();
|
||||
const double& s = fs.saturation(flowPhaseToEbosPhaseIdx(phase)).value();
|
||||
const double b = fs.invB(flowPhaseToEbosPhaseIdx(phase)).value();
|
||||
const double s = fs.saturation(flowPhaseToEbosPhaseIdx(phase)).value();
|
||||
const double pv_mult = 1.0; //todo
|
||||
fip_.fip[phase][c] = pv_mult * b * s * pv[c];
|
||||
fip_.fip[phase][cellIdx] = pv_mult * b * s * pv[cellIdx];
|
||||
}
|
||||
|
||||
if (active_[ Oil ] && active_[ Gas ]) {
|
||||
// Account for gas dissolved in oil and vaporized oil
|
||||
fip_.fip[FIPData::FIP_DISSOLVED_GAS][c] = fs.Rs().value() * fip_.fip[FIPData::FIP_LIQUID][c];
|
||||
fip_.fip[FIPData::FIP_VAPORIZED_OIL][c] = fs.Rv().value() * fip_.fip[FIPData::FIP_VAPOUR][c];
|
||||
fip_.fip[FIPData::FIP_DISSOLVED_GAS][cellIdx] = fs.Rs().value() * fip_.fip[FIPData::FIP_LIQUID][cellIdx];
|
||||
fip_.fip[FIPData::FIP_VAPORIZED_OIL][cellIdx] = fs.Rv().value() * fip_.fip[FIPData::FIP_VAPOUR][cellIdx];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -157,24 +157,31 @@ public:
|
||||
std::string tstep_filename = output_writer_.outputDirectory() + "/step_timing.txt";
|
||||
std::ofstream tstep_os(tstep_filename.c_str());
|
||||
|
||||
const auto& schedule = eclState().getSchedule();
|
||||
|
||||
// adaptive time stepping
|
||||
std::unique_ptr< AdaptiveTimeStepping > adaptiveTimeStepping;
|
||||
if( param_.getDefault("timestep.adaptive", true ) )
|
||||
{
|
||||
adaptiveTimeStepping.reset( new AdaptiveTimeStepping( param_, terminal_output_ ) );
|
||||
|
||||
if (param_.getDefault("use_TUNING", false)) {
|
||||
adaptiveTimeStepping.reset( new AdaptiveTimeStepping( schedule.getTuning(), timer.currentStepNum(), param_, terminal_output_ ) );
|
||||
} else {
|
||||
adaptiveTimeStepping.reset( new AdaptiveTimeStepping( param_, terminal_output_ ) );
|
||||
}
|
||||
}
|
||||
|
||||
std::string restorefilename = param_.getDefault("restorefile", std::string("") );
|
||||
if( ! restorefilename.empty() )
|
||||
{
|
||||
// -1 means that we'll take the last report step that was written
|
||||
//const int desiredRestoreStep = param_.getDefault("restorestep", int(-1) );
|
||||
const int desiredRestoreStep = param_.getDefault("restorestep", int(-1) );
|
||||
|
||||
// output_writer_.restore( timer,
|
||||
// state,
|
||||
// prev_well_state,
|
||||
// restorefilename,
|
||||
// desiredRestoreStep );
|
||||
output_writer_.restore( timer,
|
||||
state,
|
||||
prev_well_state,
|
||||
restorefilename,
|
||||
desiredRestoreStep );
|
||||
}
|
||||
|
||||
bool is_well_potentials_computed = param_.getDefault("compute_well_potentials", false );
|
||||
@@ -195,7 +202,6 @@ public:
|
||||
}
|
||||
}
|
||||
std::vector<std::vector<double>> OOIP;
|
||||
|
||||
// Main simulation loop.
|
||||
while (!timer.done()) {
|
||||
// Report timestep.
|
||||
@@ -221,7 +227,6 @@ public:
|
||||
is_parallel_run_,
|
||||
well_potentials,
|
||||
defunct_well_names_ );
|
||||
|
||||
const Wells* wells = wells_manager.c_wells();
|
||||
WellState well_state;
|
||||
well_state.init(wells, state, prev_well_state, props_.phaseUsage());
|
||||
@@ -229,6 +234,18 @@ public:
|
||||
// give the polymer and surfactant simulators the chance to do their stuff
|
||||
handleAdditionalWellInflow(timer, wells_manager, well_state, wells);
|
||||
|
||||
// write the inital state at the report stage
|
||||
if (timer.initialStep()) {
|
||||
Dune::Timer perfTimer;
|
||||
perfTimer.start();
|
||||
|
||||
// No per cell data is written for initial step, but will be
|
||||
// for subsequent steps, when we have started simulating
|
||||
output_writer_.writeTimeStepWithoutCellProperties( timer, state, well_state );
|
||||
|
||||
report.output_write_time += perfTimer.stop();
|
||||
}
|
||||
|
||||
// Compute reservoir volumes for RESV controls.
|
||||
computeRESV(timer.currentStepNum(), wells, state, well_state);
|
||||
|
||||
@@ -239,28 +256,10 @@ public:
|
||||
|
||||
auto solver = createSolver(well_model);
|
||||
|
||||
// write the inital state at the report stage
|
||||
if (timer.initialStep()) {
|
||||
Dune::Timer perfTimer;
|
||||
perfTimer.start();
|
||||
|
||||
// make sure that the Intensive Quantities cache is up to date
|
||||
const auto& gridManager = ebosSimulator_.gridManager();
|
||||
const auto& gridView = gridManager.gridView();
|
||||
auto elemIt = gridView.template begin<0>();
|
||||
auto elemEndIt = gridView.template end<0>();
|
||||
ElementContext elemCtx(ebosSimulator_);
|
||||
for (; elemIt != elemEndIt; ++ elemIt) {
|
||||
elemCtx.updatePrimaryStencil(*elemIt);
|
||||
elemCtx.updatePrimaryIntensiveQuantities(/*timeIdx=*/0);
|
||||
}
|
||||
|
||||
// No per cell data is written for initial step, but will be
|
||||
// for subsequent steps, when we have started simulating
|
||||
output_writer_.writeTimeStepWithoutCellProperties( timer, state, well_state );
|
||||
|
||||
report.output_write_time += perfTimer.stop();
|
||||
}
|
||||
// make sure that the ebos side of the model is consistent with the reservoir
|
||||
// state object.
|
||||
solver->model().convertInput(/*iterationIdx=*/0, state, ebosSimulator_);
|
||||
ebosSimulator_.model().invalidateIntensiveQuantitiesCache(/*timeIdx=*/0);
|
||||
|
||||
// Compute orignal FIP;
|
||||
if (!ooip_computed) {
|
||||
@@ -274,12 +273,10 @@ public:
|
||||
std::ostringstream step_msg;
|
||||
boost::posix_time::time_facet* facet = new boost::posix_time::time_facet("%d-%b-%Y");
|
||||
step_msg.imbue(std::locale(std::locale::classic(), facet));
|
||||
step_msg << "\n"
|
||||
<< "Time step " << std::setw(4) <<timer.currentStepNum()
|
||||
step_msg << "\nTime step " << std::setw(4) <<timer.currentStepNum()
|
||||
<< " at day " << (double)unit::convert::to(timer.simulationTimeElapsed(), unit::day)
|
||||
<< "/" << (double)unit::convert::to(timer.totalTime(), unit::day)
|
||||
<< ", date = " << timer.currentDateTime()
|
||||
<< ", size = " << (double)unit::convert::to(timer.currentStepLength(), unit::day) << " days";
|
||||
<< ", date = " << timer.currentDateTime();
|
||||
OpmLog::info(step_msg.str());
|
||||
}
|
||||
|
||||
@@ -321,7 +318,7 @@ public:
|
||||
// update timing.
|
||||
report.solver_time += solver_timer.secsSinceStart();
|
||||
|
||||
// Compute current FIP.
|
||||
// Compute current fluid in place.
|
||||
std::vector<std::vector<double>> COIP;
|
||||
COIP = solver->computeFluidInPlace(fipnum);
|
||||
std::vector<double> OOIP_totals = FIPTotals(OOIP, state);
|
||||
@@ -331,7 +328,7 @@ public:
|
||||
FIPUnitConvert(eclState().getUnits(), OOIP_totals);
|
||||
FIPUnitConvert(eclState().getUnits(), COIP_totals);
|
||||
|
||||
if ( terminal_output_ )
|
||||
if (terminal_output_ )
|
||||
{
|
||||
outputFluidInPlace(OOIP_totals, COIP_totals,eclState().getUnits(), 0);
|
||||
for (size_t reg = 0; reg < OOIP.size(); ++reg) {
|
||||
@@ -345,6 +342,13 @@ public:
|
||||
OpmLog::note(msg);
|
||||
}
|
||||
|
||||
if ( output_writer_.output() ) {
|
||||
if ( output_writer_.isIORank() )
|
||||
{
|
||||
stepReport.reportParam(tstep_os);
|
||||
}
|
||||
}
|
||||
|
||||
// Increment timer, remember well state.
|
||||
++timer;
|
||||
|
||||
|
||||
@@ -128,6 +128,12 @@ namespace Opm
|
||||
/** \brief return true if output is enabled */
|
||||
bool output () const { return output_; }
|
||||
|
||||
/** \brief Whether this process does write to disk */
|
||||
bool isIORank () const
|
||||
{
|
||||
return parallelOutput_->isIORank();
|
||||
}
|
||||
|
||||
void restore(SimulatorTimerInterface& timer,
|
||||
BlackoilState& state,
|
||||
WellStateFullyImplicitBlackoilDense& wellState,
|
||||
|
||||
Reference in new issue
Block a user