mirror of
https://github.com/OPM/opm-simulators.git
synced 2025-02-25 18:55:30 -06:00
Replaced SimulatorState -> SimulationDatacontainer
Have removed the SimulatorState base class, and instead replaced with the SimulationDatacontainer class from opm-common. The SimulatorState objects were typcially created with a default constructor, and then explicitly initialized with a SimulatorState::init() method. For the SimulationDataContainer RAII is employed; the init( ) has been removed - and there is no default constructor.
This commit is contained in:
parent
dcd12f052a
commit
38628de09e
@ -25,6 +25,7 @@
|
|||||||
|
|
||||||
#include <opm/core/grid.h>
|
#include <opm/core/grid.h>
|
||||||
#include <opm/core/grid/GridManager.hpp>
|
#include <opm/core/grid/GridManager.hpp>
|
||||||
|
#include <opm/core/grid/GridHelpers.hpp>
|
||||||
#include <opm/core/wells.h>
|
#include <opm/core/wells.h>
|
||||||
#include <opm/core/wells/WellsManager.hpp>
|
#include <opm/core/wells/WellsManager.hpp>
|
||||||
#include <opm/common/ErrorMacros.hpp>
|
#include <opm/common/ErrorMacros.hpp>
|
||||||
@ -89,11 +90,12 @@ try
|
|||||||
std::unique_ptr<GridManager> grid;
|
std::unique_ptr<GridManager> grid;
|
||||||
std::unique_ptr<BlackoilPropertiesInterface> props;
|
std::unique_ptr<BlackoilPropertiesInterface> props;
|
||||||
std::unique_ptr<RockCompressibility> rock_comp;
|
std::unique_ptr<RockCompressibility> rock_comp;
|
||||||
|
std::unique_ptr<BlackoilState> state;
|
||||||
|
|
||||||
|
|
||||||
ParserPtr parser(new Opm::Parser());
|
ParserPtr parser(new Opm::Parser());
|
||||||
Opm::DeckConstPtr deck;
|
Opm::DeckConstPtr deck;
|
||||||
|
|
||||||
BlackoilState state;
|
|
||||||
// bool check_well_controls = false;
|
// bool check_well_controls = false;
|
||||||
// int max_well_control_iterations = 0;
|
// int max_well_control_iterations = 0;
|
||||||
double gravity[3] = { 0.0 };
|
double gravity[3] = { 0.0 };
|
||||||
@ -105,8 +107,11 @@ try
|
|||||||
|
|
||||||
// Grid init
|
// Grid init
|
||||||
grid.reset(new GridManager(deck));
|
grid.reset(new GridManager(deck));
|
||||||
|
{
|
||||||
|
const UnstructuredGrid& ug_grid = *(grid->c_grid());
|
||||||
|
state.reset( new BlackoilState( UgGridHelpers::numCells( ug_grid ) , UgGridHelpers::numFaces( ug_grid ) ,2));
|
||||||
// Rock and fluid init
|
// Rock and fluid init
|
||||||
props.reset(new BlackoilPropertiesFromDeck(deck, eclipseState, *grid->c_grid(), param));
|
props.reset(new BlackoilPropertiesFromDeck(deck, eclipseState, ug_grid, param));
|
||||||
// check_well_controls = param.getDefault("check_well_controls", false);
|
// check_well_controls = param.getDefault("check_well_controls", false);
|
||||||
// max_well_control_iterations = param.getDefault("max_well_control_iterations", 10);
|
// max_well_control_iterations = param.getDefault("max_well_control_iterations", 10);
|
||||||
// Rock compressibility.
|
// Rock compressibility.
|
||||||
@ -115,11 +120,12 @@ try
|
|||||||
gravity[2] = deck->hasKeyword("NOGRAV") ? 0.0 : unit::gravity;
|
gravity[2] = deck->hasKeyword("NOGRAV") ? 0.0 : unit::gravity;
|
||||||
// Init state variables (saturation and pressure).
|
// Init state variables (saturation and pressure).
|
||||||
if (param.has("init_saturation")) {
|
if (param.has("init_saturation")) {
|
||||||
initStateBasic(*grid->c_grid(), *props, param, gravity[2], state);
|
initStateBasic(ug_grid, *props, param, gravity[2], *state);
|
||||||
} else {
|
} else {
|
||||||
initStateFromDeck(*grid->c_grid(), *props, deck, gravity[2], state);
|
initStateFromDeck(ug_grid, *props, deck, gravity[2], *state);
|
||||||
|
}
|
||||||
|
initBlackoilSurfvol(ug_grid, *props, *state);
|
||||||
}
|
}
|
||||||
initBlackoilSurfvol(*grid->c_grid(), *props, state);
|
|
||||||
} else {
|
} else {
|
||||||
// Grid init.
|
// Grid init.
|
||||||
const int nx = param.getDefault("nx", 100);
|
const int nx = param.getDefault("nx", 100);
|
||||||
@ -129,15 +135,22 @@ try
|
|||||||
const double dy = param.getDefault("dy", 1.0);
|
const double dy = param.getDefault("dy", 1.0);
|
||||||
const double dz = param.getDefault("dz", 1.0);
|
const double dz = param.getDefault("dz", 1.0);
|
||||||
grid.reset(new GridManager(nx, ny, nz, dx, dy, dz));
|
grid.reset(new GridManager(nx, ny, nz, dx, dy, dz));
|
||||||
|
{
|
||||||
|
const UnstructuredGrid& ug_grid = *(grid->c_grid());
|
||||||
// Rock and fluid init.
|
// Rock and fluid init.
|
||||||
props.reset(new BlackoilPropertiesBasic(param, grid->c_grid()->dimensions, grid->c_grid()->number_of_cells));
|
props.reset(new BlackoilPropertiesBasic(param, ug_grid.dimensions, UgGridHelpers::numCells( ug_grid )));
|
||||||
|
|
||||||
|
// State init
|
||||||
|
state.reset( new BlackoilState( UgGridHelpers::numCells( ug_grid ) , UgGridHelpers::numFaces( ug_grid ), 3));
|
||||||
// Rock compressibility.
|
// Rock compressibility.
|
||||||
rock_comp.reset(new RockCompressibility(param));
|
rock_comp.reset(new RockCompressibility(param));
|
||||||
|
|
||||||
// Gravity.
|
// Gravity.
|
||||||
gravity[2] = param.getDefault("gravity", 0.0);
|
gravity[2] = param.getDefault("gravity", 0.0);
|
||||||
// Init state variables (saturation and pressure).
|
// Init state variables (saturation and pressure).
|
||||||
initStateBasic(*grid->c_grid(), *props, param, gravity[2], state);
|
initStateBasic(ug_grid, *props, param, gravity[2], *state);
|
||||||
initBlackoilSurfvol(*grid->c_grid(), *props, state);
|
initBlackoilSurfvol(ug_grid, *props, *state);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool use_gravity = (gravity[0] != 0.0 || gravity[1] != 0.0 || gravity[2] != 0.0);
|
bool use_gravity = (gravity[0] != 0.0 || gravity[1] != 0.0 || gravity[2] != 0.0);
|
||||||
@ -153,7 +166,7 @@ try
|
|||||||
// terms of total pore volume.
|
// terms of total pore volume.
|
||||||
std::vector<double> porevol;
|
std::vector<double> porevol;
|
||||||
if (rock_comp->isActive()) {
|
if (rock_comp->isActive()) {
|
||||||
computePorevolume(*grid->c_grid(), props->porosity(), *rock_comp, state.pressure(), porevol);
|
computePorevolume(*grid->c_grid(), props->porosity(), *rock_comp, state->pressure(), porevol);
|
||||||
} else {
|
} else {
|
||||||
computePorevolume(*grid->c_grid(), props->porosity(), porevol);
|
computePorevolume(*grid->c_grid(), props->porosity(), porevol);
|
||||||
}
|
}
|
||||||
@ -219,8 +232,8 @@ try
|
|||||||
simtimer.init(param);
|
simtimer.init(param);
|
||||||
warnIfUnusedParams(param);
|
warnIfUnusedParams(param);
|
||||||
WellState well_state;
|
WellState well_state;
|
||||||
well_state.init(0, state);
|
well_state.init(0, *state);
|
||||||
rep = simulator.run(simtimer, state, well_state);
|
rep = simulator.run(simtimer, *state, well_state);
|
||||||
} else {
|
} else {
|
||||||
// With a deck, we may have more epochs etc.
|
// With a deck, we may have more epochs etc.
|
||||||
WellState well_state;
|
WellState well_state;
|
||||||
@ -245,7 +258,7 @@ try
|
|||||||
// properly transfer old well state to it every report step,
|
// properly transfer old well state to it every report step,
|
||||||
// since number of wells may change etc.
|
// since number of wells may change etc.
|
||||||
if (reportStepIdx == 0) {
|
if (reportStepIdx == 0) {
|
||||||
well_state.init(wells.c_wells(), state);
|
well_state.init(wells.c_wells(), *state);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create and run simulator.
|
// Create and run simulator.
|
||||||
@ -261,7 +274,7 @@ try
|
|||||||
if (reportStepIdx == 0) {
|
if (reportStepIdx == 0) {
|
||||||
warnIfUnusedParams(param);
|
warnIfUnusedParams(param);
|
||||||
}
|
}
|
||||||
SimulatorReport epoch_rep = simulator.run(simtimer, state, well_state);
|
SimulatorReport epoch_rep = simulator.run(simtimer, *state, well_state);
|
||||||
if (output) {
|
if (output) {
|
||||||
epoch_rep.reportParam(epoch_os);
|
epoch_rep.reportParam(epoch_os);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user