Skip to content

Commit

Permalink
Merge pull request OPM#1002 from pgdr/eclipsegrid-is-input
Browse files Browse the repository at this point in the history
 Using getInputGrid API from Parser
  • Loading branch information
joakim-hove committed Apr 20, 2016
2 parents b07f4dd + 9734381 commit f9b7a5f
Show file tree
Hide file tree
Showing 19 changed files with 275 additions and 277 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));
}


Loading

0 comments on commit f9b7a5f

Please sign in to comment.