Get CornerpointChopper.hpp; remove shared_ptrs

opm-parser no longer exposes shared_ptr or shared_ptr aliases.
This commit is contained in:
Jørgen Kvalsvik 2016-10-14 11:36:19 +02:00
parent 6969d38cc8
commit d3f08246b0
35 changed files with 680 additions and 224 deletions

View File

@ -219,5 +219,6 @@ list (APPEND PUBLIC_HEADER_FILES
opm/upscaling/UpscalerBase.hpp
opm/upscaling/UpscalerBase_impl.hpp
opm/upscaling/UpscalingTraits.hpp
opm/upscaling/CornerpointChopper.hpp
opm/upscaling/initCPGrid.hpp
)

View File

@ -267,11 +267,11 @@ try
flush(cout); start = clock();
// create the parser
Opm::ParserPtr parser(new Opm::Parser);
Opm::Parser parser;
stringstream gridstringstream(stringstream::in | stringstream::out);
inflate (eclipseInput, sizeof (eclipseInput) / sizeof (eclipseInput[0]), gridstringstream);
Opm::ParseContext mode;
auto deck = parser->parseString(gridstringstream.str(), mode);
auto deck = parser.parseString(gridstringstream.str(), mode);
finish = clock(); timeused = (double(finish)-double(start))/CLOCKS_PER_SEC;
if (helper.isMaster) cout << " (" << timeused <<" secs)" << endl;
@ -282,7 +282,7 @@ try
start = clock();
helper.sanityCheckInput(deck, minPerm, maxPerm, minPoro);
const Opm::DeckRecord& specgridRecord(deck->getKeyword("SPECGRID").getRecord(0));
const Opm::DeckRecord& specgridRecord(deck.getKeyword("SPECGRID").getRecord(0));
std::array<int,3> res;
res[0] = specgridRecord.getItem("NX").get<int>(0);
res[1] = specgridRecord.getItem("NY").get<int>(0);

View File

@ -33,11 +33,10 @@ try
}
Opm::BlackoilCo2PVT boPvt;
Opm::DeckConstPtr deck; // <- uninitalized pointer!
Opm::time::StopWatch clock;
clock.start();
boPvt.init(deck);
boPvt.init( Opm::Deck{} );
boPvt.generateBlackOilTables(temperature);
clock.stop();

View File

