Merge pull request #994 from pgdr/use-eclipse3dproperties

@bska We're merging as-is for now, and we've made a note to replace `shared_ptr` and maintain (and document!) this property. Those changes will obviously be internal and you won't notice a difference.
This commit is contained in:
jokva 2016-04-13 11:01:43 +02:00
commit 8b71d81a14
7 changed files with 52 additions and 48 deletions

View File

@ -25,6 +25,7 @@
#include <opm/parser/eclipse/Deck/Deck.hpp> #include <opm/parser/eclipse/Deck/Deck.hpp>
#include <opm/parser/eclipse/EclipseState/EclipseState.hpp> #include <opm/parser/eclipse/EclipseState/EclipseState.hpp>
#include <opm/parser/eclipse/EclipseState/Tables/TableManager.hpp>
namespace Opm namespace Opm
@ -37,14 +38,15 @@ namespace Opm
PhaseUsage pu; PhaseUsage pu;
std::fill(pu.phase_used, pu.phase_used + BlackoilPhases::MaxNumPhases, 0); std::fill(pu.phase_used, pu.phase_used + BlackoilPhases::MaxNumPhases, 0);
const auto& tm = eclipseState->getTableManager();
// Discover phase usage. // Discover phase usage.
if (eclipseState->hasPhase(Phase::PhaseEnum::WATER)) { if (tm.hasPhase(Phase::PhaseEnum::WATER)) {
pu.phase_used[BlackoilPhases::Aqua] = 1; pu.phase_used[BlackoilPhases::Aqua] = 1;
} }
if (eclipseState->hasPhase(Phase::PhaseEnum::OIL)) { if (tm.hasPhase(Phase::PhaseEnum::OIL)) {
pu.phase_used[BlackoilPhases::Liquid] = 1; pu.phase_used[BlackoilPhases::Liquid] = 1;
} }
if (eclipseState->hasPhase(Phase::PhaseEnum::GAS)) { if (tm.hasPhase(Phase::PhaseEnum::GAS)) {
pu.phase_used[BlackoilPhases::Vapour] = 1; pu.phase_used[BlackoilPhases::Vapour] = 1;
} }
pu.num_phases = 0; pu.num_phases = 0;

View File

