Using getInputGrid API from Parser, changed GridManager to no longer accept Deck in constructor

This commit is contained in:
Pål Grønås Drange 2016-04-19 17:00:01 +02:00
parent 668cd14755
commit 973438128c
19 changed files with 73 additions and 57 deletions

View File

@ -90,7 +90,7 @@ try
Opm::DeckConstPtr deck = parser->parseFile(deck_filename , parseContext);
Opm::EclipseStateConstPtr eclipseState(new Opm::EclipseState(deck, parseContext));
const double grav = param.getDefault("gravity", unit::gravity);
GridManager gm(deck);
GridManager gm(eclipseState->getInputGrid());
const UnstructuredGrid& grid = *gm.c_grid();
BlackoilPropertiesFromDeck props(deck, eclipseState, grid, param);
warnIfUnusedParams(param);

View File

@ -177,7 +177,7 @@ try
EclipseStateConstPtr eclipseState = std::make_shared<EclipseState>(deck , parseContext);
// Grid init
GridManager grid_manager(deck);
GridManager grid_manager(eclipseState->getInputGrid());
const UnstructuredGrid& grid = *grid_manager.c_grid();
// Rock and fluid init
IncompPropertiesSinglePhase props(deck, eclipseState, grid);

View File

@ -78,7 +78,7 @@ try
Opm::DeckConstPtr deck(parser->parseFile(eclipseFilename, parseContext));
eclState.reset(new EclipseState(deck, parseContext));
GridManager gm(deck);
GridManager gm(eclState->getInputGrid());
const UnstructuredGrid& grid = *gm.c_grid();
using boost::filesystem::path;
path fpath(eclipseFilename);

View File

@ -42,7 +42,7 @@ try
std::cout << "Done!" << std::endl;
// Setup grid
GridManager grid(deck);
GridManager grid(eclipseState->getInputGrid());
// Define rock and fluid properties
IncompPropertiesFromDeck incomp_properties(deck, eclipseState, *grid.c_grid());

View File

@ -45,14 +45,6 @@ namespace Opm
}
GridManager::GridManager(Opm::DeckConstPtr deck)
: ug_(0)
{
auto eclipseGrid = std::make_shared<const Opm::EclipseGrid>(deck);
initFromEclipseGrid(eclipseGrid, std::vector<double>());
}
GridManager::GridManager(Opm::EclipseGridConstPtr eclipseGrid,
const std::vector<double>& poreVolumes)
: ug_(0)

View File

