diff --git a/opm/output/data/Cells.hpp b/opm/output/data/Cells.hpp index 30059d7e4..bd7454a9f 100644 --- a/opm/output/data/Cells.hpp +++ b/opm/output/data/Cells.hpp @@ -15,51 +15,44 @@ You should have received a copy of the GNU General Public License along with OPM. If not, see . - */ +*/ #ifndef OPM_OUTPUT_CELLS_HPP #define OPM_OUTPUT_CELLS_HPP -#include -#include - #include -namespace Opm { +#include +#include -namespace data { +namespace Opm { namespace data { + // The 3D data which are saved to file are assembled in one large + // container. In the container the data is tagged with an element from + // the TargetType enum which specifies the vector's intended output + // destination. + // + //RESTART_SOLUTION: Cell-based quantities that are output to the + // SOLUTION section of the restart file. ECLIPSE-compatible names. + // + //RESTART_AUXILIARY: Fields with extra information, not required + // for restart. Examples of this include fluid in place values or + // evaluations of relative permeability. Will end up in the + // restart file. Deprecated and will be removed. + // + //SUMMARY: Fields which are added only to serve as input data for + // calculations of summary results. The Summary implementation can + // use data with any tag value, but if it is tagged as SUMMARY it + // will not be output anywhere else. + // + //INIT: Fields which should go to the INIT file. + // + //RESTART_OPM_EXTENDED: Cell-based quantities that are specific to + // OPM-Flow. Output only to extended OPM restart files. Specifically + // not output to ECLIPSE-compatible restart files. - /* - The 3D data which are saved to file are assembled in one large - container. In the container the data is tagged with an element - from the TargetType enum which indicates why they they have been - added to the container - and where they are headed. - - RESTART_SOLUTION : Cell-based quantities that are output to the - SOLUTION section of the restart file. ECLIPSE-compatible names. - Many, but not necessarily all, of these quantities are required - for restarting the simulator. - - RESTART_AUXILIARY : Fields with extra information, not required - for restart. Examples of this include fluid in place values or - evaluations of relative permeability. Will end up in the - restart file. - - SUMMARY : Fields which are added only to serve as input data for - calculations of summary results. The Summary implementation can - use data with any tag value, but if it is tagged as SUMMARY it - will not be output anywhere else. - - INIT : Fields which should go to the INIT file. - - RESTART_OPM_EXTENDED: Cell-based quantities that are specific to - OPM-Flow. Output only to extended OPM restart files. Specifically - not output to ECLIPSE-compatible restart files. - */ - - - enum class TargetType { + enum class TargetType + { RESTART_SOLUTION, RESTART_AUXILIARY, RESTART_TRACER_SOLUTION, @@ -68,38 +61,53 @@ namespace data { RESTART_OPM_EXTENDED, }; - /** - * Small struct that keeps track of data for output to restart/summary files. - */ - struct CellData { - UnitSystem::measure dim; //< Dimension of the data to write - std::vector data; //< The actual data itself - TargetType target; + /// Small struct that keeps track of data for output to restart/summary + /// files. + struct CellData + { + /// Dimension of the data to write + UnitSystem::measure dim{UnitSystem::measure::identity}; + + /// Per-cell solution values + std::vector data{}; + + /// File output destination + TargetType target{TargetType::RESTART_SOLUTION}; + + CellData() = default; + explicit CellData(UnitSystem::measure m, + std::vector x, + TargetType dest) + : dim { m } + , data { std::move(x) } + , target { dest } + {} bool operator==(const CellData& cell2) const { - return dim == cell2.dim && - data == cell2.data && - target == cell2.target; + return (dim == cell2.dim) + && (target == cell2.target) + && (data == cell2.data); } - template + template void serializeOp(Serializer& serializer) { - serializer(dim); - serializer(data); - serializer(target); + serializer(this->dim); + serializer(this->data); + serializer(this->target); } static CellData serializationTestObject() { - return CellData{UnitSystem::measure::runtime, - {1.0, 2.0, 3.0}, - TargetType::RESTART_TRACER_SOLUTION}; + return CellData { + UnitSystem::measure::runtime, + {1.0, 2.0, 3.0}, + TargetType::RESTART_OPM_EXTENDED + }; } }; -} -} +}} // namespace Opm::data #endif //OPM_OUTPUT_CELLS_HPP diff --git a/tests/test_EclipseIO.cpp b/tests/test_EclipseIO.cpp index 1c1652e60..c85e3cd2f 100644 --- a/tests/test_EclipseIO.cpp +++ b/tests/test_EclipseIO.cpp @@ -302,10 +302,10 @@ BOOST_AUTO_TEST_CASE(EclipseIOIntegration) { std::vector tranx(3*3*3); std::vector trany(3*3*3); std::vector tranz(3*3*3); - data::Solution eGridProps { - { "TRANX", { measure::transmissibility, tranx, TargetType::INIT } }, - { "TRANY", { measure::transmissibility, trany, TargetType::INIT } }, - { "TRANZ", { measure::transmissibility, tranz, TargetType::INIT } }, + const data::Solution eGridProps { + { "TRANX", data::CellData { measure::transmissibility, tranx, TargetType::INIT } }, + { "TRANY", data::CellData { measure::transmissibility, trany, TargetType::INIT } }, + { "TRANZ", data::CellData { measure::transmissibility, tranz, TargetType::INIT } }, }; std::map> int_data = {{"STR_ULONGNAME" , {1,1,1,1,1,1,1,1} } }; diff --git a/tests/test_Restart.cpp b/tests/test_Restart.cpp index 034b23f4a..1f8420a12 100644 --- a/tests/test_Restart.cpp +++ b/tests/test_Restart.cpp @@ -97,7 +97,6 @@ namespace { } } - namespace Opm { namespace data { @@ -201,19 +200,17 @@ data::Wells mkWells() { } } -data::Solution mkSolution( int numCells ) { - +data::Solution mkSolution(int numCells) +{ using measure = UnitSystem::measure; - using namespace data; - data::Solution sol = { - { "PRESSURE", { measure::pressure, std::vector( numCells ), TargetType::RESTART_SOLUTION } }, - { "TEMP", { measure::temperature, std::vector( numCells ), TargetType::RESTART_SOLUTION } }, - { "SWAT", { measure::identity, std::vector( numCells ), TargetType::RESTART_SOLUTION } }, - { "SGAS", { measure::identity, std::vector( numCells ), TargetType::RESTART_SOLUTION } } + auto sol = data::Solution { + { "PRESSURE", data::CellData { measure::pressure, {}, data::TargetType::RESTART_SOLUTION } }, + { "TEMP", data::CellData { measure::temperature, {}, data::TargetType::RESTART_SOLUTION } }, + { "SWAT", data::CellData { measure::identity, {}, data::TargetType::RESTART_SOLUTION } }, + { "SGAS", data::CellData { measure::identity, {}, data::TargetType::RESTART_SOLUTION } }, }; - sol.data("PRESSURE").assign( numCells, 6.0 ); sol.data("TEMP").assign( numCells, 7.0 ); sol.data("SWAT").assign( numCells, 8.0 ); @@ -222,8 +219,8 @@ data::Solution mkSolution( int numCells ) { fun::iota rsi( 300, 300 + numCells ); fun::iota rvi( 400, 400 + numCells ); - sol.insert( "RS", measure::identity, { rsi.begin(), rsi.end() } , TargetType::RESTART_SOLUTION ); - sol.insert( "RV", measure::identity, { rvi.begin(), rvi.end() } , TargetType::RESTART_SOLUTION ); + sol.insert("RS", measure::identity, { rsi.begin(), rsi.end() }, data::TargetType::RESTART_SOLUTION); + sol.insert("RV", measure::identity, { rvi.begin(), rvi.end() }, data::TargetType::RESTART_SOLUTION); return sol; } diff --git a/tests/test_Solution.cpp b/tests/test_Solution.cpp index 53f7122fb..fbad49607 100644 --- a/tests/test_Solution.cpp +++ b/tests/test_Solution.cpp @@ -64,15 +64,14 @@ BOOST_AUTO_TEST_CASE(Create) BOOST_AUTO_TEST_CASE(Create2) { - std::vector data(100); - data::Solution c = { - { "TRANX", { UnitSystem::measure::transmissibility, data, data::TargetType::RESTART_SOLUTION } }, - { "TRANY", { UnitSystem::measure::transmissibility, data, data::TargetType::RESTART_SOLUTION } }, - { "TRANZ", { UnitSystem::measure::transmissibility, data, data::TargetType::RESTART_SOLUTION } } + const auto c = data::Solution { + { "TRANX", data::CellData { UnitSystem::measure::transmissibility, data, data::TargetType::RESTART_SOLUTION } }, + { "TRANY", data::CellData { UnitSystem::measure::transmissibility, data, data::TargetType::RESTART_SOLUTION } }, + { "TRANZ", data::CellData { UnitSystem::measure::transmissibility, data, data::TargetType::RESTART_SOLUTION } }, }; - auto c2 = c; + const auto c2 = c; BOOST_CHECK_EQUAL( c2.size() , 3U ); BOOST_CHECK( c2.has("TRANX") ); }