@ -34,12 +34,12 @@
#include <opm/core/utility/MonotCubicInterpolator.hpp>
#include <opm/parser/eclipse/Units/Units.hpp>
#include <opm/output/eclipse/CornerpointChopper.hpp>
#include <opm/output/eclipse/EclipseGridInspector.hpp>
#include <opm/porsol/common/setupBoundaryConditions.hpp>
#include <opm/upscaling/SinglePhaseUpscaler.hpp>
#include <opm/upscaling/CornerpointChopper.hpp>
#include <cfloat>
#include <cmath>
@ -329,7 +329,7 @@ try
try { /* The upscaling may fail to converge on icky grids, lets just pass by those */
if (upscale) {
Opm::DeckConstPtr subdeck = ch.subDeck();
auto subdeck = ch.subDeck();
Opm::SinglePhaseUpscaler upscaler;
upscaler.init(subdeck, bctype, minpermSI,
@ -361,13 +361,13 @@ try
if (endpoints) {
// Calculate minimum and maximum water volume in each cell based on input pc-curves per rock type
// Create single-phase upscaling object to get poro and perm values from the grid
Opm::DeckConstPtr subdeck = ch.subDeck();
std::vector<double> perms = subdeck->getKeyword("PERMX").getRawDoubleData();
auto subdeck = ch.subDeck();
std::vector<double> perms = subdeck.getKeyword("PERMX").getRawDoubleData();
Opm::SinglePhaseUpscaler upscaler;
upscaler.init(subdeck, bctype, minpermSI,
residual_tolerance, linsolver_verbosity, linsolver_type, false);
std::vector<int> satnums = subdeck->getKeyword("SATNUM").getIntData();
std::vector<double> poros = subdeck->getKeyword("PORO").getSIDoubleData();
std::vector<int> satnums = subdeck.getKeyword("SATNUM").getIntData();
std::vector<double> poros = subdeck.getKeyword("PORO").getSIDoubleData();
std::vector<double> cellVolumes, cellPoreVolumes;
cellVolumes.resize(satnums.size(), 0.0);
cellPoreVolumes.resize(satnums.size(), 0.0);
@ -499,9 +499,9 @@ try
if (dips) {
Opm::DeckConstPtr subdeck = ch.subDeck();
auto subdeck = ch.subDeck();
std::vector<int> griddims(3);
const auto& specgridRecord = subdeck->getKeyword("SPECGRID").getRecord(0);
const auto& specgridRecord = subdeck.getKeyword("SPECGRID").getRecord(0);
griddims[0] = specgridRecord.getItem("NX").get< int >(0);
griddims[1] = specgridRecord.getItem("NY").get< int >(0);
griddims[2] = specgridRecord.getItem("NZ").get< int >(0);
@ -539,10 +539,10 @@ try
}
if (satnumvolumes) {
Opm::DeckConstPtr subdeck = ch.subDeck();
auto subdeck = ch.subDeck();
Opm::EclipseGridInspector subinspector(subdeck);
std::vector<int> griddims(3);
const auto& specgridRecord = subdeck->getKeyword("SPECGRID").getRecord(0);
const auto& specgridRecord = subdeck.getKeyword("SPECGRID").getRecord(0);
griddims[0] = specgridRecord.getItem("NX").get< int >(0);
griddims[1] = specgridRecord.getItem("NY").get< int >(0);
griddims[2] = specgridRecord.getItem("NZ").get< int >(0);
@ -550,7 +550,7 @@ try
int number_of_subsamplecells = griddims[0] * griddims[1] * griddims[2];
// If SATNUM is non-existent in input grid, this will fail:
std::vector<int> satnums = subdeck->getKeyword("SATNUM").getIntData();
std::vector<int> satnums = subdeck.getKeyword("SATNUM").getIntData();
std::vector<double> rockvolumessubsample;
for (int cell_idx=0; cell_idx < number_of_subsamplecells; ++cell_idx) {

View File

@ -33,7 +33,7 @@
#include <opm/parser/eclipse/Units/Units.hpp>
#include <opm/output/eclipse/CornerpointChopper.hpp>
#include <opm/upscaling/CornerpointChopper.hpp>
#include <opm/porsol/common/setupBoundaryConditions.hpp>
@ -173,7 +173,7 @@ try
try { /* The upscaling may fail to converge on icky grids, lets just pass by those */
if (upscale) {
Opm::DeckConstPtr subdeck = ch.subDeck();
auto subdeck = ch.subDeck();
Opm::SinglePhaseUpscaler upscaler;
upscaler.init(subdeck, Opm::SinglePhaseUpscaler::Fixed, minpermSI,
residual_tolerance, linsolver_verbosity, linsolver_type, false);

View File

@ -53,7 +53,7 @@
#include <opm/parser/eclipse/Units/Units.hpp>
#include <opm/output/eclipse/CornerpointChopper.hpp>
#include <opm/upscaling/CornerpointChopper.hpp>
#include <opm/output/eclipse/EclipseGridInspector.hpp>
#include <opm/porsol/common/setupBoundaryConditions.hpp>
@ -134,8 +134,8 @@ try
Opm::ParseContext parseMode;
// Original x/y resolution in terms of coordinate values (not indices)
Opm::ParserPtr parser(new Opm::Parser);
Opm::DeckConstPtr deck(parser->parseFile(gridfilename , parseMode)); // TODO: REFACTOR!!!! it is stupid to parse this again
Opm::Parser parser;
auto deck = parser.parseFile(gridfilename , parseMode); // TODO: REFACTOR!!!! it is stupid to parse this again
Opm::EclipseGridInspector gridinspector(deck);
std::array<double, 6> gridlimits=gridinspector.getGridLimits();
double finegridxresolution = (gridlimits[1]-gridlimits[0])/dims[0];
@ -185,7 +185,7 @@ try
OPM_THROW(std::logic_error, "Sub-decks not are not implemented by opm-parser. Refactor the calling code!?");
try {
Opm::DeckConstPtr subdeck = ch.subDeck();
auto subdeck = ch.subDeck();
Opm::SinglePhaseUpscaler upscaler;
upscaler.init(subdeck, Opm::SinglePhaseUpscaler::Fixed, minpermSI,
residual_tolerance, linsolver_verbosity, linsolver_type, false);

View File

@ -44,7 +44,7 @@
#include <opm/parser/eclipse/Units/Units.hpp>
#include <opm/output/eclipse/CornerpointChopper.hpp>
#include <opm/upscaling/CornerpointChopper.hpp>
#include <opm/porsol/common/setupBoundaryConditions.hpp>
@ -183,7 +183,7 @@ try
double zstart_1 = rz();
ch.chop(istart_1, istart_1 + ilen, jstart_1, jstart_1 + jlen, zstart_1, zstart_1 + zlen, false);
Opm::DeckConstPtr subdeck_1 = ch.subDeck();
auto subdeck_1 = ch.subDeck();
Opm::SinglePhaseUpscaler upscaler_1;
upscaler_1.init(subdeck_1, Opm::SinglePhaseUpscaler::Fixed, minpermSI,
residual_tolerance, linsolver_verbosity, linsolver_type, false);
@ -206,7 +206,7 @@ try
}
ch.chop(istart_2, istart_2 + ilen, jstart_2, jstart_2 + jlen, zstart_2, zstart_2 + zlen, false);
Opm::DeckConstPtr subdeck_2 = ch.subDeck();
auto subdeck_2 = ch.subDeck();
Opm::SinglePhaseUpscaler upscaler_2;
upscaler_2.init(subdeck_2, Opm::SinglePhaseUpscaler::Fixed, minpermSI,
residual_tolerance, linsolver_verbosity, linsolver_type, false);

View File

@ -34,7 +34,7 @@
#include <opm/core/utility/parameters/ParameterGroup.hpp>
#include <opm/parser/eclipse/Units/Units.hpp>
#include <opm/output/eclipse/CornerpointChopper.hpp>
#include <opm/upscaling/CornerpointChopper.hpp>
#include <opm/output/eclipse/EclipseGridInspector.hpp>
#include <opm/porsol/common/setupBoundaryConditions.hpp>
@ -82,7 +82,7 @@ int main(int argc, char** argv) try {
Opm::EclipseGridInspector gridinspector(deck);
// Check that we have the information we need from the eclipse file, we will check PERM-fields later
if (! (deck->hasKeyword("SPECGRID") && deck->hasKeyword("COORD") && deck->hasKeyword("ZCORN"))) {
if (! (deck.hasKeyword("SPECGRID") && deck.hasKeyword("COORD") && deck.hasKeyword("ZCORN"))) {
cerr << "Error: Did not find SPECGRID, COORD and ZCORN in Eclipse file " << gridfilename << endl;
exit(1);
}
@ -91,7 +91,7 @@ int main(int argc, char** argv) try {
* Find dips for every cell.
*/
const auto& specgridRecord = deck->getKeyword("SPECGRID").getRecord(0);
const auto& specgridRecord = deck.getKeyword("SPECGRID").getRecord(0);
vector<int> griddims(3);
griddims[0] = specgridRecord.getItem("NX").get< int >(0);
griddims[1] = specgridRecord.getItem("NY").get< int >(0);

View File

@ -77,7 +77,7 @@
namespace
{
void build_grid(Opm::DeckConstPtr deck,
void build_grid(const Opm::Deck& deck,
const double z_tol,
Dune::CpGrid& grid,
std::array<int,3>& cartDims)
@ -91,11 +91,11 @@ namespace
cartDims[2] = g.dims[2] = insp.gridSize()[2];
}
g.coord = &deck->getKeyword("COORD").getSIDoubleData()[0];
g.zcorn = &deck->getKeyword("ZCORN").getSIDoubleData()[0];
g.coord = &deck.getKeyword("COORD").getSIDoubleData()[0];
g.zcorn = &deck.getKeyword("ZCORN").getSIDoubleData()[0];
if (deck->hasKeyword("ACTNUM")) {
g.actnum = &deck->getKeyword("ACTNUM").getIntData()[0];
if (deck.hasKeyword("ACTNUM")) {
g.actnum = &deck.getKeyword("ACTNUM").getIntData()[0];
grid.processEclipseFormat(g, z_tol, false, false);
}
else {
@ -210,7 +210,7 @@ try
auto parser = std::make_shared<Opm::Parser>();
Opm::DeckConstPtr
const Opm::Deck&
deck(parser->parseFile(param.get<std::string>("filename"),
Opm::ParseContext()));

View File

@ -176,7 +176,7 @@ int main(int varnum, char** vararg) try {
cout << " (" << timeused <<" secs)" << endl;
// Check that we have the information we need from the eclipse file, we will check PERM-fields later
if (! (deck->hasKeyword("SPECGRID") && deck->hasKeyword("COORD") && deck->hasKeyword("ZCORN"))) {
if (! (deck.hasKeyword("SPECGRID") && deck.hasKeyword("COORD") && deck.hasKeyword("ZCORN"))) {
cerr << "Error: Did not find SPECGRID, COORD and ZCORN in Eclipse file " << ECLIPSEFILENAME << endl;
usage();
exit(1);
@ -191,9 +191,9 @@ int main(int varnum, char** vararg) try {
bool use_actnum = false;
vector<int> actnum;
if (atoi(options["use_actnum"].c_str())>0) {
if (deck->hasKeyword("ACTNUM")) {
if (deck.hasKeyword("ACTNUM")) {
use_actnum = true;
actnum = deck->getKeyword("ACTNUM").getIntData();
actnum = deck.getKeyword("ACTNUM").getIntData();
cout << actnum[0] << " " << actnum[1] << endl;
}
else {
@ -208,26 +208,26 @@ int main(int varnum, char** vararg) try {
cout << "Statistics for filename: " << ECLIPSEFILENAME << endl;
cout << "-----------------------------------------------------" << endl;
bool doporosity = false;
if (deck->hasKeyword("PORO")) {
if (deck.hasKeyword("PORO")) {
doporosity = true;
}
bool dontg = false;
if (deck->hasKeyword("NTG")) {
if (deck.hasKeyword("NTG")) {
// Ntg only used together with PORO
if (deck->hasKeyword("PORO")) dontg = true;
if (deck.hasKeyword("PORO")) dontg = true;
}
bool doperm = false;
if (deck->hasKeyword("PERMX")) {
if (deck.hasKeyword("PERMX")) {
doperm = true;
if (deck->hasKeyword("PERMY") && deck->hasKeyword("PERMZ")) {
if (deck.hasKeyword("PERMY") && deck.hasKeyword("PERMZ")) {
anisotropic_input = true;
cout << "Info: PERMY and PERMZ present in data file." << endl;
}
}
// Global number of cells (includes inactive cells)
const auto& specgridRecord = deck->getKeyword("SPECGRID").getRecord(0);
const auto& specgridRecord = deck.getKeyword("SPECGRID").getRecord(0);
vector<int> griddims(3);
griddims[0] = specgridRecord.getItem("NX").get< int >(0);
griddims[1] = specgridRecord.getItem("NY").get< int >(0);
@ -260,16 +260,16 @@ int main(int varnum, char** vararg) try {
vector<double> poros, ntgs;
vector<double> permxs, permys, permzs;
if (doporosity) {
poros = deck->getKeyword("PORO").getRawDoubleData();
poros = deck.getKeyword("PORO").getRawDoubleData();
}
if (dontg) {
ntgs = deck->getKeyword("NTG").getRawDoubleData();
ntgs = deck.getKeyword("NTG").getRawDoubleData();
}
if (doperm) {
permxs = deck->getKeyword("PERMX").getRawDoubleData();
permxs = deck.getKeyword("PERMX").getRawDoubleData();
if (anisotropic_input) {
permys = deck->getKeyword("PERMY").getRawDoubleData();
permzs = deck->getKeyword("PERMZ").getRawDoubleData();
permys = deck.getKeyword("PERMY").getRawDoubleData();
permzs = deck.getKeyword("PERMZ").getRawDoubleData();
}
}
@ -416,14 +416,14 @@ int main(int varnum, char** vararg) try {
// Then do statistics on rocktype by rocktype basis
bool dosatnums = false;
vector<int> satnums;
if (deck->hasKeyword("SATNUM")) {
if (deck.hasKeyword("SATNUM")) {
dosatnums = true;
satnums = deck->getKeyword("SATNUM").getIntData();
satnums = deck.getKeyword("SATNUM").getIntData();
} // If SATNUM was not present, maybe ROCKTYPE is there,
// if so, we will use it as SATNUM.
else if (deck->hasKeyword("ROCKTYPE")) {
else if (deck.hasKeyword("ROCKTYPE")) {
dosatnums = true;
satnums = deck->getKeyword("ROCKTYPE").getIntData();
satnums = deck.getKeyword("ROCKTYPE").getIntData();
}

View File

@ -241,17 +241,17 @@ try
auto deck = RelPermUpscaleHelper::parseEclipseFile(ECLIPSEFILENAME);
// Check that we have the information we need from the eclipse file:
if (! (deck->hasKeyword("SPECGRID") && deck->hasKeyword("COORD") && deck->hasKeyword("ZCORN")
&& deck->hasKeyword("PORO") && deck->hasKeyword("PERMX") && deck->hasKeyword("SATNUM"))) {
if (! (deck.hasKeyword("SPECGRID") && deck.hasKeyword("COORD") && deck.hasKeyword("ZCORN")
&& deck.hasKeyword("PORO") && deck.hasKeyword("PERMX") && deck.hasKeyword("SATNUM"))) {
cerr << "Error: Did not find SPECGRID, COORD and ZCORN in Eclipse file " << ECLIPSEFILENAME << endl;
usageandexit();
}
vector<int> satnums = deck->getKeyword("SATNUM").getIntData();
vector<double> poros = deck->getKeyword("PORO").getRawDoubleData();
vector<double> permxs = deck->getKeyword("PERMX").getRawDoubleData();
vector<int> satnums = deck.getKeyword("SATNUM").getIntData();
vector<double> poros = deck.getKeyword("PORO").getRawDoubleData();
vector<double> permxs = deck.getKeyword("PERMX").getRawDoubleData();
vector<int> griddims(3);
const auto& specgridRecord = deck->getKeyword("SPECGRID").getRecord(0);
const auto& specgridRecord = deck.getKeyword("SPECGRID").getRecord(0);
griddims[0] = specgridRecord.getItem("NX").get< int >(0);
griddims[1] = specgridRecord.getItem("NY").get< int >(0);
griddims[2] = specgridRecord.getItem("NZ").get< int >(0);

View File

@ -317,17 +317,17 @@ try
if (isMaster) cout << " (" << timeused <<" secs)" << endl;
// Check that we have the information we need from the eclipse file:
if (! (deck->hasKeyword("SPECGRID") && deck->hasKeyword("COORD") && deck->hasKeyword("ZCORN")
&& deck->hasKeyword("PORO") && deck->hasKeyword("PERMX") && deck->hasKeyword("SATNUM"))) {
if (! (deck.hasKeyword("SPECGRID") && deck.hasKeyword("COORD") && deck.hasKeyword("ZCORN")
&& deck.hasKeyword("PORO") && deck.hasKeyword("PERMX") && deck.hasKeyword("SATNUM"))) {
if (isMaster) cerr << "Error: Did not find SPECGRID, COORD and ZCORN in Eclipse file " << ECLIPSEFILENAME << endl;
usageandexit();
}
const int points = atoi(options["points"].c_str());
vector<int> satnums = deck->getKeyword("SATNUM").getIntData();
vector<double> poros = deck->getKeyword("PORO").getRawDoubleData();
vector<double> permxs = deck->getKeyword("PERMX").getRawDoubleData();
vector<int> satnums = deck.getKeyword("SATNUM").getIntData();
vector<double> poros = deck.getKeyword("PORO").getRawDoubleData();
vector<double> permxs = deck.getKeyword("PERMX").getRawDoubleData();
const double minPerm = atof(options["minPerm"].c_str());
const double minPoro = atof(options["minPoro"].c_str());
@ -430,7 +430,7 @@ try
(crop top and bottom). These modifications ruin the computations for
fixed and linear boundary conditions.
*/
const auto& specgridRecord = deck->getKeyword("SPECGRID").getRecord(0);
const auto& specgridRecord = deck.getKeyword("SPECGRID").getRecord(0);
vector<int> griddims(3);
griddims[0] = specgridRecord.getItem("NX").get< int >(0);
griddims[1] = specgridRecord.getItem("NY").get< int >(0);

View File

@ -295,8 +295,8 @@ int run(Params& p)
grid.createCartesian(cells,cellsize);
} else {
Opm::ParseContext parseContext;
Opm::ParserPtr parser(new Opm::Parser());
Opm::DeckConstPtr deck(parser->parseFile(p.file , parseContext));
Opm::Parser parser;
auto deck = parser.parseFile(p.file , parseContext);
Opm::EclipseGrid inputGrid(deck);
grid.processEclipseFormat(inputGrid, false);
}

View File

@ -206,7 +206,7 @@ int upscale(int varnum, char** vararg) {
cout << " (" << timeused <<" secs)" << endl;
// Check that we have the information we need from the eclipse file, we will check PERM-fields later
if (! (deck->hasKeyword("SPECGRID") && deck->hasKeyword("COORD") && deck->hasKeyword("ZCORN"))) {
if (! (deck.hasKeyword("SPECGRID") && deck.hasKeyword("COORD") && deck.hasKeyword("ZCORN"))) {
cerr << "Error: Did not find SPECGRID, COORD and ZCORN in Eclipse file " << ECLIPSEFILENAME << endl;
usage();
exit(1);
@ -270,7 +270,7 @@ int upscale(int varnum, char** vararg) {
* in terms of cpu-resources (compared to permeability upscaling).
*/
double upscaledPorosity = 0.0;
if (deck->hasKeyword("PORO")) {
if (deck.hasKeyword("PORO")) {
if (isPeriodic) {
upscaledPorosity = upscaler_periodic.upscalePorosity();
} else {

View File

@ -352,23 +352,23 @@ try
if (isMaster) cout << " (" << timeused <<" secs)" << endl;
// Check that we have the information we need from the eclipse file:
if (! (deck->hasKeyword("SPECGRID") && deck->hasKeyword("COORD") && deck->hasKeyword("ZCORN")
&& deck->hasKeyword("PORO") && deck->hasKeyword("PERMX") && deck->hasKeyword("SATNUM"))) {
if (! (deck.hasKeyword("SPECGRID") && deck.hasKeyword("COORD") && deck.hasKeyword("ZCORN")
&& deck.hasKeyword("PORO") && deck.hasKeyword("PERMX") && deck.hasKeyword("SATNUM"))) {
cerr << "Error: Did not find SPECGRID, COORD and ZCORN in Eclipse file " << ECLIPSEFILENAME << endl;
usage();
exit(1);
}
vector<double> poros = deck->getKeyword("PORO").getRawDoubleData();
vector<double> permxs = deck->getKeyword("PERMX").getRawDoubleData();
vector<double> poros = deck.getKeyword("PORO").getRawDoubleData();
vector<double> permxs = deck.getKeyword("PERMX").getRawDoubleData();
// Load anisotropic (only diagonal supported) input if present in grid
vector<double> permys, permzs;
if (deck->hasKeyword("PERMY") && deck->hasKeyword("PERMZ")) {
if (deck.hasKeyword("PERMY") && deck.hasKeyword("PERMZ")) {
anisotropic_input = true;
permys = deck->getKeyword("PERMY").getRawDoubleData();
permzs = deck->getKeyword("PERMZ").getRawDoubleData();
permys = deck.getKeyword("PERMY").getRawDoubleData();
permzs = deck.getKeyword("PERMZ").getRawDoubleData();
if (isMaster) cout << "Info: PERMY and PERMZ present, going into anisotropic input mode, no J-functions\n";
if (isMaster) cout << " Options -relPermCurve and -jFunctionCurve is meaningless.\n";
}
@ -377,11 +377,11 @@ try
/* Initialize a default satnums-vector with only "ones" (meaning only one rocktype) */
vector<int> satnums(poros.size(), 1);
if (deck->hasKeyword("SATNUM")) {
satnums = deck->getKeyword("SATNUM").getIntData();
if (deck.hasKeyword("SATNUM")) {
satnums = deck.getKeyword("SATNUM").getIntData();
}
else if (deck->hasKeyword("ROCKTYPE")) {
satnums = deck->getKeyword("ROCKTYPE").getIntData();
else if (deck.hasKeyword("ROCKTYPE")) {
satnums = deck.getKeyword("ROCKTYPE").getIntData();
}
else {
if (isMaster) cout << "Warning: SATNUM or ROCKTYPE not found in input file, assuming only one rocktype" << endl;

View File

@ -190,8 +190,8 @@ try
auto deck = Opm::RelPermUpscaleHelper::parseEclipseFile(gridfilename);
// Check that we have the information we need from the eclipse file:
if (! (deck->hasKeyword("SPECGRID") && deck->hasKeyword("COORD") && deck->hasKeyword("ZCORN")
&& deck->hasKeyword("PORO") && deck->hasKeyword("PERMX"))) {
if (! (deck.hasKeyword("SPECGRID") && deck.hasKeyword("COORD") && deck.hasKeyword("ZCORN")
&& deck.hasKeyword("PORO") && deck.hasKeyword("PERMX"))) {
std::cerr << "Error: Did not find SPECGRID, COORD, ZCORN, PORO and PERMX in Eclipse file " << gridfilename << std::endl;
usageandexit();
}
@ -260,15 +260,15 @@ try
std::vector<std::string> rockfiles;
std::vector<std::vector<double> > rocksatendpoints_ = getExtremeSats(rock_list,rockfiles);
std::vector<double> poros = deck->getKeyword("PORO").getSIDoubleData();
std::vector<double> poros = deck.getKeyword("PORO").getSIDoubleData();
// Anisotropic relperm not yet implemented in steadystate_implicit
//bool anisorocks = param.getDefault("anisotropicrocks", false);
std::vector<int> satnums(poros.size(), 1);
if (deck->hasKeyword("SATNUM")) {
satnums = deck->getKeyword("SATNUM").getIntData();
if (deck.hasKeyword("SATNUM")) {
satnums = deck.getKeyword("SATNUM").getIntData();
}
else if (deck->hasKeyword("ROCKTYPE")) {
satnums = deck->getKeyword("ROCKTYPE").getIntData();
else if (deck.hasKeyword("ROCKTYPE")) {
satnums = deck.getKeyword("ROCKTYPE").getIntData();
}
else {
std::cout << "Warning: SATNUM or ROCKTYPE not found in input file, assuming only one rocktype" << std::endl;

View File

@ -588,21 +588,21 @@ IMPL_FUNC(void, loadMaterialsFromGrid(const std::string& file))
Emod.insert(Emod.begin(),cells,100.f);
Poiss.insert(Poiss.begin(),cells,0.38f);
} else {
Opm::ParserPtr parser(new Opm::Parser());
Opm::Parser parser;
Opm::ParseContext parseContext;
Opm::DeckConstPtr deck(parser->parseFile(file , parseContext));
if (deck->hasKeyword("YOUNGMOD") && deck->hasKeyword("POISSONMOD")) {
Emod = deck->getKeyword("YOUNGMOD").getRawDoubleData();
Poiss = deck->getKeyword("POISSONMOD").getRawDoubleData();
auto deck = parser.parseFile(file , parseContext);
if (deck.hasKeyword("YOUNGMOD") && deck.hasKeyword("POISSONMOD")) {
Emod = deck.getKeyword("YOUNGMOD").getRawDoubleData();
Poiss = deck.getKeyword("POISSONMOD").getRawDoubleData();
std::vector<double>::const_iterator it = std::min_element(Poiss.begin(), Poiss.end());
if (*it < 0) {
std::cerr << "Auxetic material specified for cell " << it-Poiss.begin() << std::endl
<< "Emod: "<< Emod[it-Poiss.begin()] << " Poisson's ratio: " << *it << std::endl << "bailing..." << std::endl;
exit(1);
}
} else if (deck->hasKeyword("LAMEMOD") && deck->hasKeyword("SHEARMOD")) {
std::vector<double> lame = deck->getKeyword("LAMEMOD").getRawDoubleData();
std::vector<double> shear = deck->getKeyword("SHEARMOD").getRawDoubleData();
} else if (deck.hasKeyword("LAMEMOD") && deck.hasKeyword("SHEARMOD")) {
std::vector<double> lame = deck.getKeyword("LAMEMOD").getRawDoubleData();
std::vector<double> shear = deck.getKeyword("SHEARMOD").getRawDoubleData();
Emod.resize(lame.size());
Poiss.resize(lame.size());
for (size_t i=0;i<lame.size();++i) {
@ -616,9 +616,9 @@ IMPL_FUNC(void, loadMaterialsFromGrid(const std::string& file))
<< "Emod: "<< Emod[it-Poiss.begin()] << " Poisson's ratio: " << *it << std::endl << "bailing..." << std::endl;
exit(1);
}
} else if (deck->hasKeyword("BULKMOD") && deck->hasKeyword("SHEARMOD")) {
std::vector<double> bulk = deck->getKeyword("BULKMOD").getRawDoubleData();
std::vector<double> shear = deck->getKeyword("SHEARMOD").getRawDoubleData();
} else if (deck.hasKeyword("BULKMOD") && deck.hasKeyword("SHEARMOD")) {
std::vector<double> bulk = deck.getKeyword("BULKMOD").getRawDoubleData();
std::vector<double> shear = deck.getKeyword("SHEARMOD").getRawDoubleData();
Emod.resize(bulk.size());
Poiss.resize(bulk.size());
for (size_t i=0;i<bulk.size();++i) {
@ -632,18 +632,18 @@ IMPL_FUNC(void, loadMaterialsFromGrid(const std::string& file))
<< "Emod: "<< Emod[it-Poiss.begin()] << " Poisson's ratio: " << *it << std::endl << "bailing..." << std::endl;
exit(1);
}
} else if (deck->hasKeyword("PERMX") && deck->hasKeyword("PORO")) {
} else if (deck.hasKeyword("PERMX") && deck.hasKeyword("PORO")) {
std::cerr << "WARNING: Using PERMX and PORO for elastic material properties" << std::endl;
Emod = deck->getKeyword("PERMX").getRawDoubleData();
Poiss = deck->getKeyword("PORO").getRawDoubleData();
Emod = deck.getKeyword("PERMX").getRawDoubleData();
Poiss = deck.getKeyword("PORO").getRawDoubleData();
} else {
std::cerr << "No material data found in eclipse file, aborting" << std::endl;
exit(1);
}
if (deck->hasKeyword("SATNUM"))
satnum = deck->getKeyword("SATNUM").getIntData();
if (deck->hasKeyword("RHO"))
rho = deck->getKeyword("RHO").getRawDoubleData();
if (deck.hasKeyword("SATNUM"))
satnum = deck.getKeyword("SATNUM").getIntData();
if (deck.hasKeyword("RHO"))
rho = deck.getKeyword("RHO").getRawDoubleData();
}
// scale E modulus of materials
if (Escale > 0) {
@ -749,10 +749,10 @@ IMPL_FUNC(void, loadMaterialsFromRocklist(const std::string& file,
}
}
} else {
Opm::ParserPtr parser(new Opm::Parser());
Opm::Parser parser;
Opm::ParseContext parseContext;
Opm::DeckConstPtr deck(parser->parseFile(file , parseContext));
std::vector<int> satnum = deck->getKeyword("SATNUM").getIntData();
auto deck = parser.parseFile(file , parseContext);
std::vector<int> satnum = deck.getKeyword("SATNUM").getIntData();
std::vector<int> cells = gv.globalCell();
for (size_t i=0;i<cells.size();++i) {
int k = cells[i];

View File

@ -44,12 +44,12 @@ namespace Opm
typedef FluidStateBlackoil FluidState;
typedef BlackoilFluidData FluidData;
void init(Opm::DeckConstPtr deck)
void init(const Opm::Deck& deck)
{
fmi_params_.init(deck);
// FluidSystemBlackoil<>::init(parser);
pvt_.init(deck);
const auto& densityRecord = deck->getKeyword("DENSITY").getRecord(0);
const auto& densityRecord = deck.getKeyword("DENSITY").getRecord(0);
surface_densities_[Oil] = densityRecord.getItem("OIL").getSIDouble(0);
surface_densities_[Water] = densityRecord.getItem("WATER").getSIDouble(0);
surface_densities_[Gas] = densityRecord.getItem("GAS").getSIDouble(0);

View File

@ -123,8 +123,8 @@ init(const Opm::parameter::ParameterGroup& param)
std::string fileformat = param.getDefault<std::string>("fileformat", "cartesian");
if (fileformat == "eclipse") {
Opm::ParseContext parseContext;
Opm::ParserPtr parser(new Opm::Parser());
Opm::DeckConstPtr deck = parser->parseFile(param.get<std::string>("filename") , parseContext);
Opm::Parser parser;
auto deck = parser.parseFile(param.get<std::string>("filename") , parseContext);
Opm::EclipseGrid inputGrid( deck );
double z_tolerance = param.getDefault<double>("z_tolerance", 0.0);
@ -151,8 +151,8 @@ init(const Opm::parameter::ParameterGroup& param)
rock_.init(grid_.size(0), default_poro, default_perm);
Opm::ParseContext parseContext;
Opm::ParserPtr parser(new Opm::Parser());
Opm::DeckConstPtr deck = parser->parseFile(param.get<std::string>("filename") , parseContext);
Opm::Parser parser;
auto deck = parser.parseFile(param.get<std::string>("filename") , parseContext);
fluid_.init(deck);
wells_.init(deck, grid_, rock_);
} else {

View File

@ -38,7 +38,7 @@ namespace Opm
class BlackoilWells : public BlackoilDefs
{
public:
void init(Opm::DeckConstPtr deck,
void init(const Opm::Deck& deck,
const Dune::CpGrid& grid,
const Opm::Rock<3>& rock);
@ -121,25 +121,25 @@ namespace Opm
} // anon namespace
inline void BlackoilWells::init(Opm::DeckConstPtr deck,
inline void BlackoilWells::init(const Opm::Deck& deck,
const Dune::CpGrid& grid,
const Opm::Rock<3>& rock)
{
if (!deck->hasKeyword("WELSPECS")) {
if (!deck.hasKeyword("WELSPECS")) {
OPM_MESSAGE("Missing keyword \"WELSPECS\" in deck, initializing no wells.");
return;
}
if (!deck->hasKeyword("COMPDAT")) {
if (!deck.hasKeyword("COMPDAT")) {
OPM_MESSAGE("Missing keyword \"COMPDAT\" in deck, initializing no wells.");
return;
}
if (!(deck->hasKeyword("WCONINJE") || deck->hasKeyword("WCONPROD")) ) {
if (!(deck.hasKeyword("WCONINJE") || deck.hasKeyword("WCONPROD")) ) {
OPM_THROW(std::runtime_error, "Needed field is missing in file");
}
using namespace Opm;
// Get WELLSPECS data
const auto& welspecsKeyword = deck->getKeyword("WELSPECS");
const auto& welspecsKeyword = deck.getKeyword("WELSPECS");
const int num_welspecs = welspecsKeyword.size();
well_names_.reserve(num_welspecs);
well_data_.reserve(num_welspecs);
@ -152,7 +152,7 @@ namespace Opm
}
// Get COMPDAT data
const auto& compdatKeyword = deck->getKeyword("COMPDAT");
const auto& compdatKeyword = deck.getKeyword("COMPDAT");
const int num_compdats = compdatKeyword.size();
std::vector<std::vector<PerfData> > wellperf_data(num_welspecs);
for (int kw=0; kw<num_compdats; ++kw) {
@ -228,8 +228,8 @@ namespace Opm
// Get WCONINJE data
injection_mixture_ = 0.0;
if (deck->hasKeyword("WCONINJE")) {
const auto& wconinjeKeyword = deck->getKeyword("WCONINJE");
if (deck.hasKeyword("WCONINJE")) {
const auto& wconinjeKeyword = deck.getKeyword("WCONINJE");
const int num_wconinjes = wconinjeKeyword.size();
int injector_component = -1;
for (int kw=0; kw<num_wconinjes; ++kw) {
@ -308,8 +308,8 @@ namespace Opm
}
// Get WCONPROD data
if (deck->hasKeyword("WCONPROD")) {
const auto& wconprodKeyword = deck->getKeyword("WCONPROD");
if (deck.hasKeyword("WCONPROD")) {
const auto& wconprodKeyword = deck.getKeyword("WCONPROD");
const int num_wconprods = wconprodKeyword.size();
for (int kw=0; kw<num_wconprods; ++kw) {
const auto& wconprodRecord = wconprodKeyword.getRecord(kw);
@ -369,8 +369,8 @@ namespace Opm
}
// Get WELTARG data
if (deck->hasKeyword("WELTARG")) {
const auto& weltargKeyword = deck->getKeyword("WELTARG");
if (deck.hasKeyword("WELTARG")) {
const auto& weltargKeyword = deck.getKeyword("WELTARG");
const int num_weltargs = weltargKeyword.size();
for (int kw=0; kw<num_weltargs; ++kw) {
const auto& weltargRecord = weltargKeyword.getRecord(kw);

View File

@ -51,7 +51,7 @@ public:
typedef Opm::FluidSystems::BrineCO2</*Scalar=*/double, Opm::Benchmark3::CO2Tables> FluidSystem;
typedef Opm::CompositionalFluidState<double, FluidSystem> CompositionalFluidState;
void init(Opm::DeckConstPtr deck);
void init(const Opm::Deck& deck);
void generateBlackOilTables(double temperature);
@ -118,7 +118,7 @@ private:
// ------------ Method implementations --------------
void BlackoilCo2PVT::init(Opm::DeckConstPtr /* deck */)
void BlackoilCo2PVT::init(const Opm::Deck& /* deck */)
{
surfaceDensities_[Water] = 1000.;
surfaceDensities_[Gas] = 2.0;

View File

@ -41,16 +41,16 @@ namespace Opm
{
void BlackoilPVT::init(Opm::DeckConstPtr deck)
void BlackoilPVT::init(const Deck& deck)
{
Opm::ParseContext parseContext;
const auto eclipseState = std::make_shared<EclipseState>(deck , parseContext);
EclipseState eclipseState( deck , parseContext);
region_number_ = 0;
// Surface densities. Accounting for different orders in eclipse and our code.
if (deck->hasKeyword("DENSITY")) {
if (deck.hasKeyword("DENSITY")) {
const auto& densityRecord =
deck->getKeyword("DENSITY").getRecord(/*regionIdx=*/0);
deck.getKeyword("DENSITY").getRecord(/*regionIdx=*/0);
densities_[Aqua] = densityRecord.getItem("WATER").getSIDouble(0);
densities_[Vapour] = densityRecord.getItem("GAS").getSIDouble(0);
densities_[Liquid] = densityRecord.getItem("OIL").getSIDouble(0);
@ -59,14 +59,14 @@ namespace Opm
}
// Water PVT
if (deck->hasKeyword("PVTW")) {
water_props_.reset(new MiscibilityWater(deck->getKeyword("PVTW")));
if (deck.hasKeyword("PVTW")) {
water_props_.reset(new MiscibilityWater(deck.getKeyword("PVTW")));
} else {
water_props_.reset(new MiscibilityWater(0.5*Opm::prefix::centi*Opm::unit::Poise)); // Eclipse 100 default
}
// Oil PVT
const auto& tables = eclipseState->getTableManager();
const auto& tables = eclipseState.getTableManager();
const auto& pvdoTables = tables.getPvdoTables();
const auto& pvtoTables = tables.getPvtoTables();
if (!pvdoTables.empty()) {
@ -76,9 +76,9 @@ namespace Opm
// PVTOTables is a std::vector<>
const auto& pvtoTable = pvtoTables[0];
oil_props_.reset(new MiscibilityLiveOil(pvtoTable));
} else if (deck->hasKeyword("PVCDO")) {
} else if (deck.hasKeyword("PVCDO")) {
auto *misc_water = new MiscibilityWater(0);
misc_water->initFromPvcdo(deck->getKeyword("PVCDO"));
misc_water->initFromPvcdo(deck.getKeyword("PVCDO"));
oil_props_.reset(misc_water);
} else {
OPM_THROW(std::runtime_error, "Input is missing PVDO and PVTO\n");

View File

@ -33,7 +33,7 @@ namespace Opm
class BlackoilPVT : public BlackoilDefs
{
public:
void init(Opm::DeckConstPtr deck);
void init(const Deck& deck);
double getViscosity(double press,
const CompVec& surfvol,

View File

@ -44,7 +44,7 @@ class FluidMatrixInteractionBlackoilParams
{
public:
typedef ScalarT Scalar;
void init(Opm::DeckConstPtr deck)
void init(const Opm::Deck& deck)
{
ParseContext parseContext;
EclipseState eclipseState(deck , parseContext);

View File

@ -82,7 +82,7 @@ namespace Opm
/// pressure, if applicable.
/// @param sigma interface tension for j-scaling, if applicable.
/// @param theta angle for j-scaling, if applicable.
void init(Opm::DeckConstPtr deck,
void init(const Opm::Deck&,
const std::vector<int>& global_cell,
const double perm_threshold = 0.0,
const std::string* rock_list_filename = 0,
@ -211,18 +211,18 @@ namespace Opm
protected:
// Methods
void assignPorosity(Opm::DeckConstPtr deck,
void assignPorosity(const Opm::Deck& deck,
const std::vector<int>& global_cell);
void assignNTG(Opm::DeckConstPtr deck,
void assignNTG(const Opm::Deck& deck,
const std::vector<int>& global_cell);
void assignSWCR(Opm::DeckConstPtr deck,
void assignSWCR(const Opm::Deck& deck,
const std::vector<int>& global_cell);
void assignSOWCR(Opm::DeckConstPtr deck,
void assignSOWCR(const Opm::Deck& deck,
const std::vector<int>& global_cell);
void assignPermeability(Opm::DeckConstPtr deck,
void assignPermeability(const Opm::Deck& deck,
const std::vector<int>& global_cell,
const double perm_threshold);
void assignRockTable(Opm::DeckConstPtr deck,
void assignRockTable(const Opm::Deck& deck,
const std::vector<int>& global_cell);
void readRocks(const std::string& rock_list_file);

View File

@ -67,19 +67,19 @@ namespace Opm
/// TensorPerm at least one cross-component given.
/// None no components given.
/// Invalid invalid set of components given.
PermeabilityKind classifyPermeability(Opm::DeckConstPtr deck)
PermeabilityKind classifyPermeability(const Opm::Deck& deck)
{
const bool xx = deck->hasKeyword("PERMX" );
const bool xy = deck->hasKeyword("PERMXY");
const bool xz = deck->hasKeyword("PERMXZ");
const bool xx = deck.hasKeyword("PERMX" );
const bool xy = deck.hasKeyword("PERMXY");
const bool xz = deck.hasKeyword("PERMXZ");
const bool yx = deck->hasKeyword("PERMYX");
const bool yy = deck->hasKeyword("PERMY" );
const bool yz = deck->hasKeyword("PERMYZ");
const bool yx = deck.hasKeyword("PERMYX");
const bool yy = deck.hasKeyword("PERMY" );
const bool yz = deck.hasKeyword("PERMYZ");
const bool zx = deck->hasKeyword("PERMZX");
const bool zy = deck->hasKeyword("PERMZY");
const bool zz = deck->hasKeyword("PERMZ" );
const bool zx = deck.hasKeyword("PERMZX");
const bool zy = deck.hasKeyword("PERMZY");
const bool zz = deck.hasKeyword("PERMZ" );
int num_cross_comp = xy + xz + yx + yz + zx + zy;
int num_comp = xx + yy + zz + num_cross_comp;
@ -176,7 +176,7 @@ namespace Opm
/// @param [out] tensor
/// @param [out] kmap
inline
PermeabilityKind fillTensor(Opm::DeckConstPtr deck,
PermeabilityKind fillTensor(const Opm::Deck& deck,
std::vector<const std::vector<double>*>& tensor,
std::array<int,9>& kmap)
{
@ -193,51 +193,51 @@ namespace Opm
// -----------------------------------------------------------
// 1st row: [kxx, kxy, kxz]
if (deck->hasKeyword("PERMX" )) {
if (deck.hasKeyword("PERMX" )) {
kmap[xx] = tensor.size();
tensor.push_back(&deck->getKeyword("PERMX").getSIDoubleData());
tensor.push_back(&deck.getKeyword("PERMX").getSIDoubleData());
setScalarPermIfNeeded(kmap, xx, yy, zz);
}
if (deck->hasKeyword("PERMXY")) {
if (deck.hasKeyword("PERMXY")) {
kmap[xy] = kmap[yx] = tensor.size(); // Enforce symmetry.
tensor.push_back(&deck->getKeyword("PERMXY").getSIDoubleData());
tensor.push_back(&deck.getKeyword("PERMXY").getSIDoubleData());
}
if (deck->hasKeyword("PERMXZ")) {
if (deck.hasKeyword("PERMXZ")) {
kmap[xz] = kmap[zx] = tensor.size(); // Enforce symmetry.
tensor.push_back(&deck->getKeyword("PERMXZ").getSIDoubleData());
tensor.push_back(&deck.getKeyword("PERMXZ").getSIDoubleData());
}
// -----------------------------------------------------------
// 2nd row: [kyx, kyy, kyz]
if (deck->hasKeyword("PERMYX")) {
if (deck.hasKeyword("PERMYX")) {
kmap[yx] = kmap[xy] = tensor.size(); // Enforce symmetry.
tensor.push_back(&deck->getKeyword("PERMYX").getSIDoubleData());
tensor.push_back(&deck.getKeyword("PERMYX").getSIDoubleData());
}
if (deck->hasKeyword("PERMY" )) {
if (deck.hasKeyword("PERMY" )) {
kmap[yy] = tensor.size();
tensor.push_back(&deck->getKeyword("PERMY").getSIDoubleData());
tensor.push_back(&deck.getKeyword("PERMY").getSIDoubleData());
setScalarPermIfNeeded(kmap, yy, zz, xx);
}
if (deck->hasKeyword("PERMYZ")) {
if (deck.hasKeyword("PERMYZ")) {
kmap[yz] = kmap[zy] = tensor.size(); // Enforce symmetry.
tensor.push_back(&deck->getKeyword("PERMYZ").getSIDoubleData());
tensor.push_back(&deck.getKeyword("PERMYZ").getSIDoubleData());
}
// -----------------------------------------------------------
// 3rd row: [kzx, kzy, kzz]
if (deck->hasKeyword("PERMZX")) {
if (deck.hasKeyword("PERMZX")) {
kmap[zx] = kmap[xz] = tensor.size(); // Enforce symmetry.
tensor.push_back(&deck->getKeyword("PERMZX").getSIDoubleData());
tensor.push_back(&deck.getKeyword("PERMZX").getSIDoubleData());
}
if (deck->hasKeyword("PERMZY")) {
if (deck.hasKeyword("PERMZY")) {
kmap[zy] = kmap[yz] = tensor.size(); // Enforce symmetry.
tensor.push_back(&deck->getKeyword("PERMZY").getSIDoubleData());
tensor.push_back(&deck.getKeyword("PERMZY").getSIDoubleData());
}
if (deck->hasKeyword("PERMZ" )) {
if (deck.hasKeyword("PERMZ" )) {
kmap[zz] = tensor.size();
tensor.push_back(&deck->getKeyword("PERMZ").getSIDoubleData());
tensor.push_back(&deck.getKeyword("PERMZ").getSIDoubleData());
setScalarPermIfNeeded(kmap, zz, xx, yy);
}
@ -273,7 +273,7 @@ namespace Opm
template <int dim, class RPImpl, class RockType>
void ReservoirPropertyCommon<dim, RPImpl, RockType>::init(Opm::DeckConstPtr deck,
void ReservoirPropertyCommon<dim, RPImpl, RockType>::init(const Opm::Deck& deck,
const std::vector<int>& global_cell,
const double perm_threshold,
const std::string* rock_list_filename,
@ -590,16 +590,16 @@ namespace Opm
template <int dim, class RPImpl, class RockType>
void ReservoirPropertyCommon<dim, RPImpl, RockType>::assignPorosity(Opm::DeckConstPtr deck,
void ReservoirPropertyCommon<dim, RPImpl, RockType>::assignPorosity(const Opm::Deck& deck,
const std::vector<int>& global_cell)
{
porosity_.assign(global_cell.size(), 1.0);
if (deck->hasKeyword("PORO")) {
if (deck.hasKeyword("PORO")) {
Opm::EclipseGridInspector insp(deck);
std::array<int, 3> dims = insp.gridSize();
int num_global_cells = dims[0]*dims[1]*dims[2];
const std::vector<double>& poro = deck->getKeyword("PORO").getSIDoubleData();
const std::vector<double>& poro = deck.getKeyword("PORO").getSIDoubleData();
if (int(poro.size()) != num_global_cells) {
OPM_THROW(std::runtime_error, "PORO field must have the same size as the "
"logical cartesian size of the grid: "
@ -612,16 +612,16 @@ namespace Opm
}
template <int dim, class RPImpl, class RockType>
void ReservoirPropertyCommon<dim, RPImpl, RockType>::assignNTG(Opm::DeckConstPtr deck,
void ReservoirPropertyCommon<dim, RPImpl, RockType>::assignNTG(const Opm::Deck& deck,
const std::vector<int>& global_cell)
{
ntg_.assign(global_cell.size(), 1.0);
if (deck->hasKeyword("NTG")) {
if (deck.hasKeyword("NTG")) {
Opm::EclipseGridInspector insp(deck);
std::array<int, 3> dims = insp.gridSize();
int num_global_cells = dims[0]*dims[1]*dims[2];
const std::vector<double>& ntg = deck->getKeyword("NTG").getSIDoubleData();
const std::vector<double>& ntg = deck.getKeyword("NTG").getSIDoubleData();
if (int(ntg.size()) != num_global_cells) {
OPM_THROW(std::runtime_error, "NTG field must have the same size as the "
"logical cartesian size of the grid: "
@ -634,17 +634,17 @@ namespace Opm
}
template <int dim, class RPImpl, class RockType>
void ReservoirPropertyCommon<dim, RPImpl, RockType>::assignSWCR(Opm::DeckConstPtr deck,
void ReservoirPropertyCommon<dim, RPImpl, RockType>::assignSWCR(const Opm::Deck& deck,
const std::vector<int>& global_cell)
{
swcr_.assign(global_cell.size(), 0.0);
if (deck->hasKeyword("SWCR")) {
if (deck.hasKeyword("SWCR")) {
Opm::EclipseGridInspector insp(deck);
std::array<int, 3> dims = insp.gridSize();
int num_global_cells = dims[0]*dims[1]*dims[2];
const std::vector<double>& swcr =
deck->getKeyword("SWCR").getSIDoubleData();
deck.getKeyword("SWCR").getSIDoubleData();
if (int(swcr.size()) != num_global_cells) {
OPM_THROW(std::runtime_error, "SWCR field must have the same size as the "
"logical cartesian size of the grid: "
@ -657,17 +657,17 @@ namespace Opm
}
template <int dim, class RPImpl, class RockType>
void ReservoirPropertyCommon<dim, RPImpl, RockType>::assignSOWCR(Opm::DeckConstPtr deck,
void ReservoirPropertyCommon<dim, RPImpl, RockType>::assignSOWCR(const Opm::Deck& deck,
const std::vector<int>& global_cell)
{
sowcr_.assign(global_cell.size(), 0.0);
if (deck->hasKeyword("SOWCR")) {
if (deck.hasKeyword("SOWCR")) {
Opm::EclipseGridInspector insp(deck);
std::array<int, 3> dims = insp.gridSize();
int num_global_cells = dims[0]*dims[1]*dims[2];
const std::vector<double>& sowcr =
deck->getKeyword("SOWCR").getSIDoubleData();
deck.getKeyword("SOWCR").getSIDoubleData();
if (int(sowcr.size()) != num_global_cells) {
OPM_THROW(std::runtime_error, "SOWCR field must have the same size as the "
"logical cartesian size of the grid: "
@ -680,7 +680,7 @@ namespace Opm
}
template <int dim, class RPImpl, class RockType>
void ReservoirPropertyCommon<dim, RPImpl, RockType>::assignPermeability(Opm::DeckConstPtr deck,
void ReservoirPropertyCommon<dim, RPImpl, RockType>::assignPermeability(const Opm::Deck& deck,
const std::vector<int>& global_cell,
double perm_threshold)
{
@ -740,18 +740,18 @@ namespace Opm
template <int dim, class RPImpl, class RockType>
void ReservoirPropertyCommon<dim, RPImpl, RockType>::assignRockTable(Opm::DeckConstPtr deck,
void ReservoirPropertyCommon<dim, RPImpl, RockType>::assignRockTable(const Opm::Deck& deck,
const std::vector<int>& global_cell)
{
const int nc = global_cell.size();
cell_to_rock_.assign(nc, 0);
if (deck->hasKeyword("SATNUM")) {
if (deck.hasKeyword("SATNUM")) {
Opm::EclipseGridInspector insp(deck);
std::array<int, 3> dims = insp.gridSize();
int num_global_cells = dims[0]*dims[1]*dims[2];
const std::vector<int>& satnum = deck->getKeyword("SATNUM").getIntData();
const std::vector<int>& satnum = deck.getKeyword("SATNUM").getIntData();
if (int(satnum.size()) != num_global_cells) {
OPM_THROW(std::runtime_error, "SATNUM field must have the same size as the "
"logical cartesian size of the grid: "
@ -762,11 +762,11 @@ namespace Opm
cell_to_rock_[c] = satnum[global_cell[c]] - 1;
}
}
else if (deck->hasKeyword("ROCKTYPE")) {
else if (deck.hasKeyword("ROCKTYPE")) {
Opm::EclipseGridInspector insp(deck);
std::array<int, 3> dims = insp.gridSize();
int num_global_cells = dims[0]*dims[1]*dims[2];
const std::vector<int>& satnum = deck->getKeyword("ROCKTYPE").getIntData();
const std::vector<int>& satnum = deck.getKeyword("ROCKTYPE").getIntData();
if (int(satnum.size()) != num_global_cells) {
OPM_THROW(std::runtime_error, "ROCKTYPE field must have the same size as the "
"logical cartesian size of the grid: "

View File

@ -58,7 +58,7 @@ namespace Opm
/// pressure, if applicable.
/// @param sigma interface tension for j-scaling, if applicable.
/// @param theta angle for j-scaling, if applicable.
void init(Opm::DeckConstPtr deck,
void init(const Opm::Deck& deck,
const std::vector<int>& global_cell,
const double perm_threshold = 0.0);
@ -88,9 +88,9 @@ namespace Opm
protected:
// Methods
void assignPorosity(Opm::DeckConstPtr deck,
void assignPorosity(const Opm::Deck& deck,
const std::vector<int>& global_cell);
void assignPermeability(Opm::DeckConstPtr deck,
void assignPermeability(const Opm::Deck& deck,
const std::vector<int>& global_cell,
const double perm_threshold);

View File

@ -41,7 +41,7 @@ namespace Opm
template <int dim>
void Rock<dim>::init(Opm::DeckConstPtr deck,
void Rock<dim>::init(const Opm::Deck& deck,
const std::vector<int>& global_cell,
const double perm_threshold)
{
@ -112,13 +112,13 @@ namespace Opm
template <int dim>
void Rock<dim>::assignPorosity(Opm::DeckConstPtr deck,
void Rock<dim>::assignPorosity(const Opm::Deck& deck,
const std::vector<int>& global_cell)
{
porosity_.assign(global_cell.size(), 1.0);
if (deck->hasKeyword("PORO")) {
const std::vector<double>& poro = deck->getKeyword("PORO").getSIDoubleData();
if (deck.hasKeyword("PORO")) {
const std::vector<double>& poro = deck.getKeyword("PORO").getSIDoubleData();
for (int c = 0; c < int(porosity_.size()); ++c) {
porosity_[c] = poro[global_cell[c]];
@ -129,7 +129,7 @@ namespace Opm
template <int dim>
void Rock<dim>::assignPermeability(Opm::DeckConstPtr deck,
void Rock<dim>::assignPermeability(const Opm::Deck& deck,
const std::vector<int>& global_cell,
double perm_threshold)
{

View File

@ -83,8 +83,8 @@ namespace Opm
std::string ecl_file = param.get<std::string>("filename");
Opm::ParseContext parseContext;
Opm::ParserPtr parser(new Opm::Parser());
Opm::DeckConstPtr deck(parser->parseFile(ecl_file , parseContext));
Opm::Parser parser;
auto deck = parser.parseFile(ecl_file , parseContext);
if (param.has("z_tolerance")) {
std::cerr << "****** Warning: z_tolerance parameter is obsolete, use PINCH in deck input instead\n";
}
@ -147,7 +147,7 @@ namespace Opm
/// @todo Doc me!
/// @param
template <template <int> class ResProp>
inline void setupGridAndPropsEclipse(Opm::DeckConstPtr deck,
inline void setupGridAndPropsEclipse(const Opm::Deck& deck,
bool periodic_extension,
bool turn_normals,
bool clip_z,

View File

@ -0,0 +1,456 @@
/*
Copyright 2010 SINTEF ICT, Applied Mathematics.
This file is part of the Open Porous Media project (OPM).
OPM is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OPM is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with OPM. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef OPM_CORNERPOINTCHOPPER_HEADER_INCLUDED
#define OPM_CORNERPOINTCHOPPER_HEADER_INCLUDED
#include <opm/parser/eclipse/Parser/Parser.hpp>
#include <opm/parser/eclipse/Parser/ParseContext.hpp>
#include <opm/parser/eclipse/Units/UnitSystem.hpp>
#include <opm/parser/eclipse/Deck/Deck.hpp>
#include <opm/parser/eclipse/Deck/DeckKeyword.hpp>
#include <opm/parser/eclipse/Deck/DeckRecord.hpp>
#include <opm/parser/eclipse/Deck/DeckItem.hpp>
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <stdexcept>
#include <memory>
namespace Opm
{
class CornerPointChopper
{
public:
CornerPointChopper(const std::string& file)
{
Opm::ParseContext parseContext;
Opm::Parser parser;
deck_ = parser.parseFile(file , parseContext);
metricUnits_ = Opm::UnitSystem::newMETRIC();
const auto& specgridRecord = deck_.getKeyword("SPECGRID").getRecord(0);
dims_[0] = specgridRecord.getItem("NX").get< int >(0);
dims_[1] = specgridRecord.getItem("NY").get< int >(0);
dims_[2] = specgridRecord.getItem("NZ").get< int >(0);
int layersz = 8*dims_[0]*dims_[1];
const std::vector<double>& ZCORN = deck_.getKeyword("ZCORN").getRawDoubleData();
botmax_ = *std::max_element(ZCORN.begin(), ZCORN.begin() + layersz/2);
topmin_ = *std::min_element(ZCORN.begin() + dims_[2]*layersz - layersz/2,
ZCORN.begin() + dims_[2]*layersz);
abszmax_ = *std::max_element(ZCORN.begin(), ZCORN.end());
abszmin_ = *std::min_element(ZCORN.begin(), ZCORN.end());
std::cout << "Parsed grdecl file with dimensions ("
<< dims_[0] << ", " << dims_[1] << ", " << dims_[2] << ")" << std::endl;
}
const int* dimensions() const
{
return dims_;
}
const int* newDimensions() const
{
return new_dims_;
}
const std::pair<double, double> zLimits() const
{
return std::make_pair(botmax_, topmin_);
}
const std::pair<double, double> abszLimits() const
{
return std::make_pair(abszmin_, abszmax_);
}
void verifyInscribedShoebox(int imin, int ilen, int imax,
int jmin, int jlen, int jmax,
double zmin, double zlen, double zmax)
{
if (imin < 0) {
std::cerr << "Error! imin < 0 (imin = " << imin << ")\n";
throw std::runtime_error("Inconsistent user input.");
}
if (ilen > dims_[0]) {
std::cerr << "Error! ilen larger than grid (ilen = " << ilen <<")\n";
throw std::runtime_error("Inconsistent user input.");
}
if (imax > dims_[0]) {
std::cerr << "Error! imax larger than input grid (imax = " << imax << ")\n";
throw std::runtime_error("Inconsistent user input.");
}
if (jmin < 0) {
std::cerr << "Error! jmin < 0 (jmin = " << jmin << ")\n";
throw std::runtime_error("Inconsistent user input.");
}
if (jlen > dims_[1]) {
std::cerr << "Error! jlen larger than grid (jlen = " << jlen <<")\n";
throw std::runtime_error("Inconsistent user input.");
}
if (jmax > dims_[1]) {
std::cerr << "Error! jmax larger than input grid (jmax = " << jmax << ")\n";
throw std::runtime_error("Inconsistent user input.");
}
if (zmin < abszmin_) {
std::cerr << "Error! zmin ("<< zmin << ") less than minimum ZCORN value ("<< abszmin_ << ")\n";
throw std::runtime_error("Inconsistent user input.");
}
if (zmax > abszmax_) {
std::cerr << "Error! zmax ("<< zmax << ") larger than maximal ZCORN value ("<< abszmax_ << ")\n";
throw std::runtime_error("Inconsistent user input.");
}
if (zlen > (abszmax_ - abszmin_)) {
std::cerr << "Error! zlen ("<< zlen <<") larger than maximal ZCORN (" << abszmax_ << ") minus minimal ZCORN ("<< abszmin_ <<")\n";
throw std::runtime_error("Inconsistent user input.");
}
}
void chop(int imin, int imax, int jmin, int jmax, double zmin, double zmax, bool resettoorigin=true)
{
new_dims_[0] = imax - imin;
new_dims_[1] = jmax - jmin;
// Filter the coord field
const std::vector<double>& COORD = deck_.getKeyword("COORD").getRawDoubleData();
int num_coord = COORD.size();
if (num_coord != 6*(dims_[0] + 1)*(dims_[1] + 1)) {
std::cerr << "Error! COORD size (" << COORD.size() << ") not consistent with SPECGRID\n";
throw std::runtime_error("Inconsistent COORD and SPECGRID.");
}
int num_new_coord = 6*(new_dims_[0] + 1)*(new_dims_[1] + 1);
double x_correction = COORD[6*((dims_[0] + 1)*jmin + imin)];
double y_correction = COORD[6*((dims_[0] + 1)*jmin + imin) + 1];
new_COORD_.resize(num_new_coord, 1e100);
for (int j = jmin; j < jmax + 1; ++j) {
for (int i = imin; i < imax + 1; ++i) {
int pos = (dims_[0] + 1)*j + i;
int new_pos = (new_dims_[0] + 1)*(j-jmin) + (i-imin);
// Copy all 6 coordinates for a pillar.
std::copy(COORD.begin() + 6*pos, COORD.begin() + 6*(pos + 1), new_COORD_.begin() + 6*new_pos);
if (resettoorigin) {
// Substract lowest x value from all X-coords, similarly for y, and truncate in z-direction
new_COORD_[6*new_pos] -= x_correction;
new_COORD_[6*new_pos + 1] -= y_correction;
new_COORD_[6*new_pos + 2] = 0;
new_COORD_[6*new_pos + 3] -= x_correction;
new_COORD_[6*new_pos + 4] -= y_correction;
new_COORD_[6*new_pos + 5] = zmax-zmin;
}
}
}
// Get the z limits, check if they must be changed to make a shoe-box.
// This means that zmin must be greater than or equal to the highest
// coordinate of the bottom surface, while zmax must be less than or
// equal to the lowest coordinate of the top surface.
int layersz = 8*dims_[0]*dims_[1];
const std::vector<double>& ZCORN = deck_.getKeyword("ZCORN").getRawDoubleData();
int num_zcorn = ZCORN.size();
if (num_zcorn != layersz*dims_[2]) {
std::cerr << "Error! ZCORN size (" << ZCORN.size() << ") not consistent with SPECGRID\n";
throw std::runtime_error("Inconsistent ZCORN and SPECGRID.");
}
zmin = std::max(zmin, botmax_);
zmax = std::min(zmax, topmin_);
if (zmin >= zmax) {
std::cerr << "Error: zmin >= zmax (zmin = " << zmin << ", zmax = " << zmax << ")\n";
throw std::runtime_error("zmin >= zmax");
}
std::cout << "Chopping subsample, i: (" << imin << "--" << imax << ") j: (" << jmin << "--" << jmax << ") z: (" << zmin << "--" << zmax << ")" << std::endl;
// We must find the maximum and minimum k value for the given z limits.
// First, find the first layer with a z-coordinate strictly above zmin.
int kmin = -1;
for (int k = 0; k < dims_[2]; ++k) {
double layer_max = *std::max_element(ZCORN.begin() + k*layersz, ZCORN.begin() + (k + 1)*layersz);
if (layer_max > zmin) {
kmin = k;
break;
}
}
// Then, find the last layer with a z-coordinate strictly below zmax.
int kmax = -1;
for (int k = dims_[2]; k > 0; --k) {
double layer_min = *std::min_element(ZCORN.begin() + (k - 1)*layersz, ZCORN.begin() + k*layersz);
if (layer_min < zmax) {
kmax = k;
break;
}
}
new_dims_[2] = kmax - kmin;
// Filter the ZCORN field, build mapping from new to old cells.
double z_origin_correction = 0.0;
if (resettoorigin) {
z_origin_correction = zmin;
}
new_ZCORN_.resize(8*new_dims_[0]*new_dims_[1]*new_dims_[2], 1e100);
new_to_old_cell_.resize(new_dims_[0]*new_dims_[1]*new_dims_[2], -1);
int cellcount = 0;
int delta[3] = { 1, 2*dims_[0], 4*dims_[0]*dims_[1] };
int new_delta[3] = { 1, 2*new_dims_[0], 4*new_dims_[0]*new_dims_[1] };
for (int k = kmin; k < kmax; ++k) {
for (int j = jmin; j < jmax; ++j) {
for (int i = imin; i < imax; ++i) {
new_to_old_cell_[cellcount++] = dims_[0]*dims_[1]*k + dims_[0]*j + i;
int old_ix = 2*(i*delta[0] + j*delta[1] + k*delta[2]);
int new_ix = 2*((i-imin)*new_delta[0] + (j-jmin)*new_delta[1] + (k-kmin)*new_delta[2]);
int old_indices[8] = { old_ix, old_ix + delta[0],
old_ix + delta[1], old_ix + delta[1] + delta[0],
old_ix + delta[2], old_ix + delta[2] + delta[0],
old_ix + delta[2] + delta[1], old_ix + delta[2] + delta[1] + delta[0] };
int new_indices[8] = { new_ix, new_ix + new_delta[0],
new_ix + new_delta[1], new_ix + new_delta[1] + new_delta[0],
new_ix + new_delta[2], new_ix + new_delta[2] + new_delta[0],
new_ix + new_delta[2] + new_delta[1], new_ix + new_delta[2] + new_delta[1] + new_delta[0] };
for (int cc = 0; cc < 8; ++cc) {
new_ZCORN_[new_indices[cc]] = std::min(zmax, std::max(zmin, ZCORN[old_indices[cc]])) - z_origin_correction;
}
}
}
}
filterIntegerField("ACTNUM", new_ACTNUM_);
filterDoubleField("PORO", new_PORO_);
filterDoubleField("NTG", new_NTG_);
filterDoubleField("SWCR", new_SWCR_);
filterDoubleField("SOWCR", new_SOWCR_);
filterDoubleField("PERMX", new_PERMX_);
filterDoubleField("PERMY", new_PERMY_);
filterDoubleField("PERMZ", new_PERMZ_);
filterIntegerField("SATNUM", new_SATNUM_);
}
/// Return a sub-deck with fields corresponding to the selected subset.
Opm::Deck subDeck()
{
Opm::Deck subDeck;
Opm::DeckKeyword specGridKw("SPECGRID");
Opm::DeckRecord specGridRecord;
auto nxItem = Opm::DeckItem::make< int >("NX");
auto nyItem = Opm::DeckItem::make< int >("NY");
auto nzItem = Opm::DeckItem::make< int >("NZ");
auto numresItem = Opm::DeckItem::make< int >("NUMRES");
auto coordTypeItem = Opm::DeckItem::make< std::string >("COORD_TYPE");
nxItem.push_back(new_dims_[0]);
nyItem.push_back(new_dims_[1]);
nzItem.push_back(new_dims_[2]);
numresItem.push_back(1);
coordTypeItem.push_back("F");
specGridRecord.addItem(std::move(nxItem));
specGridRecord.addItem(std::move(nyItem));
specGridRecord.addItem(std::move(nzItem));
specGridRecord.addItem(std::move(numresItem));
specGridRecord.addItem(std::move(coordTypeItem));
specGridKw.addRecord(std::move(specGridRecord));
subDeck.addKeyword(std::move(specGridKw));
addDoubleKeyword_(subDeck, "COORD", /*dimension=*/"Length", new_COORD_);
addDoubleKeyword_(subDeck, "ZCORN", /*dimension=*/"Length", new_ZCORN_);
addIntKeyword_(subDeck, "ACTNUM", new_ACTNUM_);
addDoubleKeyword_(subDeck, "PORO", /*dimension=*/"1", new_PORO_);
addDoubleKeyword_(subDeck, "NTG", /*dimension=*/"1", new_NTG_);
addDoubleKeyword_(subDeck, "SWCR", /*dimension=*/"1", new_SWCR_);
addDoubleKeyword_(subDeck, "SOWCR", /*dimension=*/"1", new_SOWCR_);
addDoubleKeyword_(subDeck, "PERMX", /*dimension=*/"Permeability", new_PERMX_);
addDoubleKeyword_(subDeck, "PERMY", /*dimension=*/"Permeability", new_PERMY_);
addDoubleKeyword_(subDeck, "PERMZ", /*dimension=*/"Permeability", new_PERMZ_);
addIntKeyword_(subDeck, "SATNUM", new_SATNUM_);
return subDeck;
}
void writeGrdecl(const std::string& filename)
{
// Output new versions of SPECGRID, COORD, ZCORN, ACTNUM, PERMX, PORO, SATNUM.
std::ofstream out(filename.c_str());
if (!out) {
std::cerr << "Could not open file " << filename << "\n";
throw std::runtime_error("Could not open output file.");
}
out << "SPECGRID\n" << new_dims_[0] << ' ' << new_dims_[1] << ' ' << new_dims_[2]
<< " 1 F\n/\n\n";
out.precision(15);
out.setf(std::ios::scientific);
outputField(out, new_COORD_, "COORD", /* nl = */ 3);
outputField(out, new_ZCORN_, "ZCORN", /* nl = */ 4);
outputField(out, new_ACTNUM_, "ACTNUM");
outputField(out, new_PORO_, "PORO", 4);
if (hasNTG()) {outputField(out, new_NTG_, "NTG", 4);}
if (hasSWCR()) {outputField(out, new_SWCR_, "SWCR", 4);}
if (hasSOWCR()) {outputField(out, new_SOWCR_, "SOWCR", 4);}
outputField(out, new_PERMX_, "PERMX", 4);
outputField(out, new_PERMY_, "PERMY", 4);
outputField(out, new_PERMZ_, "PERMZ", 4);
outputField(out, new_SATNUM_, "SATNUM");
}
bool hasNTG() const {return !new_NTG_.empty(); }
bool hasSWCR() const {return !new_SWCR_.empty(); }
bool hasSOWCR() const {return !new_SOWCR_.empty(); }
private:
Opm::Deck deck_;
Opm::UnitSystem metricUnits_;
double botmax_;
double topmin_;
double abszmin_;
double abszmax_;
std::vector<double> new_COORD_;
std::vector<double> new_ZCORN_;
std::vector<int> new_ACTNUM_;
std::vector<double> new_PORO_;
std::vector<double> new_NTG_;
std::vector<double> new_SWCR_;
std::vector<double> new_SOWCR_;
std::vector<double> new_PERMX_;
std::vector<double> new_PERMY_;
std::vector<double> new_PERMZ_;
std::vector<int> new_SATNUM_;
int dims_[3];
int new_dims_[3];
std::vector<int> new_to_old_cell_;
void addDoubleKeyword_(Deck& subDeck,
const std::string& keywordName,
const std::string& dimensionString,
const std::vector<double>& data)
{
if (data.empty())
return;
Opm::DeckKeyword dataKw(keywordName);
Opm::DeckRecord dataRecord;
auto dataItem = Opm::DeckItem::make< double >("DATA");
for (size_t i = 0; i < data.size(); ++i) {
dataItem.push_back(data[i]);
}
auto dimension = metricUnits_.parse(dimensionString);
dataItem.push_backDimension(/*active=*/dimension, /*default=*/dimension);
dataRecord.addItem(std::move(dataItem));
dataKw.addRecord(std::move(dataRecord));
subDeck.addKeyword(std::move(dataKw));
}
void addIntKeyword_(Deck& subDeck,
const std::string& keywordName,
const std::vector<int>& data)
{
if (data.empty())
return;
Opm::DeckKeyword dataKw(keywordName);
Opm::DeckRecord dataRecord;
auto dataItem = Opm::DeckItem::make< int >("DATA");
for (size_t i = 0; i < data.size(); ++i) {
dataItem.push_back(data[i]);
}
dataRecord.addItem(std::move(dataItem));
dataKw.addRecord(std::move(dataRecord));
subDeck.addKeyword(std::move(dataKw));
}
template <typename T>
void outputField(std::ostream& os,
const std::vector<T>& field,
const std::string& keyword,
const typename std::vector<T>::size_type nl = 20)
{
if (field.empty()) return;
os << keyword << '\n';
typedef typename std::vector<T>::size_type sz_t;
const sz_t n = field.size();
for (sz_t i = 0; i < n; ++i) {
os << field[i]
<< (((i + 1) % nl == 0) ? '\n' : ' ');
}
if (n % nl != 0) {
os << '\n';
}
os << "/\n\n";
}
template <typename T>
void filterField(const std::vector<T>& field,
std::vector<T>& output_field)
{
int sz = new_to_old_cell_.size();
output_field.resize(sz);
for (int i = 0; i < sz; ++i) {
output_field[i] = field[new_to_old_cell_[i]];
}
}
void filterDoubleField(const std::string& keyword, std::vector<double>& output_field)
{
if (deck_.hasKeyword(keyword)) {
const std::vector<double>& field = deck_.getKeyword(keyword).getRawDoubleData();
filterField(field, output_field);
}
}
void filterIntegerField(const std::string& keyword, std::vector<int>& output_field)
{
if (deck_.hasKeyword(keyword)) {
const std::vector<int>& field = deck_.getKeyword(keyword).getIntData();
filterField(field, output_field);
}
}
};
}
#endif // OPM_CORNERPOINTCHOPPER_HEADER_INCLUDED

View File

@ -387,7 +387,7 @@ void RelPermUpscaleHelper::upscaleSinglePhasePermeability()
}
}
void RelPermUpscaleHelper::sanityCheckInput(Opm::DeckConstPtr deck,
void RelPermUpscaleHelper::sanityCheckInput(const Opm::Deck& deck,
const double minPerm,
const double maxPerm,
const double minPoro)
@ -400,24 +400,24 @@ void RelPermUpscaleHelper::sanityCheckInput(Opm::DeckConstPtr deck,
using kw_satnum = ParserKeywords::SATNUM;
// Check that we have the information we need from the eclipse file:
if (! (deck->hasKeyword<kw_poro >() &&
deck->hasKeyword<kw_permx>()))
if (! (deck.hasKeyword<kw_poro >() &&
deck.hasKeyword<kw_permx>()))
{
throw std::runtime_error("Error: Did not find complete set of "
"PORO and PERMX in ECLIPSE file.");
}
poros = deck->getKeyword<kw_poro >().getSIDoubleData();
perms[0] = deck->getKeyword<kw_permx>().getSIDoubleData();
poros = deck.getKeyword<kw_poro >().getSIDoubleData();
perms[0] = deck.getKeyword<kw_permx>().getSIDoubleData();
EclipseGrid(deck).exportZCORN(zcorns);
// Load anisotropic (only diagonal supported) input if present in grid
if (deck->hasKeyword<kw_permy>() && deck->hasKeyword<kw_permz>()) {
if (deck.hasKeyword<kw_permy>() && deck.hasKeyword<kw_permz>()) {
anisotropic_input = true;
perms[1] = deck->getKeyword<kw_permy>().getSIDoubleData();
perms[2] = deck->getKeyword<kw_permz>().getSIDoubleData();
perms[1] = deck.getKeyword<kw_permy>().getSIDoubleData();
perms[2] = deck.getKeyword<kw_permz>().getSIDoubleData();
if (isMaster) {
std::cout << "Info: PERMY and PERMZ present, going into "
@ -427,8 +427,8 @@ void RelPermUpscaleHelper::sanityCheckInput(Opm::DeckConstPtr deck,
}
}
if (deck->hasKeyword<kw_satnum>()) {
satnums = deck->getKeyword<kw_satnum>().getIntData();
if (deck.hasKeyword<kw_satnum>()) {
satnums = deck.getKeyword<kw_satnum>().getIntData();
}
else {
if (isMaster) {
@ -647,7 +647,7 @@ void RelPermUpscaleHelper::setupBoundaryConditions()
throw std::runtime_error("Invalid boundary condition. Only one of the letters f, l or p are allowed.");
}
double RelPermUpscaleHelper::tesselateGrid(Opm::DeckConstPtr deck)
double RelPermUpscaleHelper::tesselateGrid(const Opm::Deck& deck)
{
const auto linsolver_tolerance = to_double(options["linsolver_tolerance"]);
const auto linsolver_verbosity = to_int (options["linsolver_verbosity"]);

View File

@ -84,7 +84,7 @@ namespace Opm {
//!
//! \return Deck object resulting from parsing input file.
template <class String>
static std::shared_ptr<Deck>
static Deck
parseEclipseFile(const String& eclipseFileName);
//! \brief Default constructor.
@ -111,7 +111,7 @@ namespace Opm {
//! \param[in] maxPerm Maximum permeability.
//! \param[in] minPoro Minimum porosity.
//! \details Throws error string.
void sanityCheckInput(Opm::DeckConstPtr deck,
void sanityCheckInput(const Opm::Deck& deck,
const double minPerm,
const double maxPerm,
const double minPoro);
@ -130,7 +130,7 @@ namespace Opm {
//! linsolver_verbosity, linsolver_type, linsolver_max_iterations,
//! linsolver_smooth_steps, linsolver_prolongate_factor, minPerm
//! \return Time used for tesselation.
double tesselateGrid(Opm::DeckConstPtr deck);
double tesselateGrid(const Opm::Deck& deck);
//! \brief Find cell center pressure gradient for every cell.
//! \details Uses the following options: gravity, waterDensity, oilDensity
@ -188,7 +188,7 @@ namespace Opm {
};
template <class String>
std::shared_ptr<Deck>
Deck
RelPermUpscaleHelper::parseEclipseFile(const String& eclipseFileName)
{
auto parser = Parser{};

View File

@ -78,7 +78,7 @@ namespace Opm
void init(const Opm::parameter::ParameterGroup& param);
/// Initializes the upscaler from given arguments.
void init(Opm::DeckConstPtr deck,
void init(const Opm::Deck& deck,
BoundaryConditionType bctype,
double perm_threshold,
double residual_tolerance = 1e-8,

View File

@ -128,7 +128,7 @@ namespace Opm
template <class Traits>
inline void UpscalerBase<Traits>::init(Opm::DeckConstPtr deck,
inline void UpscalerBase<Traits>::init(const Opm::Deck& deck,
BoundaryConditionType bctype,
double perm_threshold,
double residual_tolerance,

View File

@ -59,9 +59,9 @@ void Opm::initCPGrid(Dune::CpGrid& grid, const Opm::parameter::ParameterGroup& p
}
bool periodic_extension = param.getDefault<bool>("periodic_extension", false);
bool turn_normals = param.getDefault<bool>("turn_normals", false);
Opm::ParserPtr parser(new Opm::Parser());
Opm::Parser parser;
Opm::ParseContext parseContext;
Opm::DeckConstPtr deck = parser->parseFile(filename, parseContext);
auto deck = parser.parseFile(filename, parseContext);
Opm::EclipseGrid inputGrid(deck);
grid.processEclipseFormat(inputGrid, periodic_extension , turn_normals );
} else if (fileformat == "cartesian") {