Removed parameters to EclipseWriter
Paramater::ParameterGroup& params and numCells and compressedToCartesianCellIndex These are now stored in the IOconfig object
This commit is contained in:
@@ -4,7 +4,7 @@
|
||||
#include <opm/output/eclipse/EclipseWriter.hpp>
|
||||
#include <opm/core/utility/parameters/Parameter.hpp>
|
||||
#include <opm/core/utility/parameters/ParameterGroup.hpp>
|
||||
|
||||
#include <opm/parser/eclipse/EclipseState/IOConfig/IOConfig.hpp>
|
||||
#include <forward_list>
|
||||
#include <map>
|
||||
#include <memory> // unique_ptr
|
||||
@@ -51,8 +51,7 @@ create (const ParameterGroup& params,
|
||||
std::shared_ptr <const EclipseState> eclipseState,
|
||||
const Opm::PhaseUsage &phaseUsage,
|
||||
std::shared_ptr <const UnstructuredGrid> grid) {
|
||||
return unique_ptr <OutputWriter> (new Format (params,
|
||||
eclipseState,
|
||||
return unique_ptr <OutputWriter> (new Format (eclipseState,
|
||||
phaseUsage));
|
||||
}
|
||||
|
||||
@@ -92,6 +91,13 @@ OutputWriter::create (const ParameterGroup& params,
|
||||
// invoke the constructor for the type if we found the keyword
|
||||
// and put the pointer to this writer onto the list
|
||||
if (params.getDefault <bool> (name, false)) {
|
||||
auto ioConfig = eclipseState->getIOConfig();
|
||||
|
||||
// retrieve the value of the "output" parameter
|
||||
ioConfig->setOutputEnabled(params.getDefault<bool>("output", /*defaultValue=*/true));
|
||||
// store in current directory if not explicitly set
|
||||
ioConfig->setOutputDir(params.getDefault<std::string>("output_dir", "."));
|
||||
|
||||
list->push_front (it->second (params, eclipseState, phaseUsage, grid));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -68,8 +68,7 @@ public:
|
||||
* \brief Sets the common attributes required to write eclipse
|
||||
* binary files using ERT.
|
||||
*/
|
||||
EclipseWriter(const parameter::ParameterGroup& params,
|
||||
Opm::EclipseStateConstPtr eclipseState,
|
||||
EclipseWriter(Opm::EclipseStateConstPtr eclipseState,
|
||||
const Opm::PhaseUsage &phaseUsage);
|
||||
|
||||
/**
|
||||
@@ -112,7 +111,7 @@ private:
|
||||
Opm::EclipseStateConstPtr eclipseState_;
|
||||
int numCells_;
|
||||
std::array<int, 3> cartesianSize_;
|
||||
const int* compressedToCartesianCellIdx_;
|
||||
std::vector<int> compressedToCartesianCellIdx_;
|
||||
std::vector< int > gridToEclipseIdx_;
|
||||
double deckToSiPressure_;
|
||||
double deckToSiTemperatureFactor_;
|
||||
@@ -125,7 +124,7 @@ private:
|
||||
PhaseUsage phaseUsage_; // active phases in the input deck
|
||||
std::shared_ptr<EclipseWriterDetails::Summary> summary_;
|
||||
|
||||
void init(const parameter::ParameterGroup& params);
|
||||
void init(Opm::EclipseStateConstPtr eclipseState);
|
||||
};
|
||||
|
||||
typedef std::shared_ptr<EclipseWriter> EclipseWriterPtr;
|
||||
|
||||
@@ -37,14 +37,13 @@
|
||||
#include <opm/core/simulator/BlackoilState.hpp>
|
||||
#include <opm/output/eclipse/EclipseWriteRFTHandler.hpp>
|
||||
#include <opm/common/ErrorMacros.hpp>
|
||||
#include <opm/core/utility/parameters/Parameter.hpp>
|
||||
#include <opm/core/utility/parameters/ParameterGroup.hpp>
|
||||
#include <opm/core/utility/Units.hpp>
|
||||
#include <opm/core/wells.h> // WellType
|
||||
|
||||
#include <opm/parser/eclipse/Deck/DeckKeyword.hpp>
|
||||
#include <opm/parser/eclipse/Units/Dimension.hpp>
|
||||
#include <opm/parser/eclipse/Units/UnitSystem.hpp>
|
||||
#include <opm/parser/eclipse/EclipseState/IOConfig/IOConfig.hpp>
|
||||
#include <opm/parser/eclipse/EclipseState/Eclipse3DProperties.hpp>
|
||||
#include <opm/parser/eclipse/EclipseState/Grid/EclipseGrid.hpp>
|
||||
#include <opm/parser/eclipse/EclipseState/Grid/GridProperty.hpp>
|
||||
@@ -1179,7 +1178,7 @@ void EclipseWriter::writeInit(const SimulatorTimerInterface &timer)
|
||||
|
||||
EclipseWriterDetails::Init fortio(outputDir_, baseName_, /*stepIdx=*/0, eclipseState_->getIOConfigConst());
|
||||
fortio.writeHeader(numCells_,
|
||||
compressedToCartesianCellIdx_,
|
||||
compressedToCartesianCellIdx_.data(),
|
||||
timer,
|
||||
eclipseState_,
|
||||
phaseUsage_);
|
||||
@@ -1368,7 +1367,7 @@ void EclipseWriter::writeTimeStep(const SimulatorTimerInterface& timer,
|
||||
|
||||
//Write RFT data for current timestep to RFT file
|
||||
std::shared_ptr<EclipseWriterDetails::EclipseWriteRFTHandler> eclipseWriteRFTHandler = std::make_shared<EclipseWriterDetails::EclipseWriteRFTHandler>(
|
||||
compressedToCartesianCellIdx_,
|
||||
compressedToCartesianCellIdx_.data(),
|
||||
numCells_,
|
||||
eclipseState_->getInputGrid()->getCartesianSize());
|
||||
|
||||
@@ -1416,8 +1415,7 @@ void EclipseWriter::writeTimeStep(const SimulatorTimerInterface& timer,
|
||||
}
|
||||
|
||||
|
||||
EclipseWriter::EclipseWriter(const parameter::ParameterGroup& params,
|
||||
Opm::EclipseStateConstPtr eclipseState,
|
||||
EclipseWriter::EclipseWriter(Opm::EclipseStateConstPtr eclipseState,
|
||||
const Opm::PhaseUsage &phaseUsage)
|
||||
: eclipseState_(eclipseState)
|
||||
, phaseUsage_(phaseUsage)
|
||||
@@ -1434,9 +1432,13 @@ EclipseWriter::EclipseWriter(const parameter::ParameterGroup& params,
|
||||
//This should be calculated in EclipseGrid
|
||||
std::shared_ptr<Opm::GridManager> ourFineGridManagerPtr = std::make_shared<Opm::GridManager>(eclipseState->getEclipseGrid());
|
||||
const UnstructuredGrid &ourFinerUnstructuredGrid = *ourFineGridManagerPtr->c_grid();
|
||||
const int* compressedToCartesianCellIdx_ = Opm::UgGridHelpers::globalCell(ourFinerUnstructuredGrid);
|
||||
auto compressedToCartesianCellIdx__ = Opm::UgGridHelpers::globalCell(ourFinerUnstructuredGrid);
|
||||
|
||||
if( compressedToCartesianCellIdx_ ) {
|
||||
for(int i=0;i<numCells_;i++) {
|
||||
compressedToCartesianCellIdx_.push_back(compressedToCartesianCellIdx__[i]);
|
||||
}
|
||||
|
||||
if( compressedToCartesianCellIdx_.size()>0 ) {
|
||||
// if compressedToCartesianCellIdx available then
|
||||
// compute mapping to eclipse order
|
||||
std::map< int , int > indexMap;
|
||||
@@ -1457,7 +1459,6 @@ EclipseWriter::EclipseWriter(const parameter::ParameterGroup& params,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// factor from the pressure values given in the deck to Pascals
|
||||
deckToSiPressure_ =
|
||||
eclipseState->getDeckUnitSystem().parse("Pressure")->getSIScaling();
|
||||
@@ -1468,14 +1469,15 @@ EclipseWriter::EclipseWriter(const parameter::ParameterGroup& params,
|
||||
deckToSiTemperatureOffset_ =
|
||||
eclipseState->getDeckUnitSystem().parse("Temperature")->getSIOffset();
|
||||
|
||||
init(params);
|
||||
init(eclipseState);
|
||||
}
|
||||
|
||||
void EclipseWriter::init(const parameter::ParameterGroup& params)
|
||||
void EclipseWriter::init(Opm::EclipseStateConstPtr eclipseState)
|
||||
{
|
||||
// get the base name from the name of the deck
|
||||
using boost::filesystem::path;
|
||||
path deckPath(params.get <std::string>("deck_filename"));
|
||||
auto ioConfig = eclipseState->getIOConfig();
|
||||
path deckPath(ioConfig->getDeckFileName());
|
||||
if (boost::to_upper_copy(path(deckPath.extension()).string()) == ".DATA") {
|
||||
baseName_ = path(deckPath.stem()).string();
|
||||
}
|
||||
@@ -1488,10 +1490,10 @@ void EclipseWriter::init(const parameter::ParameterGroup& params)
|
||||
baseName_ = boost::to_upper_copy(baseName_);
|
||||
|
||||
// retrieve the value of the "output" parameter
|
||||
enableOutput_ = params.getDefault<bool>("output", /*defaultValue=*/true);
|
||||
enableOutput_ = ioConfig->getOutputEnabled();
|
||||
|
||||
// store in current directory if not explicitly set
|
||||
outputDir_ = params.getDefault<std::string>("output_dir", ".");
|
||||
outputDir_ = ioConfig->getOutputDir();
|
||||
|
||||
// set the index of the first time step written to 0...
|
||||
writeStepIdx_ = 0;
|
||||
|
||||
@@ -41,6 +41,7 @@
|
||||
#include <opm/parser/eclipse/EclipseState/Schedule/Schedule.hpp>
|
||||
#include <opm/parser/eclipse/EclipseState/Schedule/Well.hpp>
|
||||
#include <opm/parser/eclipse/EclipseState/Grid/EclipseGrid.hpp>
|
||||
#include <opm/parser/eclipse/EclipseState/IOConfig/IOConfig.hpp>
|
||||
|
||||
#include <ert/ecl/ecl_rft_file.h>
|
||||
#include <ert/util/test_work_area.h>
|
||||
@@ -126,15 +127,14 @@ std::shared_ptr<Opm::EclipseWriter> createEclipseWriter(std::shared_ptr<const Op
|
||||
std::shared_ptr<Opm::EclipseState> eclipseState,
|
||||
std::shared_ptr<Opm::GridManager> ourFineGridManagerPtr)
|
||||
{
|
||||
Opm::parameter::ParameterGroup params;
|
||||
params.insertParameter("deck_filename", "testcase.data");
|
||||
auto ioConfig = eclipseState->getIOConfig();
|
||||
ioConfig->setDeckFileName("testcase.data");
|
||||
|
||||
Opm::PhaseUsage phaseUsage = Opm::phaseUsageFromDeck(deck);
|
||||
|
||||
const UnstructuredGrid &ourFinerUnstructuredGrid = *ourFineGridManagerPtr->c_grid();
|
||||
|
||||
std::shared_ptr<Opm::EclipseWriter> eclipseWriter = std::make_shared<Opm::EclipseWriter>(params,
|
||||
eclipseState,
|
||||
std::shared_ptr<Opm::EclipseWriter> eclipseWriter = std::make_shared<Opm::EclipseWriter>(eclipseState,
|
||||
phaseUsage);
|
||||
|
||||
return eclipseWriter;
|
||||
|
||||
@@ -42,6 +42,7 @@
|
||||
#include <opm/parser/eclipse/EclipseState/Grid/EclipseGrid.hpp>
|
||||
#include <opm/parser/eclipse/EclipseState/Schedule/Schedule.hpp>
|
||||
#include <opm/parser/eclipse/EclipseState/Schedule/TimeMap.hpp>
|
||||
#include <opm/parser/eclipse/EclipseState/IOConfig/IOConfig.hpp>
|
||||
|
||||
// ERT stuff
|
||||
#include <ert/ecl/ecl_kw.h>
|
||||
@@ -64,12 +65,10 @@ void createEclipseWriter(const char *deckString)
|
||||
Opm::ParserConstPtr parser(new Opm::Parser());
|
||||
deck = parser->parseString(deckString, parseContext);
|
||||
|
||||
Opm::parameter::ParameterGroup params;
|
||||
params.insertParameter("deck_filename", "foo.data");
|
||||
|
||||
eclipseState.reset(new Opm::EclipseState(deck , parseContext));
|
||||
|
||||
auto eclGrid = eclipseState->getInputGrid();
|
||||
|
||||
BOOST_CHECK(eclGrid->getNX() == 3);
|
||||
BOOST_CHECK(eclGrid->getNY() == 3);
|
||||
BOOST_CHECK(eclGrid->getNZ() == 3);
|
||||
@@ -89,9 +88,9 @@ void createEclipseWriter(const char *deckString)
|
||||
|
||||
BOOST_CHECK(ourFinerUnstructuredGrid.number_of_cells == 3*3*3);
|
||||
|
||||
|
||||
Opm::PhaseUsage phaseUsage = Opm::phaseUsageFromDeck(deck);
|
||||
eclWriter.reset(new Opm::EclipseWriter(params,
|
||||
eclipseState,
|
||||
eclWriter.reset(new Opm::EclipseWriter(eclipseState,
|
||||
phaseUsage));
|
||||
|
||||
// this check is disabled so far, because UnstructuredGrid uses some weird definition
|
||||
@@ -183,8 +182,7 @@ void getErtData(ecl_kw_type *eclKeyword, std::vector<int> &data)
|
||||
std::copy(ertData, ertData + kwSize, data.begin());
|
||||
}
|
||||
|
||||
void compareErtData(const std::vector<double> &src, const std::vector<double> &dst, double tolerance)
|
||||
{
|
||||
void compareErtData(const std::vector<double> &src, const std::vector<double> &dst, double tolerance) {
|
||||
BOOST_CHECK_EQUAL(src.size(), dst.size());
|
||||
if (src.size() != dst.size())
|
||||
return;
|
||||
@@ -193,14 +191,14 @@ void compareErtData(const std::vector<double> &src, const std::vector<double> &d
|
||||
BOOST_CHECK_CLOSE(src[i], dst[i], tolerance);
|
||||
}
|
||||
|
||||
void compareErtData(const std::vector<int> &src, const std::vector<int> &dst)
|
||||
{
|
||||
void compareErtData(const std::vector<int> &src, const std::vector<int> &dst) {
|
||||
BOOST_CHECK_EQUAL(src.size(), dst.size());
|
||||
if (src.size() != dst.size())
|
||||
return;
|
||||
|
||||
for (size_t i = 0; i < src.size(); ++i)
|
||||
BOOST_CHECK_EQUAL(src[i], dst[i]);
|
||||
|
||||
}
|
||||
|
||||
void checkEgridFile()
|
||||
|
||||
@@ -44,6 +44,7 @@
|
||||
#include <opm/parser/eclipse/EclipseState/Schedule/Schedule.hpp>
|
||||
#include <opm/parser/eclipse/EclipseState/Schedule/Well.hpp>
|
||||
#include <opm/parser/eclipse/EclipseState/Grid/EclipseGrid.hpp>
|
||||
#include <opm/parser/eclipse/EclipseState/IOConfig/IOConfig.hpp>
|
||||
#include <opm/core/wells/WellsManager.hpp>
|
||||
#include <opm/core/grid/GridManager.hpp>
|
||||
#include <opm/core/props/IncompPropertiesFromDeck.hpp>
|
||||
@@ -197,16 +198,11 @@ std::shared_ptr<Opm::BlackoilState> createBlackOilState(Opm::EclipseGridConstPtr
|
||||
}
|
||||
|
||||
Opm::EclipseWriterPtr createEclipseWriter(Opm::DeckConstPtr deck,
|
||||
Opm::EclipseStatePtr eclipseState,
|
||||
std::string& eclipse_data_filename) {
|
||||
|
||||
Opm::parameter::ParameterGroup params;
|
||||
params.insertParameter("deck_filename", eclipse_data_filename);
|
||||
Opm::EclipseStatePtr eclipseState) {
|
||||
|
||||
const Opm::PhaseUsage phaseUsage = Opm::phaseUsageFromDeck(deck);
|
||||
|
||||
Opm::EclipseWriterPtr eclWriter(new Opm::EclipseWriter(params,
|
||||
eclipseState,
|
||||
Opm::EclipseWriterPtr eclWriter(new Opm::EclipseWriter(eclipseState,
|
||||
phaseUsage));
|
||||
return eclWriter;
|
||||
}
|
||||
@@ -255,7 +251,11 @@ BOOST_AUTO_TEST_CASE(EclipseReadWriteWellStateData)
|
||||
Opm::ParseContext parseContext;
|
||||
Opm::DeckConstPtr deck = parser.parseString(input, parseContext);
|
||||
Opm::EclipseStatePtr eclipseState(new Opm::EclipseState(deck , parseContext));
|
||||
Opm::EclipseWriterPtr eclipseWriter = createEclipseWriter(deck, eclipseState, eclipse_data_filename);
|
||||
|
||||
auto ioConfig = eclipseState->getIOConfig();
|
||||
ioConfig->setDeckFileName(eclipse_data_filename);
|
||||
|
||||
Opm::EclipseWriterPtr eclipseWriter = createEclipseWriter(deck, eclipseState);
|
||||
|
||||
std::shared_ptr<Opm::SimulatorTimer> simTimer( new Opm::SimulatorTimer() );
|
||||
simTimer->init(eclipseState->getSchedule()->getTimeMap());
|
||||
|
||||
@@ -42,6 +42,7 @@
|
||||
#include <opm/parser/eclipse/EclipseState/Schedule/Schedule.hpp>
|
||||
#include <opm/parser/eclipse/EclipseState/Schedule/Well.hpp>
|
||||
#include <opm/parser/eclipse/EclipseState/Grid/EclipseGrid.hpp>
|
||||
#include <opm/parser/eclipse/EclipseState/IOConfig/IOConfig.hpp>
|
||||
|
||||
// ERT stuff
|
||||
#include <ert/ecl/ecl_kw.h>
|
||||
@@ -145,16 +146,11 @@ Opm::DeckConstPtr createDeck(const std::string& eclipse_data_filename) {
|
||||
|
||||
|
||||
Opm::EclipseWriterPtr createEclipseWriter(Opm::DeckConstPtr deck,
|
||||
Opm::EclipseStatePtr eclipseState,
|
||||
std::string& eclipse_data_filename) {
|
||||
|
||||
Opm::parameter::ParameterGroup params;
|
||||
params.insertParameter("deck_filename", eclipse_data_filename);
|
||||
Opm::EclipseStatePtr eclipseState) {
|
||||
|
||||
const Opm::PhaseUsage phaseUsage = Opm::phaseUsageFromDeck(deck);
|
||||
|
||||
Opm::EclipseWriterPtr eclWriter(new Opm::EclipseWriter(params,
|
||||
eclipseState,
|
||||
Opm::EclipseWriterPtr eclWriter(new Opm::EclipseWriter(eclipseState,
|
||||
phaseUsage));
|
||||
return eclWriter;
|
||||
}
|
||||
@@ -172,7 +168,11 @@ BOOST_AUTO_TEST_CASE(EclipseWriteRestartWellInfo)
|
||||
Opm::ParseContext parseContext;
|
||||
Opm::DeckConstPtr deck = createDeck(eclipse_data_filename);
|
||||
Opm::EclipseStatePtr eclipseState(new Opm::EclipseState(deck , parseContext));
|
||||
Opm::EclipseWriterPtr eclipseWriter = createEclipseWriter(deck, eclipseState, eclipse_data_filename);
|
||||
|
||||
auto ioConfig = eclipseState->getIOConfig();
|
||||
ioConfig->setDeckFileName(eclipse_data_filename);
|
||||
|
||||
Opm::EclipseWriterPtr eclipseWriter = createEclipseWriter(deck, eclipseState);
|
||||
|
||||
std::shared_ptr<Opm::SimulatorTimer> simTimer( new Opm::SimulatorTimer() );
|
||||
simTimer->init(eclipseState->getSchedule()->getTimeMap());
|
||||
|
||||
Reference in New Issue
Block a user