@ -41,9 +41,6 @@ namespace Opm
class GridManager
{
public:
/// Construct a 3d corner-point grid or tensor grid from a deck.
explicit GridManager(Opm::DeckConstPtr deck);
/// Construct a grid from an EclipseState::EclipseGrid instance.
explicit GridManager(Opm::EclipseGridConstPtr eclipseGrid);

View File

@ -390,7 +390,7 @@ WellsManager::init(const Opm::EclipseStateConstPtr eclipseState,
DoubleArray ntg_glob(eclipseState, "NTG", 1.0);
NTGArray ntg(ntg_glob, global_cell);
EclipseGridConstPtr eclGrid = eclipseState->getEclipseGrid();
EclipseGridConstPtr eclGrid = eclipseState->getInputGrid();
// use cell thickness (dz) from eclGrid
// dz overwrites values calculated by WellDetails::getCubeDim

View File

@ -205,7 +205,7 @@ BOOST_AUTO_TEST_CASE(test_EclipseWriterRFTHandler)
std::shared_ptr<Opm::SimulatorTimer> simulatorTimer = std::make_shared<Opm::SimulatorTimer>();
simulatorTimer->init(eclipseState->getSchedule()->getTimeMap());
std::shared_ptr<Opm::GridManager> ourFineGridManagerPtr = std::make_shared<Opm::GridManager>(eclipseState->getEclipseGrid());
std::shared_ptr<Opm::GridManager> ourFineGridManagerPtr = std::make_shared<Opm::GridManager>(eclipseState->getInputGrid());
const UnstructuredGrid &ourFinerUnstructuredGrid = *ourFineGridManagerPtr->c_grid();
const int* compressedToCartesianCellIdx = Opm::UgGridHelpers::globalCell(ourFinerUnstructuredGrid);

View File

@ -69,7 +69,7 @@ void createEclipseWriter(const char *deckString)
eclipseState.reset(new Opm::EclipseState(deck , parseContext));
auto eclGrid = eclipseState->getEclipseGrid();
auto eclGrid = eclipseState->getInputGrid();
BOOST_CHECK(eclGrid->getNX() == 3);
BOOST_CHECK(eclGrid->getNY() == 3);
BOOST_CHECK(eclGrid->getNZ() == 3);
@ -212,7 +212,7 @@ void checkEgridFile()
// use ERT directly to inspect the EGRID file produced by EclipseWriter
auto egridFile = fortio_open_reader("FOO.EGRID", /*isFormated=*/0, ECL_ENDIAN_FLIP);
auto eclGrid = eclipseState->getEclipseGrid();
auto eclGrid = eclipseState->getInputGrid();
ecl_kw_type *eclKeyword;
// yes, that's an assignment!

View File

@ -28,6 +28,13 @@ using namespace Opm;
using namespace std;
// ACTNUM 1 998*2 3
std::vector<int> get_testBlackoilStateActnum() {
std::vector<int> actnum(10 * 10 * 10, 2);
actnum.front() = 1;
actnum.back() = 3;
return actnum;
}
BOOST_AUTO_TEST_CASE(EqualsDifferentDeckReturnFalse) {
@ -35,12 +42,20 @@ BOOST_AUTO_TEST_CASE(EqualsDifferentDeckReturnFalse) {
const string filename1 = "testBlackoilState1.DATA";
const string filename2 = "testBlackoilState2.DATA";
Opm::ParserPtr parser(new Opm::Parser());
Opm::DeckConstPtr deck1(parser->parseFile(filename1, parseContext));
Opm::DeckConstPtr deck2(parser->parseFile(filename2, parseContext));
GridManager gridManager1(deck1);
Opm::DeckConstPtr deck1(parser->parseFile(filename1, parseContext));
auto eg1 = std::make_shared<Opm::EclipseGrid>(deck1);
std::vector<int> actnum = get_testBlackoilStateActnum();
eg1->resetACTNUM(actnum.data());
Opm::DeckConstPtr deck2(parser->parseFile(filename2, parseContext));
auto eg2 = std::make_shared<Opm::EclipseGrid>(deck2);
GridManager gridManager1(eg1);
const UnstructuredGrid& grid1 = *gridManager1.c_grid();
GridManager gridManager2(deck2);
GridManager gridManager2(eg2);
const UnstructuredGrid& grid2 = *gridManager2.c_grid();
BlackoilState state1( UgGridHelpers::numCells( grid1 ) , UgGridHelpers::numFaces( grid1 ) , 3);
@ -58,8 +73,11 @@ BOOST_AUTO_TEST_CASE(EqualsNumericalDifferenceReturnFalse) {
Opm::ParseContext parseContext;
Opm::ParserPtr parser(new Opm::Parser());
Opm::DeckConstPtr deck(parser->parseFile(filename , parseContext));
auto eg = std::make_shared<Opm::EclipseGrid>(deck);
std::vector<int> actnum = get_testBlackoilStateActnum();
eg->resetACTNUM(actnum.data());
GridManager gridManager(deck);
GridManager gridManager(eg);
const UnstructuredGrid& grid = *gridManager.c_grid();
BlackoilState state1( UgGridHelpers::numCells( grid ) , UgGridHelpers::numFaces( grid ) , 3);

View File

@ -134,7 +134,12 @@ BOOST_AUTO_TEST_CASE(DisjointColumn)
Opm::ParseContext parseContext;
Opm::ParserPtr parser(new Opm::Parser());
Opm::DeckConstPtr deck(parser->parseString(grdecl , parseContext));
Opm::GridManager manager(deck);
Opm::EclipseGridPtr ep = std::make_shared<Opm::EclipseGrid>(deck);
std::vector<int> actnum;
for (size_t i = 1; i <= (3 * 3 * 3); i++)
actnum.push_back(i != 14); // ACTNUM 13*1 0 13* 1
ep->resetACTNUM(actnum.data());
Opm::GridManager manager(ep);
VVI columns;
Opm::extractColumn(*manager.c_grid(), columns);

View File

@ -60,7 +60,7 @@ struct TestFixture : public Setup
{
TestFixture()
: Setup ()
, grid (deck)
, grid (ecl->getInputGrid())
, reltol(1.0e-10)
{
}

View File

@ -56,7 +56,7 @@ BOOST_AUTO_TEST_CASE(Processing)
Opm::DeckConstPtr deck = parser->parseFile(filename, parseContext);
std::shared_ptr<EclipseState> eclstate (new Opm::EclipseState(deck, parseContext));
const auto& porv = eclstate->get3DProperties().getDoubleGridProperty("PORV").getData();
EclipseGridConstPtr eclgrid = eclstate->getEclipseGrid();
EclipseGridConstPtr eclgrid = eclstate->getInputGrid();
BOOST_CHECK_EQUAL(eclgrid->getMinpvMode(), MinpvMode::EclSTD);

View File

@ -59,7 +59,7 @@ BOOST_AUTO_TEST_CASE(diagnosis)
Opm::DeckConstPtr deck(parser->parseFile("../tests/relpermDiagnostics.DATA", parseContext));
eclState.reset(new EclipseState(deck, parseContext));
GridManager gm(deck);
GridManager gm(eclState->getInputGrid());
const UnstructuredGrid& grid = *gm.c_grid();
std::string logFile = "LOGFILE.txt";
std::shared_ptr<EclipsePRTLog> prtLog = std::make_shared<EclipsePRTLog>(logFile, Log::DefaultMessageTypes);

View File

@ -48,7 +48,7 @@ BOOST_AUTO_TEST_CASE(TestStoppedWells)
Opm::DeckConstPtr deck(parser->parseFile(filename , parseContext));
Opm::EclipseStateConstPtr eclipseState(new Opm::EclipseState(deck , parseContext));
Opm::GridManager gridManager(deck);
Opm::GridManager gridManager(eclipseState->getInputGrid());
double target_surfacerate_inj;
double target_surfacerate_prod;

View File

@ -22,12 +22,13 @@
#include <opm/core/grid/cornerpoint_grid.h> /* compute_geometry */
#include <opm/core/grid/GridManager.hpp> /* compute_geometry */
#include <opm/core/grid/cpgpreprocess/preprocess.h>
#include <opm/parser/eclipse/Parser/Parser.hpp>
#include <opm/parser/eclipse/Parser/ParseContext.hpp>
#include <opm/parser/eclipse/Deck/Deck.hpp>
#include <opm/parser/eclipse/Deck/DeckItem.hpp>
#include <opm/parser/eclipse/Deck/DeckKeyword.hpp>
#include <opm/parser/eclipse/Deck/DeckRecord.hpp>
#include <opm/parser/eclipse/EclipseState/EclipseState.hpp>
#include <opm/parser/eclipse/Parser/Parser.hpp>
#include <opm/parser/eclipse/Parser/ParseContext.hpp>
using namespace std;
@ -54,14 +55,18 @@ BOOST_AUTO_TEST_CASE(Equal) {
"\n";
Opm::ParserPtr parser(new Opm::Parser() );
Opm::DeckConstPtr deck1 = parser->parseFile( filename1 , parseContext);
Opm::EclipseState es1(deck1, parseContext);
Opm::DeckConstPtr deck2 = parser->parseString( deck2Data , parseContext);
Opm::EclipseState es2(deck2, parseContext);
BOOST_CHECK( deck1->hasKeyword("ZCORN") );
BOOST_CHECK( deck1->hasKeyword("COORD") );
Opm::GridManager grid1(deck1);
Opm::GridManager grid2(deck2);
Opm::GridManager grid1(es1.getInputGrid());
Opm::GridManager grid2(es2.getInputGrid());
const UnstructuredGrid* cgrid1 = grid1.c_grid();
const UnstructuredGrid* cgrid2 = grid2.c_grid();
@ -75,15 +80,16 @@ BOOST_AUTO_TEST_CASE(Equal) {
// TODO This method might be obsolete after using EclipseState to generate grid
BOOST_AUTO_TEST_CASE(EqualEclipseGrid) {
const std::string filename = "CORNERPOINT_ACTNUM.DATA";
Opm::ParserPtr parser(new Opm::Parser() );
Opm::ParseContext parseContext;
Opm::DeckConstPtr deck = parser->parseFile( filename , parseContext);
Opm::EclipseState es(deck, parseContext);
auto grid = es.getInputGrid();
std::shared_ptr<const Opm::EclipseGrid> grid(new Opm::EclipseGrid(deck));
Opm::GridManager gridM(grid);
Opm::GridManager gridM(es.getInputGrid());
const UnstructuredGrid* cgrid1 = gridM.c_grid();
struct UnstructuredGrid * cgrid2;
{
@ -150,21 +156,19 @@ BOOST_AUTO_TEST_CASE(TOPS_Fully_Specified) {
"EDIT\n"
"\n";
Opm::ParserPtr parser(new Opm::Parser() );
Opm::ParserPtr parser(new Opm::Parser());
Opm::ParseContext parseContext;
Opm::DeckConstPtr deck1 = parser->parseString( deck1Data , parseContext);
Opm::DeckConstPtr deck2 = parser->parseString( deck2Data , parseContext);
Opm::DeckConstPtr deck1 = parser->parseString(deck1Data, parseContext);
Opm::DeckConstPtr deck2 = parser->parseString(deck2Data, parseContext);
std::shared_ptr<const Opm::EclipseGrid> grid1(new Opm::EclipseGrid(deck1));
std::shared_ptr<const Opm::EclipseGrid> grid2(new Opm::EclipseGrid(deck2));
Opm::EclipseState es1(deck1, parseContext);
Opm::EclipseState es2(deck2, parseContext);
Opm::GridManager gridM1(grid1);
Opm::GridManager gridM2(grid2);
Opm::GridManager gridM1(es1.getInputGrid());
Opm::GridManager gridM2(es2.getInputGrid());
const UnstructuredGrid* cgrid1 = gridM1.c_grid();
const UnstructuredGrid* cgrid2 = gridM2.c_grid();
BOOST_CHECK( grid_equal( cgrid1 , cgrid2 ));
BOOST_CHECK(grid_equal(cgrid1, cgrid2));
}

View File

@ -182,7 +182,7 @@ BOOST_AUTO_TEST_CASE(New_Constructor_Works) {
Opm::DeckConstPtr deck(parser->parseFile(filename, parseContext));
Opm::EclipseStateConstPtr eclipseState(new Opm::EclipseState(deck, parseContext));
Opm::GridManager gridManager(deck);
Opm::GridManager gridManager(eclipseState->getInputGrid());
{
Opm::WellsManager wellsManager(eclipseState, 0, *gridManager.c_grid(), NULL);
@ -219,7 +219,7 @@ BOOST_AUTO_TEST_CASE(WellsEqual) {
Opm::DeckConstPtr deck(parser->parseFile(filename, parseContext));
Opm::EclipseStateConstPtr eclipseState(new Opm::EclipseState(deck, parseContext));
Opm::GridManager gridManager(deck);
Opm::GridManager gridManager(eclipseState->getInputGrid());
Opm::WellsManager wellsManager0(eclipseState, 0, *gridManager.c_grid(), NULL);
Opm::WellsManager wellsManager1(eclipseState, 1, *gridManager.c_grid(), NULL);
@ -235,7 +235,7 @@ BOOST_AUTO_TEST_CASE(ControlsEqual) {
Opm::DeckConstPtr deck(parser->parseFile(filename, parseContext));
Opm::EclipseStateConstPtr eclipseState(new Opm::EclipseState(deck, parseContext));
Opm::GridManager gridManager(deck);
Opm::GridManager gridManager(eclipseState->getInputGrid());
Opm::WellsManager wellsManager0(eclipseState, 0, *gridManager.c_grid(), NULL);
Opm::WellsManager wellsManager1(eclipseState, 1, *gridManager.c_grid(), NULL);
@ -258,7 +258,7 @@ BOOST_AUTO_TEST_CASE(WellShutOK) {
Opm::DeckConstPtr deck(parser->parseFile(filename, parseContext));
Opm::EclipseStateConstPtr eclipseState(new Opm::EclipseState(deck, parseContext));
Opm::GridManager gridManager(deck);
Opm::GridManager gridManager(eclipseState->getInputGrid());
Opm::WellsManager wellsManager2(eclipseState, 2, *gridManager.c_grid(), NULL);
@ -275,7 +275,7 @@ BOOST_AUTO_TEST_CASE(WellSTOPOK) {
Opm::DeckConstPtr deck(parser->parseFile(filename, parseContext));
Opm::EclipseStateConstPtr eclipseState(new Opm::EclipseState(deck, parseContext));
Opm::GridManager gridManager(deck);
Opm::GridManager gridManager(eclipseState->getInputGrid());
Opm::WellsManager wellsManager(eclipseState, 0, *gridManager.c_grid(), NULL);

View File

@ -208,7 +208,7 @@ Opm::EclipseWriterPtr createEclipseWriter(Opm::DeckConstPtr deck,
Opm::EclipseWriterPtr eclWriter(new Opm::EclipseWriter(params,
eclipseState,
phaseUsage,
eclipseState->getEclipseGrid()->getCartesianSize(),
eclipseState->getInputGrid()->getCartesianSize(),
0));
return eclWriter;
}
@ -268,7 +268,7 @@ BOOST_AUTO_TEST_CASE(EclipseReadWriteWellStateData)
Opm::GridManager gridManager(deck);
Opm::WellsManager wellsManager(eclipseState, 1, *gridManager.c_grid(), NULL);
const Wells* wells = wellsManager.c_wells();
std::shared_ptr<Opm::BlackoilState> blackoilState = createBlackOilState(eclipseState->getEclipseGrid(), phaseUsage);
std::shared_ptr<Opm::BlackoilState> blackoilState = createBlackOilState(eclipseState->getInputGrid(), phaseUsage);
wellState->init(wells, *blackoilState);
//Set test data for pressure
@ -315,7 +315,7 @@ BOOST_AUTO_TEST_CASE(EclipseReadWriteWellStateData)
wellStateRestored->init(wells, *blackoilState);
//Read and verify OPM XWEL data, and solution data: pressure, temperature, saturation data, rs and rv
std::shared_ptr<Opm::BlackoilState> blackoilStateRestored = createBlackOilState(eclipseState->getEclipseGrid(), phaseUsage);
std::shared_ptr<Opm::BlackoilState> blackoilStateRestored = createBlackOilState(eclipseState->getInputGrid(), phaseUsage);
Opm::init_from_restart_file(eclipseState, Opm::UgGridHelpers::numCells(*gridManager.c_grid()), phaseUsage, *blackoilStateRestored, *wellStateRestored);
BOOST_CHECK_EQUAL_COLLECTIONS(wellState->bhp().begin(), wellState->bhp().end(), wellStateRestored->bhp().begin(), wellStateRestored->bhp().end());

View File

@ -156,7 +156,7 @@ Opm::EclipseWriterPtr createEclipseWriter(Opm::DeckConstPtr deck,
Opm::EclipseWriterPtr eclWriter(new Opm::EclipseWriter(params,
eclipseState,
phaseUsage,
eclipseState->getEclipseGrid()->getCartesianSize(),
eclipseState->getInputGrid()->getCartesianSize(),
0));
return eclWriter;
}
@ -182,7 +182,7 @@ BOOST_AUTO_TEST_CASE(EclipseWriteRestartWellInfo)
eclipseWriter->writeInit(*simTimer);
std::shared_ptr<Opm::WellState> wellState(new Opm::WellState());
std::shared_ptr<Opm::BlackoilState> blackoilState = createBlackOilState(eclipseState->getEclipseGrid());
std::shared_ptr<Opm::BlackoilState> blackoilState = createBlackOilState(eclipseState->getInputGrid());
wellState->init(0, *blackoilState);
int countTimeStep = eclipseState->getSchedule()->getTimeMap()->numTimesteps();
@ -192,7 +192,7 @@ BOOST_AUTO_TEST_CASE(EclipseWriteRestartWellInfo)
eclipseWriter->writeTimeStep(*simTimer, *blackoilState, *wellState, false);
}
verifyWellState(eclipse_restart_filename, eclipseState->getEclipseGrid(), eclipseState->getSchedule());
verifyWellState(eclipse_restart_filename, eclipseState->getInputGrid(), eclipseState->getSchedule());
test_work_area_free(test_area);
}