Merge pull request #4450 from akva2/simulatorreport_serialize

SimulatorReport: add serialization support
This commit is contained in:
Bård Skaflestad 2023-02-16 12:36:00 +01:00 committed by GitHub
commit c3da4f2341
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 92 additions and 0 deletions

View File

@ -29,6 +29,40 @@
namespace Opm 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) void SimulatorReportSingle::operator+=(const SimulatorReportSingle& sr)
{ {
pressure_time += sr.pressure_time; pressure_time += sr.pressure_time;
@ -168,6 +202,20 @@ namespace Opm
os << std::endl; os << std::endl;
} }
SimulatorReport SimulatorReport::serializationTestObject()
{
return SimulatorReport{SimulatorReportSingle::serializationTestObject(),
SimulatorReportSingle::serializationTestObject(),
{SimulatorReportSingle::serializationTestObject()}};
}
bool SimulatorReport::operator==(const SimulatorReport& rhs) const
{
return this->success == rhs.success &&
this->failure == rhs.failure &&
this->stepreports == rhs.stepreports;
}
void SimulatorReport::operator+=(const SimulatorReportSingle& sr) void SimulatorReport::operator+=(const SimulatorReportSingle& sr)
{ {
if (sr.converged) { if (sr.converged) {

View File

@ -58,12 +58,42 @@ namespace Opm
double global_time = 0.0; double global_time = 0.0;
double timestep_length = 0.0; double timestep_length = 0.0;
static SimulatorReportSingle serializationTestObject();
bool operator==(const SimulatorReportSingle&) const;
/// Increment this report's times by those in sr. /// Increment this report's times by those in sr.
void operator+=(const SimulatorReportSingle& sr); void operator+=(const SimulatorReportSingle& sr);
/// Print a report suitable for a single simulation step. /// Print a report suitable for a single simulation step.
void reportStep(std::ostream& os) const; void reportStep(std::ostream& os) const;
/// Print a report suitable for the end of a fully implicit case, leaving out the pressure/transport time. /// 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; void reportFullyImplicit(std::ostream& os, const SimulatorReportSingle* failedReport = nullptr) const;
template<class Serializer>
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 struct SimulatorReport
@ -72,10 +102,21 @@ namespace Opm
SimulatorReportSingle failure; SimulatorReportSingle failure;
std::vector<SimulatorReportSingle> stepreports; std::vector<SimulatorReportSingle> stepreports;
static SimulatorReport serializationTestObject();
bool operator==(const SimulatorReport&) const;
void operator+=(const SimulatorReportSingle& sr); void operator+=(const SimulatorReportSingle& sr);
void operator+=(const SimulatorReport& sr); void operator+=(const SimulatorReport& sr);
void reportFullyImplicit(std::ostream& os) const; void reportFullyImplicit(std::ostream& os) const;
void fullReports(std::ostream& os) const; void fullReports(std::ostream& os) const;
template<class Serializer>
void serializeOp(Serializer& serializer)
{
serializer(success);
serializer(failure);
serializer(stepreports);
}
}; };
} // namespace Opm } // namespace Opm

View File

@ -33,6 +33,7 @@
#include <opm/models/blackoil/blackoilprimaryvariables.hh> #include <opm/models/blackoil/blackoilprimaryvariables.hh>
#include <opm/simulators/timestepping/AdaptiveTimeSteppingEbos.hpp> #include <opm/simulators/timestepping/AdaptiveTimeSteppingEbos.hpp>
#include <opm/simulators/timestepping/SimulatorReport.hpp>
#include <opm/simulators/timestepping/SimulatorTimer.hpp> #include <opm/simulators/timestepping/SimulatorTimer.hpp>
#include <opm/simulators/timestepping/TimeStepControl.hpp> #include <opm/simulators/timestepping/TimeStepControl.hpp>
#include <opm/simulators/utils/SerializationPackers.hpp> #include <opm/simulators/utils/SerializationPackers.hpp>
@ -86,6 +87,8 @@ TEST_FOR_TYPE(PIDAndIterationCountTimeStepControl)
TEST_FOR_TYPE(PIDTimeStepControl) TEST_FOR_TYPE(PIDTimeStepControl)
TEST_FOR_TYPE(SegmentState) TEST_FOR_TYPE(SegmentState)
TEST_FOR_TYPE(SimpleIterationCountTimeStepControl) TEST_FOR_TYPE(SimpleIterationCountTimeStepControl)
TEST_FOR_TYPE(SimulatorReport)
TEST_FOR_TYPE(SimulatorReportSingle)
TEST_FOR_TYPE(SimulatorTimer) TEST_FOR_TYPE(SimulatorTimer)
namespace Opm { using ATE = AdaptiveTimeSteppingEbos<Properties::TTag::EbosTypeTag>; } namespace Opm { using ATE = AdaptiveTimeSteppingEbos<Properties::TTag::EbosTypeTag>; }