Coalesce called methods into init and timestep

This commit is contained in:
Roland Kaufmann 2013-11-06 12:57:53 +01:00
parent 572123675d
commit 5ce5975586
2 changed files with 79 additions and 104 deletions

View File

@ -137,16 +137,6 @@ time_t current (const SimulatorTimer& timer) {
} }
namespace Opm { namespace Opm {
void BlackoilEclipseOutputWriter::writeInitFile(const SimulatorTimer &timer)
{
#if HAVE_ERT
writeGridInitFile_(timer);
writeSummaryHeaderFile_(timer);
#else
OPM_THROW(std::runtime_error,
"The ERT libraries are required to write ECLIPSE output files.");
#endif // HAVE_ERT
}
/** /**
* Pointer to memory that holds the name to an Eclipse output file. * Pointer to memory that holds the name to an Eclipse output file.
@ -224,51 +214,6 @@ private:
} }
}; };
static double pasToBar (double pressureInPascal) {
return Opm::unit::convert::to (pressureInPascal, Opm::unit::barsa);
}
void BlackoilEclipseOutputWriter::writeReservoirState(const BlackoilState& reservoirState, const SimulatorTimer& timer)
{
#if HAVE_ERT
EclipseRestart rst (outputDir_,
baseName_,
timer);
rst.writeHeader (grid_,
timer,
ECL_OIL_PHASE | ECL_GAS_PHASE | ECL_WATER_PHASE);
EclipseSolution sol (rst);
// convert the pressures from Pascals to bar because eclipse
// seems to write bars
const std::vector<double>& pas = reservoirState.pressure ();
std::vector<double> bar (pas.size (), 0.);
std::transform (pas.begin(), pas.end(), bar.begin(), pasToBar);
sol.add (EclipseKeyword<double> ("PRESSURE", bar));
sol.add (EclipseKeyword<double> ("SWAT",
reservoirState.saturation(),
grid_.number_of_cells,
BlackoilPhases::Aqua,
BlackoilPhases::MaxNumPhases));
sol.add (EclipseKeyword<double> ("SOIL",
reservoirState.saturation(),
grid_.number_of_cells,
BlackoilPhases::Liquid,
BlackoilPhases::MaxNumPhases));
sol.add (EclipseKeyword<double> ("SGAS",
reservoirState.saturation(),
grid_.number_of_cells,
BlackoilPhases::Vapour,
BlackoilPhases::MaxNumPhases));
#else
OPM_THROW(std::runtime_error,
"The ERT libraries are required to write ECLIPSE output files.");
#endif // HAVE_ERT
}
/** /**
* Representation of an Eclipse grid. * Representation of an Eclipse grid.
*/ */
@ -403,24 +348,6 @@ private:
fortio_fclose) { } fortio_fclose) { }
}; };
#if HAVE_ERT
void BlackoilEclipseOutputWriter::writeGridInitFile_(const SimulatorTimer &timer)
{
EclipseGrid ecl_grid = EclipseGrid::make (eclipseParser_);
ecl_grid.write (outputDir_, baseName_, timer);
EclipseInit fortio = EclipseInit::make (outputDir_, baseName_, timer);
fortio.writeHeader (ecl_grid,
timer,
eclipseParser_,
ECL_OIL_PHASE | ECL_GAS_PHASE | ECL_WATER_PHASE);
/* This collection of keywords is somewhat arbitrary and random. */
fortio.writeKeyword<double> ("PERMX", eclipseParser_);
fortio.writeKeyword<double> ("PERMY", eclipseParser_);
fortio.writeKeyword<double> ("PERMZ", eclipseParser_);
}
// forward decl. of mutually dependent type // forward decl. of mutually dependent type
struct EclipseWellReport; struct EclipseWellReport;
@ -639,20 +566,24 @@ EclipseSummary::writeTimeStep (const SimulatorTimer& timer,
} }
} }
void BlackoilEclipseOutputWriter::writeWellState(const WellState& wellState, const SimulatorTimer& timer)
{
#if HAVE_ERT
sum_->writeTimeStep (timer, wellState);
#else
OPM_THROW(std::runtime_error,
"The ERT libraries are required to write ECLIPSE output files.");
#endif // HAVE_ERT
}
static WellType WELL_TYPES[] = { INJECTOR, PRODUCER }; static WellType WELL_TYPES[] = { INJECTOR, PRODUCER };
void BlackoilEclipseOutputWriter::writeSummaryHeaderFile_(const SimulatorTimer &timer) void BlackoilEclipseOutputWriter::writeInit(const SimulatorTimer &timer) {
{ /* Grid files */
EclipseGrid ecl_grid = EclipseGrid::make (eclipseParser_);
ecl_grid.write (outputDir_, baseName_, timer);
EclipseInit fortio = EclipseInit::make (outputDir_, baseName_, timer);
fortio.writeHeader (ecl_grid,
timer,
eclipseParser_,
ECL_OIL_PHASE | ECL_GAS_PHASE | ECL_WATER_PHASE);
fortio.writeKeyword<double> ("PERMX", eclipseParser_);
fortio.writeKeyword<double> ("PERMY", eclipseParser_);
fortio.writeKeyword<double> ("PERMZ", eclipseParser_);
/* Summary files */
sum_ = std::move (std::unique_ptr <EclipseSummary> ( sum_ = std::move (std::unique_ptr <EclipseSummary> (
new EclipseSummary (outputDir_, new EclipseSummary (outputDir_,
baseName_, baseName_,
@ -693,6 +624,65 @@ void BlackoilEclipseOutputWriter::writeSummaryHeaderFile_(const SimulatorTimer &
ecl_sum_fwrite(*sum_); ecl_sum_fwrite(*sum_);
} }
static double pasToBar (double pressureInPascal) {
return Opm::unit::convert::to (pressureInPascal, Opm::unit::barsa);
}
void BlackoilEclipseOutputWriter::writeTimeStep(
const SimulatorTimer& timer,
const BlackoilState& reservoirState,
const WellState& wellState) {
EclipseRestart rst (outputDir_,
baseName_,
timer);
rst.writeHeader (grid_,
timer,
ECL_OIL_PHASE | ECL_GAS_PHASE | ECL_WATER_PHASE);
EclipseSolution sol (rst);
// convert the pressures from Pascals to bar because eclipse
// seems to write bars
const std::vector<double>& pas = reservoirState.pressure ();
std::vector<double> bar (pas.size (), 0.);
std::transform (pas.begin(), pas.end(), bar.begin(), pasToBar);
sol.add (EclipseKeyword<double> ("PRESSURE", bar));
sol.add (EclipseKeyword<double> ("SWAT",
reservoirState.saturation(),
grid_.number_of_cells,
BlackoilPhases::Aqua,
BlackoilPhases::MaxNumPhases));
sol.add (EclipseKeyword<double> ("SOIL",
reservoirState.saturation(),
grid_.number_of_cells,
BlackoilPhases::Liquid,
BlackoilPhases::MaxNumPhases));
sol.add (EclipseKeyword<double> ("SGAS",
reservoirState.saturation(),
grid_.number_of_cells,
BlackoilPhases::Vapour,
BlackoilPhases::MaxNumPhases));
/* Summary variables (well reporting) */
sum_->writeTimeStep (timer, wellState);
}
#else
void BlackoilEclipseOutputWriter::writeInit(const SimulatorTimer &timer) {
OPM_THROW(std::runtime_error,
"The ERT libraries are required to write ECLIPSE output files.");
}
void BlackoilEclipseOutputWriter::writeTimeStep(
const SimulatorTimer& timer,
const BlackoilState& reservoirState,
const WellState& wellState) {
OPM_THROW(std::runtime_error,
"The ERT libraries are required to write ECLIPSE output files.");
}
#endif // HAVE_ERT #endif // HAVE_ERT
} // namespace Opm } // namespace Opm

View File

@ -80,31 +80,21 @@ public:
{ {
} }
~BlackoilEclipseOutputWriter()
{
}
/*! /*!
* \brief Write the static eclipse data (grid, PVT curves, etc) to disk * \brief Write the static eclipse data (grid, PVT curves, etc) to disk
*/ */
void writeInitFile(const SimulatorTimer &timer); void writeInit(const SimulatorTimer &timer);
/*! /*!
* \brief Write a blackoil reservoir state to disk for later inspection with * \brief Write a blackoil reservoir state to disk for later inspection with
* visualization tools like ResInsight * visualization tools like ResInsight
* *
* \param[in] reservoirState The thermodynamic state of the reservoir * \param[in] reservoirState The thermodynamic state of the reservoir
*/
void writeReservoirState(const BlackoilState& reservoirState,
const SimulatorTimer& timer);
/*!
* \brief Write a well state to disk for later inspection with
* visualization tools
*
* \param[in] wellState The production/injection data for all wells * \param[in] wellState The production/injection data for all wells
*/ */
void writeWellState(const WellState& wellState, const SimulatorTimer& timer); void writeTimeStep(const SimulatorTimer& timer,
const BlackoilState& reservoirState,
const WellState& wellState);
private: private:
const EclipseGridParser& eclipseParser_; const EclipseGridParser& eclipseParser_;
@ -113,11 +103,6 @@ private:
std::string baseName_; std::string baseName_;
std::unique_ptr <EclipseSummary> sum_; std::unique_ptr <EclipseSummary> sum_;
#if HAVE_ERT
void writeSummaryHeaderFile_(const SimulatorTimer &timer);
void writeGridInitFile_(const SimulatorTimer &timer);
#endif
}; };
} // namespace Opm } // namespace Opm