Output takes data::Solution over SimDataContainer
To break dependencies between modules, and to properly define the input format for the output facilities, make writeTimeStep take data::Solution over SimulationDataContainer.
This commit is contained in:
parent
3a81e1bd3b
commit
8776cc9c44
@ -35,7 +35,7 @@ struct MultiWriter : public OutputWriter {
|
||||
virtual void writeTimeStep(int report_step,
|
||||
time_t current_time,
|
||||
double secs_elapsed,
|
||||
const SimulationDataContainer& reservoirState,
|
||||
data::Solution reservoirState,
|
||||
const WellState& wellState,
|
||||
bool isSubstep) {
|
||||
for (it_t it = writers_->begin (); it != writers_->end(); ++it) {
|
||||
|
@ -23,6 +23,8 @@
|
||||
#include <memory> // unique_ptr, shared_ptr
|
||||
#include <opm/parser/eclipse/EclipseState/Grid/NNC.hpp>
|
||||
|
||||
#include <opm/output/Cells.hpp>
|
||||
|
||||
struct UnstructuredGrid;
|
||||
|
||||
namespace Opm {
|
||||
@ -30,7 +32,6 @@ namespace Opm {
|
||||
// forward declaration
|
||||
class EclipseState;
|
||||
namespace parameter { class ParameterGroup; }
|
||||
class SimulationDataContainer;
|
||||
class WellState;
|
||||
struct PhaseUsage;
|
||||
|
||||
@ -91,7 +92,7 @@ public:
|
||||
virtual void writeTimeStep( int report_step,
|
||||
time_t current_posix_time,
|
||||
double seconds_elapsed,
|
||||
const SimulationDataContainer& reservoirState,
|
||||
data::Solution reservoirState,
|
||||
const WellState& wellState,
|
||||
bool isSubstep) = 0;
|
||||
|
||||
|
@ -91,7 +91,7 @@ public:
|
||||
virtual void writeTimeStep( int report_step,
|
||||
time_t current_posix_time,
|
||||
double seconds_elapsed,
|
||||
const SimulationDataContainer& reservoirState,
|
||||
data::Solution,
|
||||
const WellState& wellState,
|
||||
bool isSubstep);
|
||||
|
||||
|
@ -23,9 +23,6 @@
|
||||
|
||||
#include "EclipseWriter.hpp"
|
||||
|
||||
#include <opm/common/data/SimulationDataContainer.hpp>
|
||||
|
||||
|
||||
#include <opm/core/props/BlackoilPhases.hpp>
|
||||
#include <opm/core/props/phaseUsageFromDeck.hpp>
|
||||
#include <opm/core/grid.h>
|
||||
@ -78,9 +75,6 @@
|
||||
// namespace start here since we don't want the ERT headers in it
|
||||
namespace Opm {
|
||||
namespace EclipseWriterDetails {
|
||||
/// Names of the saturation property for each phase. The order of these
|
||||
/// names are critical; they must be the same as the BlackoilPhases enum
|
||||
static const char* saturationKeywordNames[] = { "SWAT", "SOIL", "SGAS" };
|
||||
|
||||
// throw away the data for all non-active cells and reorder to the Cartesian logic of
|
||||
// eclipse
|
||||
@ -111,22 +105,6 @@ void convertFromSiTo(std::vector<double> &siValues, double toSiConversionFactor,
|
||||
}
|
||||
}
|
||||
|
||||
// extract a sub-array of a larger one which represents multiple
|
||||
// striped ones
|
||||
void extractFromStripedData(std::vector<double> &data,
|
||||
int offset,
|
||||
int stride)
|
||||
{
|
||||
size_t tmpIdx = 0;
|
||||
for (size_t curIdx = offset; curIdx < data.size(); curIdx += stride) {
|
||||
assert(tmpIdx <= curIdx);
|
||||
data[tmpIdx] = data[curIdx];
|
||||
++tmpIdx;
|
||||
}
|
||||
// shirk the result
|
||||
data.resize(tmpIdx);
|
||||
}
|
||||
|
||||
/// Convert OPM phase usage to ERT bitmask
|
||||
int ertPhaseMask(const PhaseUsage uses)
|
||||
{
|
||||
@ -647,44 +625,33 @@ void EclipseWriter::writeInit( time_t current_posix_time, double start_time, con
|
||||
void EclipseWriter::writeTimeStep(int report_step,
|
||||
time_t current_posix_time,
|
||||
double secs_elapsed,
|
||||
const SimulationDataContainer& reservoirState,
|
||||
data::Solution cells,
|
||||
const WellState& wellState,
|
||||
bool isSubstep)
|
||||
{
|
||||
|
||||
using dc = data::Solution::key;
|
||||
// if we don't want to write anything, this method becomes a
|
||||
// no-op...
|
||||
if (!enableOutput_) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
std::vector<double> pressure = reservoirState.pressure();
|
||||
auto& pressure = cells[ dc::PRESSURE ];
|
||||
EclipseWriterDetails::convertFromSiTo(pressure, deckToSiPressure_);
|
||||
EclipseWriterDetails::restrictAndReorderToActiveCells(pressure, gridToEclipseIdx_.size(), gridToEclipseIdx_.data());
|
||||
|
||||
std::vector<double> saturation_water;
|
||||
std::vector<double> saturation_gas;
|
||||
|
||||
if (phaseUsage_.phase_used[BlackoilPhases::Aqua]) {
|
||||
saturation_water = reservoirState.saturation();
|
||||
EclipseWriterDetails::extractFromStripedData(saturation_water,
|
||||
/*offset=*/phaseUsage_.phase_pos[BlackoilPhases::Aqua],
|
||||
/*stride=*/phaseUsage_.num_phases);
|
||||
if( cells.has( dc::SWAT ) ) {
|
||||
auto& saturation_water = cells[ dc::SWAT ];
|
||||
EclipseWriterDetails::restrictAndReorderToActiveCells(saturation_water, gridToEclipseIdx_.size(), gridToEclipseIdx_.data());
|
||||
}
|
||||
|
||||
|
||||
if (phaseUsage_.phase_used[BlackoilPhases::Vapour]) {
|
||||
saturation_gas = reservoirState.saturation();
|
||||
EclipseWriterDetails::extractFromStripedData(saturation_gas,
|
||||
/*offset=*/phaseUsage_.phase_pos[BlackoilPhases::Vapour],
|
||||
/*stride=*/phaseUsage_.num_phases);
|
||||
if( cells.has( dc::SGAS ) ) {
|
||||
auto& saturation_gas = cells[ dc::SGAS ];
|
||||
EclipseWriterDetails::restrictAndReorderToActiveCells(saturation_gas, gridToEclipseIdx_.size(), gridToEclipseIdx_.data());
|
||||
}
|
||||
|
||||
|
||||
|
||||
IOConfigConstPtr ioConfig = eclipseState_->getIOConfigConst();
|
||||
|
||||
|
||||
@ -750,33 +717,28 @@ void EclipseWriter::writeTimeStep(int report_step,
|
||||
|
||||
|
||||
// write the cell temperature
|
||||
std::vector<double> temperature = reservoirState.temperature();
|
||||
auto& temperature = cells[ dc::TEMP ];
|
||||
EclipseWriterDetails::convertFromSiTo(temperature, deckToSiTemperatureFactor_, deckToSiTemperatureOffset_);
|
||||
EclipseWriterDetails::restrictAndReorderToActiveCells(temperature, gridToEclipseIdx_.size(), gridToEclipseIdx_.data());
|
||||
sol.add(EclipseWriterDetails::Keyword<float>("TEMP", temperature));
|
||||
|
||||
|
||||
if (phaseUsage_.phase_used[BlackoilPhases::Aqua]) {
|
||||
sol.add(EclipseWriterDetails::Keyword<float>(EclipseWriterDetails::saturationKeywordNames[BlackoilPhases::PhaseIndex::Aqua], saturation_water));
|
||||
if( cells.has( dc::SWAT ) ) {
|
||||
sol.add( EclipseWriterDetails::Keyword<float>( "SWAT", cells[ dc::SWAT ] ) );
|
||||
}
|
||||
|
||||
|
||||
if (phaseUsage_.phase_used[BlackoilPhases::Vapour]) {
|
||||
sol.add(EclipseWriterDetails::Keyword<float>(EclipseWriterDetails::saturationKeywordNames[BlackoilPhases::PhaseIndex::Vapour], saturation_gas));
|
||||
if( cells.has( dc::SGAS ) ) {
|
||||
sol.add( EclipseWriterDetails::Keyword<float>( "SGAS", cells[ dc::SGAS ] ) );
|
||||
}
|
||||
|
||||
|
||||
// Write RS - Dissolved GOR
|
||||
if (reservoirState.hasCellData( BlackoilState::GASOILRATIO )) {
|
||||
const std::vector<double>& rs = reservoirState.getCellData( BlackoilState::GASOILRATIO );
|
||||
sol.add(EclipseWriterDetails::Keyword<float>("RS", rs));
|
||||
}
|
||||
if( cells.has( dc::RS ) )
|
||||
sol.add(EclipseWriterDetails::Keyword<float>("RS", cells[ dc::RS ] ) );
|
||||
|
||||
// Write RV - Volatilized oil/gas ratio
|
||||
if (reservoirState.hasCellData( BlackoilState::RV )) {
|
||||
const std::vector<double>& rv = reservoirState.getCellData( BlackoilState::RV );
|
||||
sol.add(EclipseWriterDetails::Keyword<float>("RV", rv));
|
||||
}
|
||||
if( cells.has( dc::RV ) )
|
||||
sol.add(EclipseWriterDetails::Keyword<float>("RV", cells[ dc::RV ] ) );
|
||||
}
|
||||
|
||||
|
||||
@ -805,8 +767,8 @@ void EclipseWriter::writeTimeStep(int report_step,
|
||||
wells,
|
||||
eclipseState_->getInputGrid(),
|
||||
pressure,
|
||||
saturation_water,
|
||||
saturation_gas);
|
||||
cells[ dc::SWAT ],
|
||||
cells[ dc::SGAS ] );
|
||||
free( rft_filename );
|
||||
}
|
||||
|
||||
|
@ -34,6 +34,7 @@
|
||||
#include <opm/core/simulator/SimulatorTimer.hpp>
|
||||
#include <opm/core/props/phaseUsageFromDeck.hpp>
|
||||
#include <opm/core/utility/parameters/ParameterGroup.hpp>
|
||||
#include <opm/core/utility/Compat.hpp>
|
||||
|
||||
#include <opm/parser/eclipse/Parser/ParseContext.hpp>
|
||||
#include <opm/parser/eclipse/Parser/Parser.hpp>
|
||||
@ -174,7 +175,8 @@ BOOST_AUTO_TEST_CASE(test_EclipseWriterRFTHandler)
|
||||
eclipseWriter->writeTimeStep( simulatorTimer->reportStepNum(),
|
||||
simulatorTimer->currentPosixTime(),
|
||||
simulatorTimer->simulationTimeElapsed(),
|
||||
*blackoilState2, *wellState, false);
|
||||
sim2solution( *blackoilState2, phaseUsageFromDeck( eclipseState ) ),
|
||||
*wellState, false);
|
||||
}
|
||||
|
||||
std::string cwd(test_work_area_get_cwd(test_area.get()));
|
||||
|
@ -34,6 +34,7 @@
|
||||
#include <opm/core/simulator/WellState.hpp>
|
||||
#include <opm/core/simulator/SimulatorTimer.hpp>
|
||||
#include <opm/core/utility/parameters/ParameterGroup.hpp>
|
||||
#include <opm/core/utility/Compat.hpp>
|
||||
|
||||
#include <opm/parser/eclipse/Parser/ParseContext.hpp>
|
||||
#include <opm/parser/eclipse/Parser/Parser.hpp>
|
||||
@ -52,6 +53,8 @@
|
||||
|
||||
#include <memory>
|
||||
|
||||
using namespace Opm;
|
||||
|
||||
std::shared_ptr<Opm::EclipseWriter> eclWriter;
|
||||
std::shared_ptr<Opm::SimulatorTimer> simTimer;
|
||||
std::shared_ptr<const Opm::Deck> deck;
|
||||
@ -406,6 +409,7 @@ BOOST_AUTO_TEST_CASE(EclipseWriterIntegration)
|
||||
"'PROD' 'G' 3 3 1000 'OIL' /\n"
|
||||
"/\n";
|
||||
|
||||
auto deck = Parser().parseString( deckString, ParseContext() );
|
||||
createEclipseWriter(deckString);
|
||||
|
||||
tm t = boost::posix_time::to_tm( simTimer->startDateTime() );
|
||||
@ -423,7 +427,8 @@ BOOST_AUTO_TEST_CASE(EclipseWriterIntegration)
|
||||
eclWriter->writeTimeStep( report_step,
|
||||
simTimer->currentPosixTime(),
|
||||
simTimer->simulationTimeElapsed(),
|
||||
*blackoilState, *wellState, false);
|
||||
sim2solution( *blackoilState, phaseUsageFromDeck( deck ) ),
|
||||
*wellState, false);
|
||||
checkRestartFile( current_step );
|
||||
checkSummaryFile( current_step );
|
||||
}
|
||||
|
@ -36,6 +36,7 @@
|
||||
#include <opm/core/simulator/WellState.hpp>
|
||||
#include <opm/core/simulator/SimulatorTimer.hpp>
|
||||
#include <opm/core/utility/parameters/ParameterGroup.hpp>
|
||||
#include <opm/core/utility/Compat.hpp>
|
||||
#include <opm/core/wells.h>
|
||||
|
||||
#include <opm/parser/eclipse/Parser/Parser.hpp>
|
||||
@ -306,7 +307,8 @@ state first_sim(test_work_area_type * test_area) {
|
||||
eclipseWriter->writeTimeStep( simTimer->reportStepNum(),
|
||||
simTimer->currentPosixTime(),
|
||||
simTimer->simulationTimeElapsed(),
|
||||
*blackoilState, *wellState , false);
|
||||
sim2solution( *blackoilState, phaseUsage ),
|
||||
*wellState , false);
|
||||
|
||||
return std::make_pair(wellState, blackoilState);
|
||||
}
|
||||
|
@ -33,6 +33,7 @@
|
||||
#include <opm/core/simulator/WellState.hpp>
|
||||
#include <opm/core/simulator/SimulatorTimer.hpp>
|
||||
#include <opm/core/utility/parameters/ParameterGroup.hpp>
|
||||
#include <opm/core/utility/Compat.hpp>
|
||||
#include <opm/core/wells.h>
|
||||
|
||||
#include <opm/parser/eclipse/Parser/Parser.hpp>
|
||||
@ -186,7 +187,8 @@ BOOST_AUTO_TEST_CASE(EclipseWriteRestartWellInfo)
|
||||
eclipseWriter->writeTimeStep( simTimer->reportStepNum(),
|
||||
simTimer->currentPosixTime(),
|
||||
simTimer->simulationTimeElapsed(),
|
||||
*blackoilState, *wellState, false);
|
||||
sim2solution( *blackoilState, phaseUsageFromDeck( eclipseState ) ),
|
||||
*wellState, false);
|
||||
}
|
||||
|
||||
verifyWellState(eclipse_restart_filename, eclipseState->getInputGrid(), eclipseState->getSchedule());
|
||||
|
Loading…
Reference in New Issue
Block a user