From f0ca3120ff490c049cd85654a3754cdef39f6444 Mon Sep 17 00:00:00 2001 From: Arne Morten Kvarving Date: Thu, 9 Feb 2023 11:52:49 +0100 Subject: [PATCH] SimulatorReportSingle: add serialization support --- .../timestepping/SimulatorReport.cpp | 34 +++++++++++++++++++ .../timestepping/SimulatorReport.hpp | 30 ++++++++++++++++ tests/test_RestartSerialization.cpp | 2 ++ 3 files changed, 66 insertions(+) diff --git a/opm/simulators/timestepping/SimulatorReport.cpp b/opm/simulators/timestepping/SimulatorReport.cpp index 2fb8607e1..bf25b3379 100644 --- a/opm/simulators/timestepping/SimulatorReport.cpp +++ b/opm/simulators/timestepping/SimulatorReport.cpp @@ -29,6 +29,40 @@ namespace Opm { + SimulatorReportSingle SimulatorReportSingle::serializationTestObject() + { + return SimulatorReportSingle{1.0, 2.0, 3.0, 4.0, 5.0, 6.0, + 7.0, 8.0, 9.0, 10.0, 11.0, + 12, 13, 14, 15, 16, 17, + true, false, 18, 19.0, 20.0}; + } + + bool SimulatorReportSingle::operator==(const SimulatorReportSingle& rhs) const + { + return this->pressure_time == rhs.pressure_time && + this->transport_time == rhs.transport_time && + this->total_time == rhs.total_time && + this->solver_time == rhs.solver_time && + this->assemble_time == rhs.assemble_time && + this->pre_post_time == rhs.pre_post_time && + this->assemble_time_well == rhs.assemble_time_well && + this->linear_solve_setup_time == rhs.linear_solve_setup_time && + this->linear_solve_time == rhs.linear_solve_time && + this->update_time == rhs.update_time && + this->output_write_time == rhs.output_write_time && + this->total_well_iterations == rhs.total_well_iterations && + this->total_linearizations == rhs.total_linearizations && + this->total_newton_iterations == rhs.total_newton_iterations && + this->total_linear_iterations == rhs.total_linear_iterations && + this->min_linear_iterations == rhs.min_linear_iterations && + this->max_linear_iterations == rhs.max_linear_iterations && + this->converged == rhs.converged && + this->well_group_control_changed == rhs.well_group_control_changed && + this->exit_status == rhs.exit_status && + this->global_time == rhs.global_time && + this->timestep_length == rhs.timestep_length; + } + void SimulatorReportSingle::operator+=(const SimulatorReportSingle& sr) { pressure_time += sr.pressure_time; diff --git a/opm/simulators/timestepping/SimulatorReport.hpp b/opm/simulators/timestepping/SimulatorReport.hpp index 3e1e32a3e..9ba49b467 100644 --- a/opm/simulators/timestepping/SimulatorReport.hpp +++ b/opm/simulators/timestepping/SimulatorReport.hpp @@ -58,12 +58,42 @@ namespace Opm double global_time = 0.0; double timestep_length = 0.0; + static SimulatorReportSingle serializationTestObject(); + + bool operator==(const SimulatorReportSingle&) const; /// Increment this report's times by those in sr. void operator+=(const SimulatorReportSingle& sr); /// Print a report suitable for a single simulation step. void reportStep(std::ostream& os) const; /// Print a report suitable for the end of a fully implicit case, leaving out the pressure/transport time. void reportFullyImplicit(std::ostream& os, const SimulatorReportSingle* failedReport = nullptr) const; + + template + void serializeOp(Serializer& serializer) + { + serializer(pressure_time); + serializer(transport_time); + serializer(total_time); + serializer(solver_time); + serializer(assemble_time); + serializer(pre_post_time); + serializer(assemble_time_well); + serializer(linear_solve_setup_time); + serializer(linear_solve_time); + serializer(update_time); + serializer(output_write_time); + serializer(total_well_iterations); + serializer(total_linearizations); + serializer(total_newton_iterations); + serializer(total_linear_iterations); + serializer(min_linear_iterations); + serializer(max_linear_iterations); + serializer(converged); + serializer(well_group_control_changed); + serializer(exit_status); + serializer(global_time); + serializer(timestep_length); + } }; struct SimulatorReport diff --git a/tests/test_RestartSerialization.cpp b/tests/test_RestartSerialization.cpp index a6653aa75..5fc28a0d9 100644 --- a/tests/test_RestartSerialization.cpp +++ b/tests/test_RestartSerialization.cpp @@ -33,6 +33,7 @@ #include #include +#include #include #include #include @@ -86,6 +87,7 @@ TEST_FOR_TYPE(PIDAndIterationCountTimeStepControl) TEST_FOR_TYPE(PIDTimeStepControl) TEST_FOR_TYPE(SegmentState) TEST_FOR_TYPE(SimpleIterationCountTimeStepControl) +TEST_FOR_TYPE(SimulatorReportSingle) TEST_FOR_TYPE(SimulatorTimer) namespace Opm { using ATE = AdaptiveTimeSteppingEbos; }