flow: initialize the parameters for the material law only once

this saves some memory and some time at initialization.
This commit is contained in:
Andreas Lauser 2015-07-31 18:31:01 +02:00
parent 009ae54523
commit a394af6734
4 changed files with 43 additions and 8 deletions

View File

@ -251,15 +251,19 @@ try
const PhaseUsage pu = Opm::phaseUsageFromDeck(deck);
Opm::BlackoilOutputWriter outputWriter(grid, param, eclipseState, pu );
typedef BlackoilPropsAdFromDeck::MaterialLawManager MaterialLawManager;
auto materialLawManager = std::make_shared<MaterialLawManager>();
materialLawManager->initFromDeck(deck, eclipseState);
// Rock and fluid init
BlackoilPropertiesFromDeck props( deck, eclipseState,
BlackoilPropertiesFromDeck props( deck, eclipseState, materialLawManager,
Opm::UgGridHelpers::numCells(grid),
Opm::UgGridHelpers::globalCell(grid),
Opm::UgGridHelpers::cartDims(grid),
Opm::UgGridHelpers::beginCellCentroids(grid),
Opm::UgGridHelpers::dimensions(grid), param);
BlackoilPropsAdFromDeck new_props( deck, eclipseState, grid );
BlackoilPropsAdFromDeck new_props( deck, eclipseState, materialLawManager, grid );
// check_well_controls = param.getDefault("check_well_controls", false);
// max_well_control_iterations = param.getDefault("max_well_control_iterations", 10);
// Rock compressibility.

View File

@ -247,15 +247,31 @@ try
const PhaseUsage pu = Opm::phaseUsageFromDeck(deck);
Opm::BlackoilOutputWriter outputWriter(grid, param, eclipseState, pu );
int numCells = Opm::UgGridHelpers::numCells(grid);
const auto& globalCell = Opm::UgGridHelpers::globalCell(grid);
std::vector<int> compressedToCartesianIdx(numCells);
for (unsigned cellIdx = 0; cellIdx < numCells; ++cellIdx) {
if (globalCell) {
compressedToCartesianIdx[cellIdx] = globalCell[cellIdx];
}
else {
compressedToCartesianIdx[cellIdx] = cellIdx;
}
}
typedef BlackoilPropsAdFromDeck::MaterialLawManager MaterialLawManager;
auto materialLawManager = std::make_shared<MaterialLawManager>();
materialLawManager->initFromDeck(deck, eclipseState, compressedToCartesianIdx);
// Rock and fluid init
BlackoilPropertiesFromDeck props( deck, eclipseState,
BlackoilPropertiesFromDeck props( deck, eclipseState, materialLawManager,
Opm::UgGridHelpers::numCells(grid),
Opm::UgGridHelpers::globalCell(grid),
Opm::UgGridHelpers::cartDims(grid),
Opm::UgGridHelpers::beginCellCentroids(grid),
Opm::UgGridHelpers::dimensions(grid), param);
BlackoilPropsAdFromDeck new_props( deck, eclipseState, grid );
BlackoilPropsAdFromDeck new_props( deck, eclipseState, materialLawManager, grid );
SolventPropsAdFromDeck solvent_props( deck, eclipseState, Opm::UgGridHelpers::numCells(grid), Opm::UgGridHelpers::globalCell(grid));

View File

@ -50,10 +50,11 @@ namespace Opm
/// Constructor wrapping an opm-core black oil interface.
BlackoilPropsAdFromDeck::BlackoilPropsAdFromDeck(Opm::DeckConstPtr deck,
Opm::EclipseStateConstPtr eclState,
std::shared_ptr<MaterialLawManager> materialLawManager,
const UnstructuredGrid& grid,
const bool init_rock)
{
init(deck, eclState, grid.number_of_cells, grid.global_cell, grid.cartdims,
init(deck, eclState, materialLawManager, grid.number_of_cells, grid.global_cell, grid.cartdims,
grid.cell_centroids, grid.dimensions, init_rock);
}
@ -61,10 +62,11 @@ namespace Opm
/// Constructor wrapping an opm-core black oil interface.
BlackoilPropsAdFromDeck::BlackoilPropsAdFromDeck(Opm::DeckConstPtr deck,
Opm::EclipseStateConstPtr eclState,
std::shared_ptr<MaterialLawManager> materialLawManager,
const Dune::CpGrid& grid,
const bool init_rock )
{
init(deck, eclState, grid.numCells(), static_cast<const int*>(&grid.globalCell()[0]),
init(deck, eclState, materialLawManager, grid.numCells(), static_cast<const int*>(&grid.globalCell()[0]),
static_cast<const int*>(&grid.logicalCartesianSize()[0]),
grid.beginCellCentroids(), Dune::CpGrid::dimension, init_rock);
}
@ -81,6 +83,9 @@ BlackoilPropsAdFromDeck::BlackoilPropsAdFromDeck(const BlackoilPropsAdFromDeck&
if (number_of_cells < 0) {
OPM_THROW(std::runtime_error, "The number of cells is has to be larger than 0.");
}
materialLawManager_ = props.materialLawManager_;
// Copy properties that do not depend on the postion within the grid.
rock_ = props.rock_;
satprops_ = props.satprops_;
@ -99,6 +104,7 @@ BlackoilPropsAdFromDeck::BlackoilPropsAdFromDeck(const BlackoilPropsAdFromDeck&
template <class CentroidIterator>
void BlackoilPropsAdFromDeck::init(Opm::DeckConstPtr deck,
Opm::EclipseStateConstPtr eclState,
std::shared_ptr<MaterialLawManager> materialLawManager,
int number_of_cells,
const int* global_cell,
const int* cart_dims,
@ -106,6 +112,8 @@ BlackoilPropsAdFromDeck::BlackoilPropsAdFromDeck(const BlackoilPropsAdFromDeck&
int dimension,
const bool init_rock)
{
materialLawManager_ = materialLawManager;
// retrieve the cell specific PVT table index from the deck
// and using the grid...
extractPvtTableIndex(cellPvtRegionIdx_, deck, number_of_cells, global_cell);
@ -239,7 +247,7 @@ BlackoilPropsAdFromDeck::BlackoilPropsAdFromDeck(const BlackoilPropsAdFromDeck&
SaturationPropsFromDeck* ptr
= new SaturationPropsFromDeck();
satprops_.reset(ptr);
ptr->init(deck, eclState, number_of_cells, global_cell, begin_cell_centroids, dimension);
ptr->init(deck, eclState, materialLawManager_, number_of_cells, global_cell, begin_cell_centroids, dimension);
if (phase_usage_.num_phases != satprops_->numPhases()) {
OPM_THROW(std::runtime_error, "BlackoilPropsAdFromDeck::BlackoilPropsAdFromDeck() - "

View File

@ -59,9 +59,12 @@ namespace Opm
{
friend class BlackoilPropsDataHandle;
public:
typedef typename SaturationPropsFromDeck::MaterialLawManager MaterialLawManager;
/// Constructor wrapping an opm-core black oil interface.
BlackoilPropsAdFromDeck(Opm::DeckConstPtr deck,
Opm::EclipseStateConstPtr eclState,
std::shared_ptr<MaterialLawManager> materialLawManager,
const UnstructuredGrid& grid,
const bool init_rock = true );
@ -69,6 +72,7 @@ namespace Opm
/// Constructor wrapping an opm-core black oil interface.
BlackoilPropsAdFromDeck(Opm::DeckConstPtr deck,
Opm::EclipseStateConstPtr eclState,
std::shared_ptr<MaterialLawManager> materialLawManager,
const Dune::CpGrid& grid,
const bool init_rock = true );
#endif
@ -305,6 +309,7 @@ namespace Opm
template <class CentroidIterator>
void init(Opm::DeckConstPtr deck,
Opm::EclipseStateConstPtr eclState,
std::shared_ptr<MaterialLawManager> materialLawManager,
int number_of_cells,
const int* global_cell,
const int* cart_dims,
@ -327,9 +332,11 @@ namespace Opm
void mapPvtRegions(const std::vector<int>& cells) const;
RockFromDeck rock_;
// This has to be a shared pointer as we must
// be able to make a copy of *this in the parallel case.
std::shared_ptr<SaturationPropsInterface> satprops_;
std::shared_ptr<MaterialLawManager> materialLawManager_;
std::shared_ptr<SaturationPropsFromDeck> satprops_;
PhaseUsage phase_usage_;
// bool has_vapoil_;