@ -45,8 +45,8 @@ namespace Opm
: pref_(0.0), : pref_(0.0),
rock_comp_(0.0) rock_comp_(0.0)
{ {
const auto tables = eclipseState->getTableManager(); const auto& tables = eclipseState->getTableManager();
const auto& rocktabTables = tables->getRocktabTables(); const auto& rocktabTables = tables.getRocktabTables();
if (rocktabTables.size() > 0) { if (rocktabTables.size() > 0) {
const auto& rocktabTable = rocktabTables.getTable<RocktabTable>(0); const auto& rocktabTable = rocktabTables.getTable<RocktabTable>(0);
if (rocktabTables.size() != 1) if (rocktabTables.size() != 1)

View File

@ -183,16 +183,17 @@ namespace Opm
/// Invalid invalid set of components given. /// Invalid invalid set of components given.
PermeabilityKind classifyPermeability(Opm::EclipseStateConstPtr eclState) PermeabilityKind classifyPermeability(Opm::EclipseStateConstPtr eclState)
{ {
const bool xx = eclState->hasDeckDoubleGridProperty("PERMX" ); auto& props = eclState->get3DProperties();
const bool xy = eclState->hasDeckDoubleGridProperty("PERMXY"); const bool xx = props.hasDeckDoubleGridProperty("PERMX" );
const bool xy = props.hasDeckDoubleGridProperty("PERMXY");
const bool yx = xy; const bool yx = xy;
const bool yy = eclState->hasDeckDoubleGridProperty("PERMY" ); const bool yy = props.hasDeckDoubleGridProperty("PERMY" );
const bool yz = eclState->hasDeckDoubleGridProperty("PERMYZ"); const bool yz = props.hasDeckDoubleGridProperty("PERMYZ");
const bool zy = yz; const bool zy = yz;
const bool zz = eclState->hasDeckDoubleGridProperty("PERMZ" ); const bool zz = props.hasDeckDoubleGridProperty("PERMZ" );
const bool zx = eclState->hasDeckDoubleGridProperty("PERMZX"); const bool zx = props.hasDeckDoubleGridProperty("PERMZX");
const bool xz = zx; const bool xz = zx;
int num_cross_comp = xy + xz + yx + yz + zx + zy; int num_cross_comp = xy + xz + yx + yz + zx + zy;
@ -309,7 +310,7 @@ namespace Opm
// ----------------------------------------------------------- // -----------------------------------------------------------
// 1st row: [ kxx, kxy ], kxz handled in kzx // 1st row: [ kxx, kxy ], kxz handled in kzx
if (eclState->hasDeckDoubleGridProperty("PERMX" )) { if (eclState->get3DProperties().hasDeckDoubleGridProperty("PERMX" )) {
kmap[xx] = tensor.size(); kmap[xx] = tensor.size();
tensor.push_back(extractPermComponent(eclState, "PERMX", global_cell)); tensor.push_back(extractPermComponent(eclState, "PERMX", global_cell));
@ -322,7 +323,7 @@ namespace Opm
// ----------------------------------------------------------- // -----------------------------------------------------------
// 2nd row: [ kyy, kyz ], kyx handled in kxy // 2nd row: [ kyy, kyz ], kyx handled in kxy
if (eclState->hasDeckDoubleGridProperty("PERMY" )) { if (eclState->get3DProperties().hasDeckDoubleGridProperty("PERMY" )) {
kmap[yy] = tensor.size(); kmap[yy] = tensor.size();
tensor.push_back(extractPermComponent(eclState, "PERMY", global_cell)); tensor.push_back(extractPermComponent(eclState, "PERMY", global_cell));
@ -339,7 +340,7 @@ namespace Opm
kmap[zx] = kmap[xz] = tensor.size(); // Enforce symmetry. kmap[zx] = kmap[xz] = tensor.size(); // Enforce symmetry.
tensor.push_back(extractPermComponent(eclState, "PERMZX", global_cell)); tensor.push_back(extractPermComponent(eclState, "PERMZX", global_cell));
} }
if (eclState->hasDeckDoubleGridProperty("PERMZ" )) { if (eclState->get3DProperties().hasDeckDoubleGridProperty("PERMZ" )) {
kmap[zz] = tensor.size(); kmap[zz] = tensor.size();
tensor.push_back(extractPermComponent(eclState, "PERMZ", global_cell)); tensor.push_back(extractPermComponent(eclState, "PERMZ", global_cell));

View File

@ -93,14 +93,14 @@ namespace Opm{
void RelpermDiagnostics::satFamilyCheck_(Opm::EclipseStateConstPtr eclState) void RelpermDiagnostics::satFamilyCheck_(Opm::EclipseStateConstPtr eclState)
{ {
const auto& tableManager = eclState->getTableManager(); const auto& tableManager = eclState->getTableManager();
const TableContainer& swofTables = tableManager->getSwofTables(); const TableContainer& swofTables = tableManager.getSwofTables();
const TableContainer& slgofTables= tableManager->getSlgofTables(); const TableContainer& slgofTables= tableManager.getSlgofTables();
const TableContainer& sgofTables = tableManager->getSgofTables(); const TableContainer& sgofTables = tableManager.getSgofTables();
const TableContainer& swfnTables = tableManager->getSwfnTables(); const TableContainer& swfnTables = tableManager.getSwfnTables();
const TableContainer& sgfnTables = tableManager->getSgfnTables(); const TableContainer& sgfnTables = tableManager.getSgfnTables();
const TableContainer& sof3Tables = tableManager->getSof3Tables(); const TableContainer& sof3Tables = tableManager.getSof3Tables();
const TableContainer& sof2Tables = tableManager->getSof2Tables(); const TableContainer& sof2Tables = tableManager.getSof2Tables();
const TableContainer& sgwfnTables= tableManager->getSgwfnTables(); const TableContainer& sgwfnTables= tableManager.getSgwfnTables();
bool family1 = (!sgofTables.empty() || !slgofTables.empty()) && !swofTables.empty(); bool family1 = (!sgofTables.empty() || !slgofTables.empty()) && !swofTables.empty();
@ -147,19 +147,19 @@ namespace Opm{
std::cout << msg << std::endl; std::cout << msg << std::endl;
OpmLog::info(msg); OpmLog::info(msg);
const auto& tableManager = eclState->getTableManager(); const auto& tableManager = eclState->getTableManager();
const TableContainer& swofTables = tableManager->getSwofTables(); const TableContainer& swofTables = tableManager.getSwofTables();
const TableContainer& slgofTables= tableManager->getSlgofTables(); const TableContainer& slgofTables = tableManager.getSlgofTables();
const TableContainer& sgofTables = tableManager->getSgofTables(); const TableContainer& sgofTables = tableManager.getSgofTables();
const TableContainer& swfnTables = tableManager->getSwfnTables(); const TableContainer& swfnTables = tableManager.getSwfnTables();
const TableContainer& sgfnTables = tableManager->getSgfnTables(); const TableContainer& sgfnTables = tableManager.getSgfnTables();
const TableContainer& sof3Tables = tableManager->getSof3Tables(); const TableContainer& sof3Tables = tableManager.getSof3Tables();
const TableContainer& sof2Tables = tableManager->getSof2Tables(); const TableContainer& sof2Tables = tableManager.getSof2Tables();
const TableContainer& sgwfnTables= tableManager->getSgwfnTables(); const TableContainer& sgwfnTables = tableManager.getSgwfnTables();
const TableContainer& sgcwmisTables = tableManager->getSgcwmisTables(); const TableContainer& sgcwmisTables = tableManager.getSgcwmisTables();
const TableContainer& sorwmisTables = tableManager->getSorwmisTables(); const TableContainer& sorwmisTables = tableManager.getSorwmisTables();
const TableContainer& ssfnTables = tableManager->getSsfnTables(); const TableContainer& ssfnTables = tableManager.getSsfnTables();
const TableContainer& miscTables = tableManager->getMiscTables(); const TableContainer& miscTables = tableManager.getMiscTables();
const TableContainer& msfnTables = tableManager->getMsfnTables(); const TableContainer& msfnTables = tableManager.getMsfnTables();
for (int satnumIdx = 0; satnumIdx < numSatRegions; ++satnumIdx) { for (int satnumIdx = 0; satnumIdx < numSatRegions; ++satnumIdx) {
if (deck->hasKeyword("SWOF")) { if (deck->hasKeyword("SWOF")) {
@ -710,11 +710,11 @@ namespace Opm{
const int numSatRegions = deck->getKeyword("TABDIMS").getRecord(0).getItem("NTSFUN").get< int >(0); const int numSatRegions = deck->getKeyword("TABDIMS").getRecord(0).getItem("NTSFUN").get< int >(0);
unscaledEpsInfo_.resize(numSatRegions); unscaledEpsInfo_.resize(numSatRegions);
const auto tables = eclState->getTableManager(); const auto& tables = eclState->getTableManager();
const TableContainer& swofTables = tables->getSwofTables(); const TableContainer& swofTables = tables.getSwofTables();
const TableContainer& sgofTables = tables->getSgofTables(); const TableContainer& sgofTables = tables.getSgofTables();
const TableContainer& slgofTables = tables->getSlgofTables(); const TableContainer& slgofTables = tables.getSlgofTables();
const TableContainer& sof3Tables = tables->getSof3Tables(); const TableContainer& sof3Tables = tables.getSof3Tables();
// std::cout << "***************\nEnd-Points In all the Tables\n"; // std::cout << "***************\nEnd-Points In all the Tables\n";
for (int satnumIdx = 0; satnumIdx < numSatRegions; ++satnumIdx) { for (int satnumIdx = 0; satnumIdx < numSatRegions; ++satnumIdx) {

View File

@ -82,11 +82,11 @@ namespace Opm {
scaledEpsInfo_.resize(nc); scaledEpsInfo_.resize(nc);
EclEpsGridProperties epsGridProperties; EclEpsGridProperties epsGridProperties;
epsGridProperties.initFromDeck(deck, eclState, /*imbibition=*/false); epsGridProperties.initFromDeck(deck, eclState, /*imbibition=*/false);
const auto satnum = eclState->getIntGridProperty("SATNUM"); const auto& satnum = eclState->get3DProperties().getIntGridProperty("SATNUM");
for (int c = 0; c < nc; ++c) { for (int c = 0; c < nc; ++c) {
const int cartIdx = compressedToCartesianIdx[c]; const int cartIdx = compressedToCartesianIdx[c];
const std::string satnumIdx = std::to_string(satnum->iget(cartIdx)); const std::string satnumIdx = std::to_string(satnum.iget(cartIdx));
std::array<int, 3> ijk; std::array<int, 3> ijk;
ijk[0] = cartIdx % dims[0]; ijk[0] = cartIdx % dims[0];
ijk[1] = (cartIdx / dims[0]) % dims[1]; ijk[1] = (cartIdx / dims[0]) % dims[1];

View File

@ -221,7 +221,7 @@ namespace Opm
const int nc = UgGridHelpers::numCells(G); const int nc = UgGridHelpers::numCells(G);
eqlnum.resize(nc); eqlnum.resize(nc);
const std::vector<int>& e = const std::vector<int>& e =
eclipseState->getIntGridProperty("EQLNUM")->getData(); eclipseState->get3DProperties().getIntGridProperty("EQLNUM").getData();
const int* gc = UgGridHelpers::globalCell(G); const int* gc = UgGridHelpers::globalCell(G);
for (int cell = 0; cell < nc; ++cell) { for (int cell = 0; cell < nc; ++cell) {
const int deck_pos = (gc == NULL) ? cell : gc[cell]; const int deck_pos = (gc == NULL) ? cell : gc[cell];
@ -255,14 +255,14 @@ namespace Opm
{ {
// Get the equilibration records. // Get the equilibration records.
const std::vector<EquilRecord> rec = getEquil(*eclipseState); const std::vector<EquilRecord> rec = getEquil(*eclipseState);
std::shared_ptr<const TableManager> tables = eclipseState->getTableManager(); const auto& tables = eclipseState->getTableManager();
// Create (inverse) region mapping. // Create (inverse) region mapping.
const RegionMapping<> eqlmap(equilnum(deck, eclipseState, G)); const RegionMapping<> eqlmap(equilnum(deck, eclipseState, G));
// Create Rs functions. // Create Rs functions.
rs_func_.reserve(rec.size()); rs_func_.reserve(rec.size());
if (deck->hasKeyword("DISGAS")) { if (deck->hasKeyword("DISGAS")) {
const TableContainer& rsvdTables = tables->getRsvdTables(); const TableContainer& rsvdTables = tables.getRsvdTables();
for (size_t i = 0; i < rec.size(); ++i) { for (size_t i = 0; i < rec.size(); ++i) {
const int cell = *(eqlmap.cells(i).begin()); const int cell = *(eqlmap.cells(i).begin());
if (!rec[i].liveOilInitConstantRs()) { if (!rec[i].liveOilInitConstantRs()) {
@ -295,7 +295,7 @@ namespace Opm
rv_func_.reserve(rec.size()); rv_func_.reserve(rec.size());
if (deck->hasKeyword("VAPOIL")) { if (deck->hasKeyword("VAPOIL")) {
const TableContainer& rvvdTables = tables->getRvvdTables(); const TableContainer& rvvdTables = tables.getRvvdTables();
for (size_t i = 0; i < rec.size(); ++i) { for (size_t i = 0; i < rec.size(); ++i) {
const int cell = *(eqlmap.cells(i).begin()); const int cell = *(eqlmap.cells(i).begin());
if (!rec[i].wetGasInitConstantRv()) { if (!rec[i].wetGasInitConstantRv()) {
@ -332,7 +332,8 @@ namespace Opm
// Check for presence of kw SWATINIT // Check for presence of kw SWATINIT
if (deck->hasKeyword("SWATINIT")) { if (deck->hasKeyword("SWATINIT")) {
const std::vector<double>& swat_init = eclipseState->getDoubleGridProperty("SWATINIT")->getData(); const std::vector<double>& swat_init = eclipseState->
get3DProperties().getDoubleGridProperty("SWATINIT").getData();
const int nc = UgGridHelpers::numCells(G); const int nc = UgGridHelpers::numCells(G);
swat_init_.resize(nc); swat_init_.resize(nc);
const int* gc = UgGridHelpers::globalCell(G); const int* gc = UgGridHelpers::globalCell(G);

View File

@ -55,7 +55,7 @@ BOOST_AUTO_TEST_CASE(Processing)
Opm::ParseContext parseContext({{ ParseContext::PARSE_RANDOM_SLASH , InputError::IGNORE }}); Opm::ParseContext parseContext({{ ParseContext::PARSE_RANDOM_SLASH , InputError::IGNORE }});
Opm::DeckConstPtr deck = parser->parseFile(filename, parseContext); Opm::DeckConstPtr deck = parser->parseFile(filename, parseContext);
std::shared_ptr<EclipseState> eclstate (new Opm::EclipseState(deck, parseContext)); std::shared_ptr<EclipseState> eclstate (new Opm::EclipseState(deck, parseContext));
std::vector<double> porv = eclstate->getDoubleGridProperty("PORV")->getData(); const auto& porv = eclstate->get3DProperties().getDoubleGridProperty("PORV").getData();
EclipseGridConstPtr eclgrid = eclstate->getEclipseGrid(); EclipseGridConstPtr eclgrid = eclstate->getEclipseGrid();
BOOST_CHECK_EQUAL(eclgrid->getMinpvMode(), MinpvMode::EclSTD); BOOST_CHECK_EQUAL(eclgrid->getMinpvMode(), MinpvMode::EclSTD);