Skip to content

Commit

Permalink
Using getInputGrid API from Parser, changed GridManager to no longer …
Browse files Browse the repository at this point in the history
…accept Deck in constructor
  • Loading branch information
Pål Grønås Drange authored and Pål Grønås Drange committed Apr 20, 2016
1 parent 668cd14 commit 9734381
Show file tree
Hide file tree
Showing 19 changed files with 71 additions and 55 deletions.
2 changes: 1 addition & 1 deletion examples/compute_initial_state.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion examples/compute_tof.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion examples/diagnose_relperm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion examples/wells_example.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down
8 changes: 0 additions & 8 deletions opm/core/grid/GridManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
3 changes: 0 additions & 3 deletions opm/core/grid/GridManager.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
2 changes: 1 addition & 1 deletion opm/core/wells/WellsManager_impl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion tests/test_EclipseWriteRFTHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
4 changes: 2 additions & 2 deletions tests/test_EclipseWriter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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!
Expand Down
24 changes: 21 additions & 3 deletions tests/test_blackoilstate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,19 +28,34 @@ 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) {

ParseContext parseContext;
const string filename1 = "testBlackoilState1.DATA";
const string filename2 = "testBlackoilState2.DATA";
Opm::ParserPtr parser(new Opm::Parser());

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(deck1);
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);
Expand All @@ -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);
Expand Down
7 changes: 6 additions & 1 deletion tests/test_column_extract.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion tests/test_compressedpropertyaccess.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ struct TestFixture : public Setup
{
TestFixture()
: Setup ()
, grid (deck)
, grid (ecl->getInputGrid())
, reltol(1.0e-10)
{
}
Expand Down
2 changes: 1 addition & 1 deletion tests/test_pinchprocessor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
2 changes: 1 addition & 1 deletion tests/test_relpermdiagnostics.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion tests/test_stoppedwells.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
38 changes: 21 additions & 17 deletions tests/test_ug.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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();
Expand All @@ -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;
{
Expand Down Expand Up @@ -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));
}


10 changes: 5 additions & 5 deletions tests/test_wellsmanager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand All @@ -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);
Expand All @@ -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);

Expand All @@ -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);

Expand Down
6 changes: 3 additions & 3 deletions tests/test_writeReadRestartFile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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());
Expand Down
6 changes: 3 additions & 3 deletions tests/test_writenumwells.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand All @@ -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();
Expand All @@ -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);
}

0 comments on commit 9734381

Please sign in to comment.