From ce7eb448362626bf720831f554fbb8ee738c653a Mon Sep 17 00:00:00 2001 From: Roland Kaufmann Date: Tue, 19 Nov 2013 11:44:27 +0100 Subject: [PATCH] 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. --- opm/core/io/OutputWriter.cpp | 14 +++++++++----- opm/core/io/OutputWriter.hpp | 7 +++++-- opm/core/io/eclipse/EclipseWriter.cpp | 3 ++- opm/core/io/eclipse/EclipseWriter.hpp | 5 ++++- opm/core/simulator/SimulatorOutput.cpp | 3 ++- opm/core/simulator/SimulatorOutput.hpp | 12 +++++++++--- 6 files changed, 31 insertions(+), 13 deletions(-) diff --git a/opm/core/io/OutputWriter.cpp b/opm/core/io/OutputWriter.cpp index 11e25497..2bc9d732 100644 --- a/opm/core/io/OutputWriter.cpp +++ b/opm/core/io/OutputWriter.cpp @@ -45,8 +45,10 @@ private: /// Psuedo-constructor, can appear in template template unique_ptr -create (const ParameterGroup& params, std::shared_ptr parser) { - return unique_ptr (new Format (params, parser)); +create (const ParameterGroup& params, + std::shared_ptr parser, + std::shared_ptr grid) { + return unique_ptr (new Format (params, parser, grid)); } /// Map between keyword in configuration and the corresponding @@ -57,7 +59,8 @@ create (const ParameterGroup& params, std::shared_ptr parser /// to the list below! typedef map (*)( const ParameterGroup&, - std::shared_ptr )> map_t; + std::shared_ptr , + std::shared_ptr )> map_t; map_t FORMATS = { { "output_ecl", &create }, }; @@ -66,7 +69,8 @@ map_t FORMATS = { unique_ptr OutputWriter::create (const ParameterGroup& params, - std::shared_ptr parser) { + std::shared_ptr parser, + std::shared_ptr 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 (name, false)) { - list->push_back (it->second (params, parser)); + list->push_back (it->second (params, parser, grid)); } } diff --git a/opm/core/io/OutputWriter.hpp b/opm/core/io/OutputWriter.hpp index 11878fef..f815371a 100644 --- a/opm/core/io/OutputWriter.hpp +++ b/opm/core/io/OutputWriter.hpp @@ -20,7 +20,9 @@ #ifndef OPM_OUTPUT_WRITER_HPP #define OPM_OUTPUT_WRITER_HPP -#include // unique_ptr +#include // unique_ptr, shared_ptr + +struct UnstructuredGrid; namespace Opm { @@ -90,7 +92,8 @@ public: */ static std::unique_ptr create (const parameter::ParameterGroup& params, - std::shared_ptr parser); + std::shared_ptr parser, + std::shared_ptr grid); }; } // namespace Opm diff --git a/opm/core/io/eclipse/EclipseWriter.cpp b/opm/core/io/eclipse/EclipseWriter.cpp index 505734c2..a6ba97fb 100644 --- a/opm/core/io/eclipse/EclipseWriter.cpp +++ b/opm/core/io/eclipse/EclipseWriter.cpp @@ -800,7 +800,8 @@ void EclipseWriter::writeTimeStep( EclipseWriter::EclipseWriter ( const ParameterGroup& params, - std::shared_ptr parser) + std::shared_ptr parser, + std::shared_ptr grid) : parser_ (parser) , uses_ (phaseUsageFromDeck (*parser)) { diff --git a/opm/core/io/eclipse/EclipseWriter.hpp b/opm/core/io/eclipse/EclipseWriter.hpp index ecba38c2..4e201255 100644 --- a/opm/core/io/eclipse/EclipseWriter.hpp +++ b/opm/core/io/eclipse/EclipseWriter.hpp @@ -27,6 +27,8 @@ #include #include // 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 parser); + std::shared_ptr parser, + std::shared_ptr grid); /*! * \brief Write the static eclipse data (grid, PVT curves, etc) to disk diff --git a/opm/core/simulator/SimulatorOutput.cpp b/opm/core/simulator/SimulatorOutput.cpp index c94e6771..08235bea 100644 --- a/opm/core/simulator/SimulatorOutput.cpp +++ b/opm/core/simulator/SimulatorOutput.cpp @@ -31,6 +31,7 @@ using namespace Opm; SimulatorOutputBase::SimulatorOutputBase ( const parameter::ParameterGroup& params, std::shared_ptr parser, + std::shared_ptr grid, std::shared_ptr timer, std::shared_ptr state, std::shared_ptr 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) { diff --git a/opm/core/simulator/SimulatorOutput.hpp b/opm/core/simulator/SimulatorOutput.hpp index 25e0a914..cca01cd4 100644 --- a/opm/core/simulator/SimulatorOutput.hpp +++ b/opm/core/simulator/SimulatorOutput.hpp @@ -23,6 +23,8 @@ #include // unique_ptr, shared_ptr #include +struct UnstructuredGrid; + namespace Opm { // forward definitions @@ -48,6 +50,7 @@ protected: */ SimulatorOutputBase (const parameter::ParameterGroup& p, std::shared_ptr parser, + std::shared_ptr grid, std::shared_ptr timer, std::shared_ptr state, std::shared_ptr wellState); @@ -99,6 +102,8 @@ private: * * // input file * auto deck = make_shared ( ... ); + * const GridManager manager (*parser); + * auto grid = share_obj (*manager.c_grid ()); * * // timestep ends up here * auto timer = make_shared (); @@ -108,11 +113,11 @@ private: * auto wellState = make_shared (); * * // set up simulation - * auto sim = make_shared (params, grid, ... ); + * auto sim = make_shared (params, *grid, ... ); * * // use this to dump state to disk * auto output = make_shared ( - * params, deck, timer, state, wellState, sim); + * params, deck, grid, timer, state, wellState, sim); * * // start simulation * sim.run (timer, state, ... ) @@ -126,12 +131,13 @@ template struct SimulatorOutput : public SimulatorOutputBase { SimulatorOutput (const parameter::ParameterGroup& params, std::shared_ptr parser, + std::shared_ptr grid, std::shared_ptr timer, std::shared_ptr state, std::shared_ptr wellState, std::shared_ptr 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) {