diff --git a/opm/core/props/BlackoilPropertiesFromDeck.cpp b/opm/core/props/BlackoilPropertiesFromDeck.cpp index 012b276e1..8173a0e69 100644 --- a/opm/core/props/BlackoilPropertiesFromDeck.cpp +++ b/opm/core/props/BlackoilPropertiesFromDeck.cpp @@ -19,24 +19,40 @@ #include "config.h" #include +#include #include +#include +#include namespace Opm { + + namespace + { + // Construct explicit mapping from active/compressed to logical cartesian + // indices, either as given in global_cell or as { 0, 1, 2, ....} if null. + std::vector compressedToCartesian(const int num_cells, + const int* global_cell) + { + std::vector retval; + if (global_cell) { + retval.assign(global_cell, global_cell + num_cells); + } else { + retval.resize(num_cells); + std::iota(retval.begin(), retval.end(), 0); + } + return retval; + } + } // anonymous namespace + + BlackoilPropertiesFromDeck::BlackoilPropertiesFromDeck(Opm::DeckConstPtr deck, Opm::EclipseStateConstPtr eclState, const UnstructuredGrid& grid, bool init_rock) { - std::vector compressedToCartesianIdx(grid.number_of_cells); - for (int cellIdx = 0; cellIdx < grid.number_of_cells; ++cellIdx) { - if (grid.global_cell) { - compressedToCartesianIdx[cellIdx] = grid.global_cell[cellIdx]; - } - else { - compressedToCartesianIdx[cellIdx] = cellIdx; - } - } + std::vector compressedToCartesianIdx + = compressedToCartesian(grid.number_of_cells, grid.global_cell); auto materialLawManager = std::make_shared(); materialLawManager->initFromDeck(deck, eclState, compressedToCartesianIdx); @@ -51,15 +67,8 @@ namespace Opm const parameter::ParameterGroup& param, bool init_rock) { - std::vector compressedToCartesianIdx(grid.number_of_cells); - for (int cellIdx = 0; cellIdx < grid.number_of_cells; ++cellIdx) { - if (grid.global_cell) { - compressedToCartesianIdx[cellIdx] = grid.global_cell[cellIdx]; - } - else { - compressedToCartesianIdx[cellIdx] = cellIdx; - } - } + std::vector compressedToCartesianIdx + = compressedToCartesian(grid.number_of_cells, grid.global_cell); auto materialLawManager = std::make_shared(); materialLawManager->initFromDeck(deck, eclState, compressedToCartesianIdx); @@ -74,15 +83,9 @@ namespace Opm const int* cart_dims, bool init_rock) { - std::vector compressedToCartesianIdx(number_of_cells); - for (int cellIdx = 0; cellIdx < number_of_cells; ++cellIdx) { - if (global_cell) { - compressedToCartesianIdx[cellIdx] = global_cell[cellIdx]; - } - else { - compressedToCartesianIdx[cellIdx] = cellIdx; - } - } + std::vector compressedToCartesianIdx + = compressedToCartesian(number_of_cells, global_cell); + auto materialLawManager = std::make_shared(); materialLawManager->initFromDeck(deck, eclState, compressedToCartesianIdx); @@ -98,15 +101,9 @@ namespace Opm const parameter::ParameterGroup& param, bool init_rock) { - std::vector compressedToCartesianIdx(number_of_cells); - for (int cellIdx = 0; cellIdx < number_of_cells; ++cellIdx) { - if (global_cell) { - compressedToCartesianIdx[cellIdx] = global_cell[cellIdx]; - } - else { - compressedToCartesianIdx[cellIdx] = cellIdx; - } - } + std::vector compressedToCartesianIdx + = compressedToCartesian(number_of_cells, global_cell); + auto materialLawManager = std::make_shared(); materialLawManager->initFromDeck(deck, eclState, compressedToCartesianIdx); diff --git a/opm/core/props/BlackoilPropertiesFromDeck.hpp b/opm/core/props/BlackoilPropertiesFromDeck.hpp index c45ff7011..3aaa601ce 100644 --- a/opm/core/props/BlackoilPropertiesFromDeck.hpp +++ b/opm/core/props/BlackoilPropertiesFromDeck.hpp @@ -27,8 +27,6 @@ #include #include -#include - #include #include diff --git a/opm/core/props/IncompPropertiesFromDeck.cpp b/opm/core/props/IncompPropertiesFromDeck.cpp index c7d8593b7..5a29fbd25 100644 --- a/opm/core/props/IncompPropertiesFromDeck.cpp +++ b/opm/core/props/IncompPropertiesFromDeck.cpp @@ -20,6 +20,7 @@ #include "config.h" #include +#include #include #include #include @@ -45,7 +46,7 @@ namespace Opm } materialLawManager->initFromDeck(deck, eclState, compressedToCartesianIdx); - satprops_.init(deck, eclState, materialLawManager, grid); + satprops_.init(deck, materialLawManager); if (pvt_.numPhases() != satprops_.numPhases()) { OPM_THROW(std::runtime_error, "IncompPropertiesFromDeck::IncompPropertiesFromDeck() - Inconsistent number of phases in pvt data (" << pvt_.numPhases() << ") and saturation-dependent function data (" << satprops_.numPhases() << ")."); diff --git a/opm/core/props/satfunc/SaturationPropsFromDeck.cpp b/opm/core/props/satfunc/SaturationPropsFromDeck.cpp index 8bc8bf64e..769ad0325 100644 --- a/opm/core/props/satfunc/SaturationPropsFromDeck.cpp +++ b/opm/core/props/satfunc/SaturationPropsFromDeck.cpp @@ -18,6 +18,10 @@ */ #include "config.h" +#include + +#include + #include #include #include @@ -30,11 +34,10 @@ #include #include -#include "SaturationPropsFromDeck.hpp" - namespace Opm { + typedef SaturationPropsFromDeck::MaterialLawManager::MaterialLaw MaterialLaw; // ----------- Methods of SaturationPropsFromDeck --------- @@ -44,17 +47,6 @@ namespace Opm { } - /// Initialize from deck. - void SaturationPropsFromDeck::init(Opm::DeckConstPtr deck, - Opm::EclipseStateConstPtr eclipseState, - std::shared_ptr materialLawManager, - const UnstructuredGrid& grid) - { - this->init(deck, eclipseState, materialLawManager, grid.number_of_cells, - grid.global_cell, grid.cell_centroids, - grid.dimensions); - } - /// Initialize from deck. void SaturationPropsFromDeck::init(const PhaseUsage &phaseUsage, std::shared_ptr materialLawManager) diff --git a/opm/core/props/satfunc/SaturationPropsFromDeck.hpp b/opm/core/props/satfunc/SaturationPropsFromDeck.hpp index 756f6d698..127700fd6 100644 --- a/opm/core/props/satfunc/SaturationPropsFromDeck.hpp +++ b/opm/core/props/satfunc/SaturationPropsFromDeck.hpp @@ -29,14 +29,20 @@ #include #include -#include - #include struct UnstructuredGrid; namespace Opm { + + // Forward declaring the EclMaterialLawManager template. + template + class ThreePhaseMaterialTraits; + template + class EclMaterialLawManager; + + /// Interface to saturation functions from deck. class SaturationPropsFromDeck : public SaturationPropsInterface { @@ -46,47 +52,22 @@ namespace Opm /*nonWettingPhaseIdx=*/BlackoilPhases::Liquid, /*gasPhaseIdx=*/BlackoilPhases::Vapour> MaterialTraits; typedef Opm::EclMaterialLawManager MaterialLawManager; - typedef MaterialLawManager::MaterialLaw MaterialLaw; - typedef MaterialLawManager::MaterialLawParams MaterialLawParams; /// Default constructor. SaturationPropsFromDeck(); - /// Initialize from a MaterialLawManager object and a compressed to cartesian cell index map. + /// Initialize from a MaterialLawManager object. + /// \param[in] phaseUsage Phase configuration /// \param[in] materialLawManager An initialized MaterialLawManager object - void init(const PhaseUsage &phaseUsage, + void init(const PhaseUsage& phaseUsage, std::shared_ptr materialLawManager); - /// Initialize from deck and grid. - /// \param[in] deck Deck input parser - /// \param[in] grid Grid to which property object applies, needed for the - /// mapping from cell indices (typically from a processed grid) - /// to logical cartesian indices consistent with the deck. + /// Initialize from deck and MaterialLawManager. + /// \param[in] deck Input deck + /// \param[in] materialLawManager An initialized MaterialLawManager object void init(Opm::DeckConstPtr deck, - Opm::EclipseStateConstPtr eclipseState, - std::shared_ptr materialLawManager, - const UnstructuredGrid& grid); - - /// Initialize from deck and grid. - /// \param[in] deck Deck input parser - /// \param[in] number_of_cells The number of cells of the grid to which property - /// object applies, needed for the - /// mapping from cell indices (typically from a processed - /// grid) to logical cartesian indices consistent with the - /// deck. - /// \param[in] global_cell The mapping from local cell indices of the grid to - /// global cell indices used in the deck. - /// \param[in] begin_cell_centroids Pointer to the first cell_centroid of the grid. - /// \param[in] dimensions The dimensions of the grid. - template - void init(Opm::DeckConstPtr deck, - Opm::EclipseStateConstPtr eclipseState, - std::shared_ptr materialLawManager, - int number_of_cells, - const int* global_cell, - const T& begin_cell_centroids, - int dimensions) + std::shared_ptr materialLawManager) { init(Opm::phaseUsageFromDeck(deck), materialLawManager); }