Merge pull request #776 from andlaus/use_EclipseState_for_summary_units

summary output: use the EclipseState to determine the deck unit system
This commit is contained in:
Atgeirr Flø Rasmussen 2015-03-31 17:45:04 +02:00
commit 78682c7139
9 changed files with 34 additions and 45 deletions

View File

@ -47,12 +47,10 @@ private:
/// Psuedo-constructor, can appear in template
template <typename Format> unique_ptr <OutputWriter>
create (const ParameterGroup& params,
std::shared_ptr <const Deck> deck,
std::shared_ptr <const EclipseState> eclipseState,
const Opm::PhaseUsage &phaseUsage,
std::shared_ptr <const UnstructuredGrid> grid) {
return unique_ptr <OutputWriter> (new Format (params,
deck,
eclipseState,
phaseUsage,
grid->number_of_cells,
@ -67,7 +65,6 @@ create (const ParameterGroup& params,
/// to the list below!
typedef map <const char*, unique_ptr <OutputWriter> (*)(
const ParameterGroup&,
std::shared_ptr <const Deck> deck,
std::shared_ptr <const EclipseState> eclipseState,
const Opm::PhaseUsage &phaseUsage,
std::shared_ptr <const UnstructuredGrid>)> map_t;
@ -79,7 +76,6 @@ map_t FORMATS = {
unique_ptr <OutputWriter>
OutputWriter::create (const ParameterGroup& params,
std::shared_ptr <const Deck> deck,
std::shared_ptr <const EclipseState> eclipseState,
const Opm::PhaseUsage &phaseUsage,
std::shared_ptr <const UnstructuredGrid> grid) {
@ -97,7 +93,7 @@ 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)) {
list->push_front (it->second (params, deck, eclipseState, phaseUsage, grid));
list->push_front (it->second (params, eclipseState, phaseUsage, grid));
}
}

View File

@ -21,7 +21,6 @@
#define OPM_OUTPUT_WRITER_HPP
#include <memory> // unique_ptr, shared_ptr
#include <opm/parser/eclipse/Deck/Deck.hpp>
#include <opm/core/simulator/SimulatorTimerInterface.hpp>
struct UnstructuredGrid;
@ -108,7 +107,6 @@ public:
*/
static std::unique_ptr <OutputWriter>
create (const parameter::ParameterGroup& params,
std::shared_ptr <const Deck> deck,
std::shared_ptr <const EclipseState> eclipseState,
const Opm::PhaseUsage &phaseUsage,
std::shared_ptr <const UnstructuredGrid> grid);

View File

@ -449,8 +449,7 @@ public:
// on the classes defined in the following.
// add rate variables for each of the well in the input file
void addAllWells(Opm::DeckConstPtr deck,
Opm::EclipseStateConstPtr eclipseState,
void addAllWells(Opm::EclipseStateConstPtr eclipseState,
const PhaseUsage& uses);
void writeTimeStep(int writeStepIdx,
const SimulatorTimerInterface& timer,
@ -734,7 +733,7 @@ public:
PhaseUsage uses,
BlackoilPhases::PhaseIndex phase,
WellType type,
bool useFieldUnits)
UnitSystem::UnitType unitType)
: WellReport(summary,
eclipseState,
well,
@ -742,7 +741,7 @@ public:
phase,
type,
'R',
handleUnit_(phase, useFieldUnits))
handleUnit_(phase, unitType))
{
}
@ -770,27 +769,31 @@ public:
}
private:
const std::string handleUnit_(BlackoilPhases::PhaseIndex phase, bool useField) {
const std::string handleUnit_(BlackoilPhases::PhaseIndex phase, UnitSystem::UnitType unitType) {
using namespace Opm::unit;
if (phase == BlackoilPhases::Liquid || phase == BlackoilPhases::Aqua) {
if (useField) {
if (unitType == UnitSystem::UNIT_TYPE_METRIC) {
unitName_ = "STB/DAY";
targetRateToSiConversionFactor_ = stb/day; // m^3/s -> STB/day
}
else {
else if (unitType == UnitSystem::UNIT_TYPE_FIELD) {
unitName_ = "SM3/DAY";
targetRateToSiConversionFactor_ = cubic(meter)/day; // m^3/s -> m^3/day
}
else
OPM_THROW(std::logic_error, "Deck uses unexpected unit system");
}
else if (phase == BlackoilPhases::Vapour) {
if (useField) {
if (unitType == UnitSystem::UNIT_TYPE_METRIC) {
unitName_ = "MSCF/DAY";
targetRateToSiConversionFactor_ = 1000*cubic(feet)/day; // m^3/s -> MSCF^3/day
}
else {
else if (unitType == UnitSystem::UNIT_TYPE_FIELD) {
unitName_ = "SM3/DAY";
targetRateToSiConversionFactor_ = cubic(meter)/day; // m^3/s -> m^3/day
}
else
OPM_THROW(std::logic_error, "Deck uses unexpected unit system");
}
else
OPM_THROW(std::logic_error,
@ -812,7 +815,7 @@ public:
PhaseUsage uses,
BlackoilPhases::PhaseIndex phase,
WellType type,
bool useFieldUnits)
UnitSystem::UnitType unitType)
: WellReport(summary,
eclipseState,
well,
@ -820,7 +823,7 @@ public:
phase,
type,
'T',
handleUnit_(phase, useFieldUnits))
handleUnit_(phase, unitType))
// nothing produced when the reporting starts
, total_(0.)
{ }
@ -860,27 +863,31 @@ public:
}
private:
const std::string handleUnit_(BlackoilPhases::PhaseIndex phase, bool useField) {
const std::string handleUnit_(BlackoilPhases::PhaseIndex phase, UnitSystem::UnitType unitType) {
using namespace Opm::unit;
if (phase == BlackoilPhases::Liquid || phase == BlackoilPhases::Aqua) {
if (useField) {
if (unitType == UnitSystem::UNIT_TYPE_METRIC) {
unitName_ = "STB/DAY";
targetRateToSiConversionFactor_ = stb/day; // m^3/s -> STB/day
}
else {
else if (unitType == UnitSystem::UNIT_TYPE_FIELD) {
unitName_ = "SM3/DAY";
targetRateToSiConversionFactor_ = cubic(meter)/day; // m^3/s -> m^3/day
}
else
OPM_THROW(std::logic_error, "Deck uses unexpected unit system");
}
else if (phase == BlackoilPhases::Vapour) {
if (useField) {
if (unitType == UnitSystem::UNIT_TYPE_METRIC) {
unitName_ = "MSCF/DAY";
targetRateToSiConversionFactor_ = 1000*cubic(feet)/day; // m^3/s -> MSCF^3/day
}
else {
else if (unitType == UnitSystem::UNIT_TYPE_FIELD) {
unitName_ = "SM3/DAY";
targetRateToSiConversionFactor_ = cubic(meter)/day; // m^3/s -> m^3/day
}
else
OPM_THROW(std::logic_error, "Deck uses unexpected unit system");
}
else
OPM_THROW(std::logic_error,
@ -986,12 +993,12 @@ void Summary::writeTimeStep(int writeStepIdx,
ecl_sum_fwrite(ertHandle());
}
void Summary::addAllWells(Opm::DeckConstPtr deck,
Opm::EclipseStateConstPtr eclipseState,
void Summary::addAllWells(Opm::EclipseStateConstPtr eclipseState,
const PhaseUsage& uses)
{
eclipseState_ = eclipseState;
bool useFieldUnits = !deck->hasKeyword("METRIC");
std::shared_ptr<const UnitSystem> unitsystem = eclipseState_->getDeckUnitSystem();
auto deckUnitType = unitsystem->getType();
// TODO: Only create report variables that are requested with keywords
// (e.g. "WOPR") in the input files, and only for those wells that are
@ -1018,7 +1025,7 @@ void Summary::addAllWells(Opm::DeckConstPtr deck,
uses,
ertPhaseIdx,
wellType,
useFieldUnits)));
deckUnitType)));
// W{O,G,W}{I,P}T
addWell(std::unique_ptr <WellReport>(
new WellTotal(*this,
@ -1027,7 +1034,7 @@ void Summary::addAllWells(Opm::DeckConstPtr deck,
uses,
ertPhaseIdx,
wellType,
useFieldUnits)));
deckUnitType)));
}
}
}
@ -1050,7 +1057,7 @@ void Summary::addAllWells(Opm::DeckConstPtr deck,
uses,
ertPhaseIdx,
WELL_TYPES[0],
useFieldUnits)));
deckUnitType)));
}
}
} // end namespace EclipseWriterDetails
@ -1165,7 +1172,7 @@ void EclipseWriter::writeInit(const SimulatorTimerInterface &timer)
eclGrid->getNX(),
eclGrid->getNY(),
eclGrid->getNZ()));
summary_->addAllWells(deck_, eclipseState_, phaseUsage_);
summary_->addAllWells(eclipseState_, phaseUsage_);
}
// implementation of the writeTimeStep method
@ -1332,13 +1339,11 @@ void EclipseWriter::writeTimeStep(const SimulatorTimerInterface& timer,
EclipseWriter::EclipseWriter(const parameter::ParameterGroup& params,
Opm::DeckConstPtr deck,
Opm::EclipseStateConstPtr eclipseState,
const Opm::PhaseUsage &phaseUsage,
int numCells,
const int* compressedToCartesianCellIdx)
: deck_(deck)
, eclipseState_(eclipseState)
: eclipseState_(eclipseState)
, numCells_(numCells)
, compressedToCartesianCellIdx_(compressedToCartesianCellIdx)
, gridToEclipseIdx_(numCells, int(-1) )

View File

@ -65,7 +65,6 @@ public:
* binary files using ERT.
*/
EclipseWriter(const parameter::ParameterGroup& params,
Opm::DeckConstPtr deck,
Opm::EclipseStateConstPtr eclipseState,
const Opm::PhaseUsage &phaseUsage,
int numCells,
@ -107,7 +106,6 @@ public:
static ert_ecl_unit_enum convertUnitTypeErtEclUnitEnum(UnitSystem::UnitType unit);
private:
Opm::DeckConstPtr deck_;
Opm::EclipseStateConstPtr eclipseState_;
int numCells_;
std::array<int, 3> cartesianSize_;

View File

@ -30,7 +30,6 @@ using namespace Opm;
SimulatorOutputBase::SimulatorOutputBase (
const parameter::ParameterGroup& params,
std::shared_ptr <const Deck> deck,
std::shared_ptr <const EclipseState> eclipseState,
const Opm::PhaseUsage &phaseUsage,
std::shared_ptr <const UnstructuredGrid> grid,
@ -46,7 +45,7 @@ SimulatorOutputBase::SimulatorOutputBase (
// process parameters into a writer. we don't setup a new chain in
// every timestep!
, writer_ (std::move (OutputWriter::create (params, deck, eclipseState, phaseUsage, grid)))
, writer_ (std::move (OutputWriter::create (params, eclipseState, phaseUsage, grid)))
// always start from the first timestep
, next_ (0) {

View File

@ -56,7 +56,6 @@ protected:
* need to pick them up from the object members.
*/
SimulatorOutputBase (const parameter::ParameterGroup& p,
std::shared_ptr <const Deck> deck,
std::shared_ptr <const EclipseState> eclipseState,
const Opm::PhaseUsage &phaseUsage,
std::shared_ptr <const UnstructuredGrid> grid,
@ -146,7 +145,6 @@ private:
template <typename Simulator>
struct SimulatorOutput : public SimulatorOutputBase {
SimulatorOutput (const parameter::ParameterGroup& params,
std::shared_ptr <const Deck> deck,
std::shared_ptr <const EclipseState> eclipseState,
const Opm::PhaseUsage &phaseUsage,
std::shared_ptr <const UnstructuredGrid> grid,
@ -155,7 +153,7 @@ struct SimulatorOutput : public SimulatorOutputBase {
std::shared_ptr <const WellState> wellState,
std::shared_ptr <Simulator> sim)
// send all other parameters to base class
: SimulatorOutputBase (params, deck, eclipseState, phaseUsage,
: SimulatorOutputBase (params, eclipseState, phaseUsage,
grid, timer, state, wellState)
// store reference to simulator in derived class
@ -171,7 +169,6 @@ struct SimulatorOutput : public SimulatorOutputBase {
* the arguments passed exceeds the lifetime of this object.
*/
SimulatorOutput (const parameter::ParameterGroup& params,
const Deck& deck,
const EclipseState& eclipseState,
const Opm::PhaseUsage &phaseUsage,
const UnstructuredGrid& grid,
@ -181,7 +178,6 @@ struct SimulatorOutput : public SimulatorOutputBase {
Simulator& sim)
// send all other parameters to base class
: SimulatorOutputBase (params,
share_obj (deck),
share_obj (eclipseState),
phaseUsage,
share_obj (grid),

View File

@ -136,7 +136,6 @@ std::shared_ptr<Opm::EclipseWriter> createEclipseWriter(std::shared_ptr<const Op
const UnstructuredGrid &ourFinerUnstructuredGrid = *ourFineGridManagerPtr->c_grid();
std::shared_ptr<Opm::EclipseWriter> eclipseWriter = std::make_shared<Opm::EclipseWriter>(params,
deck,
eclipseState,
phaseUsage,
ourFinerUnstructuredGrid.number_of_cells,

View File

@ -85,7 +85,6 @@ void createEclipseWriter(const char *deckString)
Opm::PhaseUsage phaseUsage = Opm::phaseUsageFromDeck(deck);
eclWriter.reset(new Opm::EclipseWriter(params,
deck,
eclipseState,
phaseUsage,
ourFinerUnstructuredGrid.number_of_cells,

View File

@ -151,7 +151,6 @@ Opm::EclipseWriterPtr createEclipseWriter(Opm::DeckConstPtr deck,
const Opm::PhaseUsage phaseUsage = Opm::phaseUsageFromDeck(deck);
Opm::EclipseWriterPtr eclWriter(new Opm::EclipseWriter(params,
deck,
eclipseState,
phaseUsage,
eclipseState->getEclipseGrid()->getCartesianSize(),