Merge pull request #879 from atgeirr/remove-args

Remove arguments from BlackoilPropertiesFromDeck constructors.
This commit is contained in:
Bård Skaflestad committed 2015-09-14 17:07:37 +02:00
commit f8e1526903
7 files changed
+176 -249

No files matched your search

-1
View File
@@ -339,7 +339,6 @@ list (APPEND PUBLIC_HEADER_FILES
opm/core/props/BlackoilPhases.hpp
opm/core/props/BlackoilPropertiesBasic.hpp
opm/core/props/BlackoilPropertiesFromDeck.hpp
opm/core/props/BlackoilPropertiesFromDeck_impl.hpp
opm/core/props/BlackoilPropertiesInterface.hpp
opm/core/props/IncompPropertiesBasic.hpp
opm/core/props/IncompPropertiesFromDeck.hpp
+153 -21
View File
@@ -19,30 +19,46 @@
#include "config.h"
#include <opm/core/props/BlackoilPropertiesFromDeck.hpp>
#include <opm/material/fluidmatrixinteractions/EclMaterialLawManager.hpp>
#include <opm/core/utility/parameters/ParameterGroup.hpp>
#include <vector>
#include <numeric>
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<int> compressedToCartesian(const int num_cells,
const int* global_cell)
{
std::vector<int> 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<int> 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<int> compressedToCartesianIdx
= compressedToCartesian(grid.number_of_cells, grid.global_cell);
auto materialLawManager = std::make_shared<MaterialLawManager>();
materialLawManager->initFromDeck(deck, eclState, compressedToCartesianIdx);
init(deck, eclState, materialLawManager, grid.number_of_cells, grid.global_cell, grid.cartdims,
grid.cell_centroids, grid.dimensions, init_rock);
init_rock);
}
BlackoilPropertiesFromDeck::BlackoilPropertiesFromDeck(Opm::DeckConstPtr deck,
@@ -51,21 +67,137 @@ namespace Opm
const parameter::ParameterGroup& param,
bool init_rock)
{
std::vector<int> 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<int> compressedToCartesianIdx
= compressedToCartesian(grid.number_of_cells, grid.global_cell);
auto materialLawManager = std::make_shared<MaterialLawManager>();
materialLawManager->initFromDeck(deck, eclState, compressedToCartesianIdx);
init(deck, eclState, materialLawManager, grid.number_of_cells, grid.global_cell, grid.cartdims, grid.cell_centroids,
grid.dimensions, param, init_rock);
init(deck, eclState, materialLawManager, grid.number_of_cells, grid.global_cell, grid.cartdims, param, init_rock);
}
BlackoilPropertiesFromDeck::BlackoilPropertiesFromDeck(Opm::DeckConstPtr deck,
Opm::EclipseStateConstPtr eclState,
int number_of_cells,
const int* global_cell,
const int* cart_dims,
bool init_rock)
{
std::vector<int> compressedToCartesianIdx
= compressedToCartesian(number_of_cells, global_cell);
auto materialLawManager = std::make_shared<MaterialLawManager>();
materialLawManager->initFromDeck(deck, eclState, compressedToCartesianIdx);
init(deck, eclState, materialLawManager, number_of_cells, global_cell, cart_dims,
init_rock);
}
BlackoilPropertiesFromDeck::BlackoilPropertiesFromDeck(Opm::DeckConstPtr deck,
Opm::EclipseStateConstPtr eclState,
int number_of_cells,
const int* global_cell,
const int* cart_dims,
const parameter::ParameterGroup& param,
bool init_rock)
{
std::vector<int> compressedToCartesianIdx
= compressedToCartesian(number_of_cells, global_cell);
auto materialLawManager = std::make_shared<MaterialLawManager>();
materialLawManager->initFromDeck(deck, eclState, compressedToCartesianIdx);
init(deck,
eclState,
materialLawManager,
number_of_cells,
global_cell,
cart_dims,
param,
init_rock);
}
BlackoilPropertiesFromDeck::BlackoilPropertiesFromDeck(Opm::DeckConstPtr deck,
Opm::EclipseStateConstPtr eclState,
std::shared_ptr<MaterialLawManager> materialLawManager,
int number_of_cells,
const int* global_cell,
const int* cart_dims,
const parameter::ParameterGroup& param,
bool init_rock)
{
init(deck,
eclState,
materialLawManager,
number_of_cells,
global_cell,
cart_dims,
param,
init_rock);
}
inline void BlackoilPropertiesFromDeck::init(Opm::DeckConstPtr deck,
Opm::EclipseStateConstPtr eclState,
std::shared_ptr<MaterialLawManager> materialLawManager,
int number_of_cells,
const int* global_cell,
const int* cart_dims,
bool init_rock)
{
// retrieve the cell specific PVT table index from the deck
// and using the grid...
extractPvtTableIndex(cellPvtRegionIdx_, deck, number_of_cells, global_cell);
if (init_rock){
rock_.init(eclState, number_of_cells, global_cell, cart_dims);
}
pvt_.init(deck, eclState, /*numSamples=*/0);
SaturationPropsFromDeck* ptr
= new SaturationPropsFromDeck();
ptr->init(phaseUsageFromDeck(deck), materialLawManager);
satprops_.reset(ptr);
if (pvt_.numPhases() != satprops_->numPhases()) {
OPM_THROW(std::runtime_error, "BlackoilPropertiesFromDeck::BlackoilPropertiesFromDeck() - Inconsistent number of phases in pvt data ("
<< pvt_.numPhases() << ") and saturation-dependent function data (" << satprops_->numPhases() << ").");
}
}
inline void BlackoilPropertiesFromDeck::init(Opm::DeckConstPtr deck,
Opm::EclipseStateConstPtr eclState,
std::shared_ptr<MaterialLawManager> materialLawManager,
int number_of_cells,
const int* global_cell,
const int* cart_dims,
const parameter::ParameterGroup& param,
bool init_rock)
{
// retrieve the cell specific PVT table index from the deck
// and using the grid...
extractPvtTableIndex(cellPvtRegionIdx_, deck, number_of_cells, global_cell);
if(init_rock){
rock_.init(eclState, number_of_cells, global_cell, cart_dims);
}
const int pvt_samples = param.getDefault("pvt_tab_size", -1);
pvt_.init(deck, eclState, pvt_samples);
// Unfortunate lack of pointer smartness here...
std::string threephase_model = param.getDefault<std::string>("threephase_model", "gwseg");
if (deck->hasKeyword("ENDSCALE") && threephase_model != "gwseg") {
OPM_THROW(std::runtime_error, "Sorry, end point scaling currently available for the 'gwseg' model only.");
}
SaturationPropsFromDeck* ptr
= new SaturationPropsFromDeck();
ptr->init(phaseUsageFromDeck(deck), materialLawManager);
satprops_.reset(ptr);
if (pvt_.numPhases() != satprops_->numPhases()) {
OPM_THROW(std::runtime_error, "BlackoilPropertiesFromDeck::BlackoilPropertiesFromDeck() - Inconsistent number of phases in pvt data ("
<< pvt_.numPhases() << ") and saturation-dependent function data (" << satprops_->numPhases() << ").");
}
}
BlackoilPropertiesFromDeck::~BlackoilPropertiesFromDeck()
+1 -19
View File
@@ -27,8 +27,6 @@
#include <opm/core/props/satfunc/SaturationPropsFromDeck.hpp>
#include <opm/core/utility/parameters/ParameterGroup.hpp>
#include <opm/material/fluidmatrixinteractions/EclMaterialLawManager.hpp>
#include <opm/parser/eclipse/Deck/Deck.hpp>
#include <memory>
@@ -71,36 +69,27 @@ namespace Opm
const parameter::ParameterGroup& param,
bool init_rock=true);
template<class CentroidIterator>
BlackoilPropertiesFromDeck(Opm::DeckConstPtr deck,
Opm::EclipseStateConstPtr eclState,
int number_of_cells,
const int* global_cell,
const int* cart_dims,
const CentroidIterator& begin_cell_centroids,
int dimension,
bool init_rock=true);
template<class CentroidIterator>
BlackoilPropertiesFromDeck(Opm::DeckConstPtr deck,
Opm::EclipseStateConstPtr eclState,
int number_of_cells,
const int* global_cell,
const int* cart_dims,
const CentroidIterator& begin_cell_centroids,
int dimension,
const parameter::ParameterGroup& param,
bool init_rock=true);
template<class CentroidIterator>
BlackoilPropertiesFromDeck(Opm::DeckConstPtr deck,
Opm::EclipseStateConstPtr eclState,
std::shared_ptr<MaterialLawManager> materialLawManager,
int number_of_cells,
const int* global_cell,
const int* cart_dims,
const CentroidIterator& begin_cell_centroids,
int dimension,
const parameter::ParameterGroup& param,
bool init_rock=true);
@@ -252,25 +241,20 @@ namespace Opm
return pvtTableIdx[cellIdx];
}
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,
const CentroidIterator& begin_cell_centroids,
int dimension,
bool init_rock);
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,
const CentroidIterator& begin_cell_centroids,
int dimension,
const parameter::ParameterGroup& param,
bool init_rock);
@@ -289,6 +273,4 @@ namespace Opm
} // namespace Opm
#include "BlackoilPropertiesFromDeck_impl.hpp"
#endif // OPM_BLACKOILPROPERTIESFROMDECK_HEADER_INCLUDED
@@ -1,160 +0,0 @@
#include <memory>
namespace Opm
{
template<class CentroidIterator>
BlackoilPropertiesFromDeck::BlackoilPropertiesFromDeck(Opm::DeckConstPtr deck,
Opm::EclipseStateConstPtr eclState,
int number_of_cells,
const int* global_cell,
const int* cart_dims,
const CentroidIterator& begin_cell_centroids,
int dimension,
bool init_rock)
{
std::vector<int> 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;
}
}
auto materialLawManager = std::make_shared<MaterialLawManager>();
materialLawManager->initFromDeck(deck, eclState, compressedToCartesianIdx);
init(deck, eclState, materialLawManager, number_of_cells, global_cell, cart_dims, begin_cell_centroids, dimension,
init_rock);
}
template<class CentroidIterator>
BlackoilPropertiesFromDeck::BlackoilPropertiesFromDeck(Opm::DeckConstPtr deck,
Opm::EclipseStateConstPtr eclState,
int number_of_cells,
const int* global_cell,
const int* cart_dims,
const CentroidIterator& begin_cell_centroids,
int dimension,
const parameter::ParameterGroup& param,
bool init_rock)
{
std::vector<int> 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;
}
}
auto materialLawManager = std::make_shared<MaterialLawManager>();
materialLawManager->initFromDeck(deck, eclState, compressedToCartesianIdx);
init(deck,
eclState,
materialLawManager,
number_of_cells,
global_cell,
cart_dims,
begin_cell_centroids,
dimension,
param,
init_rock);
}
template<class CentroidIterator>
BlackoilPropertiesFromDeck::BlackoilPropertiesFromDeck(Opm::DeckConstPtr deck,
Opm::EclipseStateConstPtr eclState,
std::shared_ptr<MaterialLawManager> materialLawManager,
int number_of_cells,
const int* global_cell,
const int* cart_dims,
const CentroidIterator& begin_cell_centroids,
int dimension,
const parameter::ParameterGroup& param,
bool init_rock)
{
init(deck,
eclState,
materialLawManager,
number_of_cells,
global_cell,
cart_dims,
begin_cell_centroids,
dimension,
param,
init_rock);
}
template<class CentroidIterator>
inline void BlackoilPropertiesFromDeck::init(Opm::DeckConstPtr deck,
Opm::EclipseStateConstPtr eclState,
std::shared_ptr<MaterialLawManager> materialLawManager,
int number_of_cells,
const int* global_cell,
const int* cart_dims,
const CentroidIterator& begin_cell_centroids,
int dimension,
bool init_rock)
{
// retrieve the cell specific PVT table index from the deck
// and using the grid...
extractPvtTableIndex(cellPvtRegionIdx_, deck, number_of_cells, global_cell);
if (init_rock){
rock_.init(eclState, number_of_cells, global_cell, cart_dims);
}
pvt_.init(deck, eclState, /*numSamples=*/0);
SaturationPropsFromDeck* ptr
= new SaturationPropsFromDeck();
ptr->init(phaseUsageFromDeck(deck), materialLawManager);
satprops_.reset(ptr);
if (pvt_.numPhases() != satprops_->numPhases()) {
OPM_THROW(std::runtime_error, "BlackoilPropertiesFromDeck::BlackoilPropertiesFromDeck() - Inconsistent number of phases in pvt data ("
<< pvt_.numPhases() << ") and saturation-dependent function data (" << satprops_->numPhases() << ").");
}
}
template<class CentroidIterator>
inline void BlackoilPropertiesFromDeck::init(Opm::DeckConstPtr deck,
Opm::EclipseStateConstPtr eclState,
std::shared_ptr<MaterialLawManager> materialLawManager,
int number_of_cells,
const int* global_cell,
const int* cart_dims,
const CentroidIterator& begin_cell_centroids,
int dimension,
const parameter::ParameterGroup& param,
bool init_rock)
{
// retrieve the cell specific PVT table index from the deck
// and using the grid...
extractPvtTableIndex(cellPvtRegionIdx_, deck, number_of_cells, global_cell);
if(init_rock){
rock_.init(eclState, number_of_cells, global_cell, cart_dims);
}
const int pvt_samples = param.getDefault("pvt_tab_size", -1);
pvt_.init(deck, eclState, pvt_samples);
// Unfortunate lack of pointer smartness here...
std::string threephase_model = param.getDefault<std::string>("threephase_model", "gwseg");
if (deck->hasKeyword("ENDSCALE") && threephase_model != "gwseg") {
OPM_THROW(std::runtime_error, "Sorry, end point scaling currently available for the 'gwseg' model only.");
}
SaturationPropsFromDeck* ptr
= new SaturationPropsFromDeck();
ptr->init(phaseUsageFromDeck(deck), materialLawManager);
satprops_.reset(ptr);
if (pvt_.numPhases() != satprops_->numPhases()) {
OPM_THROW(std::runtime_error, "BlackoilPropertiesFromDeck::BlackoilPropertiesFromDeck() - Inconsistent number of phases in pvt data ("
<< pvt_.numPhases() << ") and saturation-dependent function data (" << satprops_->numPhases() << ").");
}
}
}
+2 -1
View File
@@ -20,6 +20,7 @@
#include "config.h"
#include <opm/core/props/IncompPropertiesFromDeck.hpp>
#include <opm/material/fluidmatrixinteractions/EclMaterialLawManager.hpp>
#include <opm/core/utility/Units.hpp>
#include <opm/core/utility/ErrorMacros.hpp>
#include <iostream>
@@ -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() << ").");
@@ -18,6 +18,10 @@
*/
#include "config.h"
#include <opm/core/props/satfunc/SaturationPropsFromDeck.hpp>
#include <opm/material/fluidmatrixinteractions/EclMaterialLawManager.hpp>
#include <opm/core/utility/UniformTableLinear.hpp>
#include <opm/core/utility/NonuniformTableLinear.hpp>
#include <opm/core/grid/GridHelpers.hpp>
@@ -30,11 +34,10 @@
#include <iostream>
#include <map>
#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> 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> materialLawManager)
@@ -29,14 +29,20 @@
#include <opm/parser/eclipse/Deck/Deck.hpp>
#include <opm/parser/eclipse/EclipseState/EclipseState.hpp>
#include <opm/material/fluidmatrixinteractions/EclMaterialLawManager.hpp>
#include <vector>
struct UnstructuredGrid;
namespace Opm
{
// Forward declaring the EclMaterialLawManager template.
template <class ScalarT, int wettingPhaseIdxV, int nonWettingasPhaseIdxV, int gasPhaseIdxV>
class ThreePhaseMaterialTraits;
template <class Traits>
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<MaterialTraits> 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> 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> 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<class T>
void init(Opm::DeckConstPtr deck,
Opm::EclipseStateConstPtr eclipseState,
std::shared_ptr<MaterialLawManager> materialLawManager,
int number_of_cells,
const int* global_cell,
const T& begin_cell_centroids,
int dimensions)
std::shared_ptr<MaterialLawManager> materialLawManager)
{
init(Opm::phaseUsageFromDeck(deck), materialLawManager);
}