Propagate UnstructuredGrid to the EclipseWriter ctor

The writer will need to know which cells are the active cells after
post-processing (because these are the cells there is stored results
for in the pressure and saturation arrays), and thus not only the
raw input grid (to get the COORD and ZCORN arrays which is not easily
detainable from the UnstructuredGrid), *and* the UnstructuredGrid
needs to be available.
This commit is contained in:
Roland Kaufmann committed 2013-11-25 14:14:48 +01:00
1 parent 3b22d1b8f9
commit ce7eb44836
6 files changed
+31 -13

No files matched your search

+9 -5
View File
@@ -45,8 +45,10 @@ private:
/// Psuedo-constructor, can appear in template
template <typename Format> unique_ptr <OutputWriter>
create (const ParameterGroup& params, std::shared_ptr <EclipseGridParser> parser) {
return unique_ptr <OutputWriter> (new Format (params, parser));
create (const ParameterGroup& params,
std::shared_ptr <EclipseGridParser> parser,
std::shared_ptr <UnstructuredGrid> grid) {
return unique_ptr <OutputWriter> (new Format (params, parser, grid));
}
/// Map between keyword in configuration and the corresponding
@@ -57,7 +59,8 @@ create (const ParameterGroup& params, std::shared_ptr <EclipseGridParser> parser
/// to the list below!
typedef map <const char*, unique_ptr <OutputWriter> (*)(
const ParameterGroup&,
std::shared_ptr <EclipseGridParser>)> map_t;
std::shared_ptr <EclipseGridParser>,
std::shared_ptr <UnstructuredGrid>)> map_t;
map_t FORMATS = {
{ "output_ecl", &create <EclipseWriter> },
};
@@ -66,7 +69,8 @@ map_t FORMATS = {
unique_ptr <OutputWriter>
OutputWriter::create (const ParameterGroup& params,
std::shared_ptr<EclipseGridParser> parser) {
std::shared_ptr <EclipseGridParser> parser,
std::shared_ptr <UnstructuredGrid> grid) {
// allocate a list which will be filled with writers. this list
// is initially empty (no output).
MultiWriter::ptr_t list (new MultiWriter::writers_t ());
@@ -81,7 +85,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_back (it->second (params, parser));
list->push_back (it->second (params, parser, grid));
}
}
+5 -2
View File
@@ -20,7 +20,9 @@
#ifndef OPM_OUTPUT_WRITER_HPP
#define OPM_OUTPUT_WRITER_HPP
#include <memory> // unique_ptr
#include <memory> // unique_ptr, shared_ptr
struct UnstructuredGrid;
namespace Opm {
@@ -90,7 +92,8 @@ public:
*/
static std::unique_ptr <OutputWriter>
create (const parameter::ParameterGroup& params,
std::shared_ptr <EclipseGridParser> parser);
std::shared_ptr <EclipseGridParser> parser,
std::shared_ptr <UnstructuredGrid> grid);
};
} // namespace Opm
+2 -1
View File
@@ -800,7 +800,8 @@ void EclipseWriter::writeTimeStep(
EclipseWriter::EclipseWriter (
const ParameterGroup& params,
std::shared_ptr <EclipseGridParser> parser)
std::shared_ptr <EclipseGridParser> parser,
std::shared_ptr <UnstructuredGrid> grid)
: parser_ (parser)
, uses_ (phaseUsageFromDeck (*parser)) {
+4 -1
View File
@@ -27,6 +27,8 @@
#include <string>
#include <memory> // std::unique_ptr
struct UnstructuredGrid;
namespace Opm {
// forward declarations
@@ -59,7 +61,8 @@ public:
* binary files using ERT.
*/
EclipseWriter(const parameter::ParameterGroup& params,
std::shared_ptr <EclipseGridParser> parser);
std::shared_ptr <EclipseGridParser> parser,
std::shared_ptr <UnstructuredGrid> grid);
/*!
* \brief Write the static eclipse data (grid, PVT curves, etc) to disk
+2 -1
View File
@@ -31,6 +31,7 @@ using namespace Opm;
SimulatorOutputBase::SimulatorOutputBase (
const parameter::ParameterGroup& params,
std::shared_ptr <EclipseGridParser> parser,
std::shared_ptr <UnstructuredGrid> grid,
std::shared_ptr <SimulatorTimer> timer,
std::shared_ptr <BlackoilState> state,
std::shared_ptr <WellState> wellState)
@@ -44,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, parser_)))
, writer_ (std::move (OutputWriter::create (params, parser, grid)))
// always start from the first timestep
, next_ (0) {
+9 -3
View File
@@ -23,6 +23,8 @@
#include <memory> // unique_ptr, shared_ptr
#include <vector>
struct UnstructuredGrid;
namespace Opm {
// forward definitions
@@ -48,6 +50,7 @@ protected:
*/
SimulatorOutputBase (const parameter::ParameterGroup& p,
std::shared_ptr <EclipseGridParser> parser,
std::shared_ptr <UnstructuredGrid> grid,
std::shared_ptr <SimulatorTimer> timer,
std::shared_ptr <BlackoilState> state,
std::shared_ptr <WellState> wellState);
@@ -99,6 +102,8 @@ private:
*
* // input file
* auto deck = make_shared <EclipseGridParser> ( ... );
* const GridManager manager (*parser);
* auto grid = share_obj (*manager.c_grid ());
*
* // timestep ends up here
* auto timer = make_shared <SimulatorTimer> ();
@@ -108,11 +113,11 @@ private:
* auto wellState = make_shared <WellState> ();
*
* // set up simulation
* auto sim = make_shared <SimulatorIncompTwophase> (params, grid, ... );
* auto sim = make_shared <SimulatorIncompTwophase> (params, *grid, ... );
*
* // use this to dump state to disk
* auto output = make_shared <SimulatorOutput> (
* params, deck, timer, state, wellState, sim);
* params, deck, grid, timer, state, wellState, sim);
*
* // start simulation
* sim.run (timer, state, ... )
@@ -126,12 +131,13 @@ template <typename Simulator>
struct SimulatorOutput : public SimulatorOutputBase {
SimulatorOutput (const parameter::ParameterGroup& params,
std::shared_ptr <EclipseGridParser> parser,
std::shared_ptr <UnstructuredGrid> grid,
std::shared_ptr <SimulatorTimer> timer,
std::shared_ptr <BlackoilState> state,
std::shared_ptr <WellState> wellState,
std::shared_ptr <Simulator> sim)
// send all other parameters to base class
: SimulatorOutputBase (params, parser, timer, state, wellState)
: SimulatorOutputBase (params, parser, grid, timer, state, wellState)
// store reference to simulator in derived class
, sim_ (sim) {