SimulatorReportSingle: use in-class initializers

this way there are no explicit ctors, which again means
brace initialization works
This commit is contained in:
Arne Morten Kvarving 2023-02-09 11:28:46 +01:00
parent 949d03e564
commit cb3b50f4b7
2 changed files with 25 additions and 52 deletions

View File

@ -27,36 +27,9 @@
#include <ostream> #include <ostream>
#include <sstream> #include <sstream>
#include <fmt/format.h> #include <fmt/format.h>
#include <limits>
namespace Opm namespace Opm
{ {
SimulatorReportSingle::SimulatorReportSingle()
: pressure_time(0.0),
transport_time(0.0),
total_time(0.0),
solver_time(0.0),
assemble_time(0.0),
pre_post_time(0.0),
assemble_time_well(0.0),
linear_solve_setup_time(0.0),
linear_solve_time(0.0),
update_time(0.0),
output_write_time(0.0),
total_well_iterations(0),
total_linearizations( 0 ),
total_newton_iterations( 0 ),
total_linear_iterations( 0 ),
min_linear_iterations ( std::numeric_limits<unsigned int>::max() ),
max_linear_iterations ( 0 ),
converged(false),
well_group_control_changed(false),
exit_status(EXIT_SUCCESS),
global_time(0),
timestep_length(0.0)
{
}
void SimulatorReportSingle::operator+=(const SimulatorReportSingle& sr) void SimulatorReportSingle::operator+=(const SimulatorReportSingle& sr)
{ {
pressure_time += sr.pressure_time; pressure_time += sr.pressure_time;

View File

@ -19,8 +19,11 @@
#ifndef OPM_SIMULATORREPORT_HEADER_INCLUDED #ifndef OPM_SIMULATORREPORT_HEADER_INCLUDED
#define OPM_SIMULATORREPORT_HEADER_INCLUDED #define OPM_SIMULATORREPORT_HEADER_INCLUDED
#include <cassert> #include <cassert>
#include <cstdlib>
#include <iosfwd> #include <iosfwd>
#include <limits>
#include <vector> #include <vector>
namespace Opm namespace Opm
@ -29,35 +32,32 @@ namespace Opm
/// A struct for returning timing data from a simulator to its caller. /// A struct for returning timing data from a simulator to its caller.
struct SimulatorReportSingle struct SimulatorReportSingle
{ {
double pressure_time; double pressure_time = 0.0;
double transport_time; double transport_time = 0.0;
double total_time; double total_time = 0.0;
double solver_time; double solver_time = 0.0;
double assemble_time; double assemble_time = 0.0;
double pre_post_time; double pre_post_time = 0.0;
double assemble_time_well; double assemble_time_well = 0.0;
double linear_solve_setup_time; double linear_solve_setup_time = 0.0;
double linear_solve_time; double linear_solve_time = 0.0;
double update_time; double update_time = 0.0;
double output_write_time; double output_write_time = 0.0;
unsigned int total_well_iterations; unsigned int total_well_iterations = 0;
unsigned int total_linearizations; unsigned int total_linearizations = 0;
unsigned int total_newton_iterations; unsigned int total_newton_iterations = 0;
unsigned int total_linear_iterations; unsigned int total_linear_iterations = 0;
unsigned int min_linear_iterations; unsigned int min_linear_iterations = std::numeric_limits<unsigned int>::max();
unsigned int max_linear_iterations; unsigned int max_linear_iterations = 0;
bool converged = false;
bool well_group_control_changed = false;
int exit_status = EXIT_SUCCESS;
bool converged; double global_time = 0.0;
bool well_group_control_changed; double timestep_length = 0.0;
int exit_status;
double global_time;
double timestep_length;
/// Default constructor initializing all times to 0.0.
SimulatorReportSingle();
/// 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.