EclipseWriter: use opm-parser's EclipseGrid class

this unifies the grid creation code paths with the one used by the
simulators and simplfies things.
This commit is contained in:
Andreas Lauser 2014-07-14 12:15:48 +02:00
parent 3511812a52
commit 6ac1196859
2 changed files with 33 additions and 74 deletions

View File

@ -23,9 +23,7 @@
#include "EclipseWriter.hpp" #include "EclipseWriter.hpp"
#include <opm/core/props/BlackoilPhases.hpp> #include <opm/core/props/BlackoilPhases.hpp>
#include <opm/core/grid/GridManager.hpp> #include <opm/parser/eclipse/EclipseState/Grid/EclipseGrid.hpp>
#include <opm/core/grid.h>
#include <opm/core/grid/cpgpreprocess/preprocess.h>
#include <opm/core/props/phaseUsageFromDeck.hpp> #include <opm/core/props/phaseUsageFromDeck.hpp>
#include <opm/core/simulator/SimulatorState.hpp> #include <opm/core/simulator/SimulatorState.hpp>
#include <opm/core/simulator/SimulatorTimer.hpp> #include <opm/core/simulator/SimulatorTimer.hpp>
@ -512,44 +510,32 @@ struct EclipseWriterGrid : public EclipseHandle <ecl_grid_type> {
const int* cart_dims, const int* cart_dims,
const int* global_cell) const int* global_cell)
{ {
if (deck->hasKeyword("DXV")) { auto runspecSection = std::make_shared<RUNSPECSection>(deck);
// make sure that the DYV and DZV keywords are present if the auto gridSection = std::make_shared<GRIDSection>(deck);
// DXV keyword is used in the deck... EclipseGrid eGrid(runspecSection, gridSection);
assert(deck->hasKeyword("DYV"));
assert(deck->hasKeyword("DZV"));
const auto& dxv = deck->getKeyword("DXV")->getSIDoubleData(); std::vector<double> mapaxesData;
const auto& dyv = deck->getKeyword("DYV")->getSIDoubleData(); std::vector<double> zcornData;
const auto& dzv = deck->getKeyword("DZV")->getSIDoubleData(); std::vector<double> coordData;
std::vector<int> actnumData;
return EclipseWriterGrid (dxv, dyv, dzv); eGrid.exportMAPAXES(mapaxesData);
} eGrid.exportZCORN(zcornData);
else if (deck->hasKeyword("ZCORN")) { eGrid.exportCOORD(coordData);
struct grdecl g; eGrid.exportACTNUM(actnumData);
GridManager::createGrdecl(deck, g);
auto coordData = getAllSiDoubles_(deck->getKeyword(COORD_KW)); EclipseKeyword<float> mapaxesKeyword("MAPAXES", mapaxesData);
auto zcornData = getAllSiDoubles_(deck->getKeyword(ZCORN_KW)); EclipseKeyword<float> zcornKeyword("ZCORN", zcornData);
EclipseKeyword<float> coord_kw (COORD_KW, coordData); EclipseKeyword<float> coordKeyword("COORD", coordData);
EclipseKeyword<float> zcorn_kw (ZCORN_KW, zcornData); EclipseKeyword<int> actnumKeyword("ACTNUM", actnumData);
// get the actually active cells, after processing return EclipseWriterGrid(eGrid.getNX(),
std::vector <int> actnum; eGrid.getNY(),
getActiveCells_(number_of_cells, cart_dims, global_cell, actnum); eGrid.getNZ(),
EclipseKeyword<int> actnum_kw (ACTNUM_KW, actnum); zcornKeyword,
coordKeyword,
EclipseKeyword<float> mapaxes_kw (MAPAXES_KW); actnumKeyword,
if (g.mapaxes) { mapaxesKeyword);
auto mapaxesData = getAllSiDoubles_(deck->getKeyword(MAPAXES_KW));
mapaxes_kw = std::move (EclipseKeyword<float> (MAPAXES_KW, mapaxesData));
}
return EclipseWriterGrid (cart_dims, zcorn_kw, coord_kw, actnum_kw, mapaxes_kw);
}
else {
OPM_THROW(std::runtime_error,
"Can't create an ERT grid (no supported keywords found in deck)");
}
} }
/** /**
@ -577,34 +563,18 @@ struct EclipseWriterGrid : public EclipseHandle <ecl_grid_type> {
EclipseWriterGrid& operator= (const EclipseWriterGrid&) = delete; EclipseWriterGrid& operator= (const EclipseWriterGrid&) = delete;
private: private:
// each of these cases could have been their respective subclass,
// but there is not any polymorphism on each of these grid types
// once we have the handle
// setup smart pointer for Cartesian grid
EclipseWriterGrid (const std::vector<double>& dxv,
const std::vector<double>& dyv,
const std::vector<double>& dzv)
: EclipseHandle <ecl_grid_type> (
ecl_grid_alloc_dxv_dyv_dzv (dxv.size (),
dyv.size (),
dzv.size (),
&dxv[0],
&dyv[0],
&dzv[0],
NULL),
ecl_grid_free) { }
// setup smart pointer for cornerpoint grid // setup smart pointer for cornerpoint grid
EclipseWriterGrid (const int dims[], EclipseWriterGrid (int nx,
const EclipseKeyword<float>& zcorn, int ny,
const EclipseKeyword<float>& coord, int nz,
const EclipseKeyword<int>& actnum, const EclipseKeyword<float>& zcorn,
const EclipseKeyword<float>& mapaxes) const EclipseKeyword<float>& coord,
const EclipseKeyword<int>& actnum,
const EclipseKeyword<float>& mapaxes)
: EclipseHandle <ecl_grid_type> ( : EclipseHandle <ecl_grid_type> (
ecl_grid_alloc_GRDECL_kw(dims[0], ecl_grid_alloc_GRDECL_kw(nx,
dims[1], ny,
dims[2], nz,
zcorn, zcorn,
coord, coord,
actnum, actnum,

View File

@ -54,14 +54,6 @@ namespace parameter { class ParameterGroup; }
class EclipseWriter : public OutputWriter class EclipseWriter : public OutputWriter
{ {
public: public:
/*!
* \brief Sets the common attributes required to write eclipse
* binary files using ERT.
*/
EclipseWriter(const parameter::ParameterGroup& params,
Opm::DeckConstPtr deck,
std::shared_ptr <const UnstructuredGrid> grid);
/*! /*!
* \brief Sets the common attributes required to write eclipse * \brief Sets the common attributes required to write eclipse
* binary files using ERT. * binary files using ERT.
@ -71,8 +63,6 @@ public:
int number_of_cells, const int* global_cell, const int* cart_dims, int number_of_cells, const int* global_cell, const int* cart_dims,
int dimension); int dimension);
/** /**
* We need a destructor in the compilation unit to avoid the * We need a destructor in the compilation unit to avoid the
* EclipseSummary being a complete type here. * EclipseSummary being a complete type here.
@ -104,7 +94,6 @@ public:
private: private:
Opm::DeckConstPtr deck_; Opm::DeckConstPtr deck_;
std::shared_ptr <const UnstructuredGrid> grid_;
int number_of_cells_; int number_of_cells_;
int dimensions_; int dimensions_;
const int* cart_dims_; const int* cart_dims_;