From 98de8263978d7241a242c8eeb84554d26aadf92b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Atgeirr=20Fl=C3=B8=20Rasmussen?= Date: Thu, 14 Jun 2012 14:13:03 +0200 Subject: [PATCH] Moved SimulatorReport class into its own file, for reusability. --- opm/core/simulator/SimulatorReport.cpp | 47 ++++++++++++++++++++++++++ opm/core/simulator/SimulatorReport.hpp | 45 ++++++++++++++++++++++++ 2 files changed, 92 insertions(+) create mode 100644 opm/core/simulator/SimulatorReport.cpp create mode 100644 opm/core/simulator/SimulatorReport.hpp diff --git a/opm/core/simulator/SimulatorReport.cpp b/opm/core/simulator/SimulatorReport.cpp new file mode 100644 index 000000000..3d8e0c048 --- /dev/null +++ b/opm/core/simulator/SimulatorReport.cpp @@ -0,0 +1,47 @@ +/* + Copyright 2012 SINTEF ICT, Applied Mathematics. + + This file is part of the Open Porous Media project (OPM). + + OPM is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + OPM is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with OPM. If not, see . +*/ + +#include +#include + +namespace Opm +{ + SimulatorReport::SimulatorReport() + : pressure_time(0.0), + transport_time(0.0), + total_time(0.0) + { + } + + void SimulatorReport::operator+=(const SimulatorReport& sr) + { + pressure_time += sr.pressure_time; + transport_time += sr.transport_time; + total_time += sr.total_time; + } + + void SimulatorReport::report(std::ostream& os) + { + os << "Total time taken: " << total_time + << "\n Pressure time: " << pressure_time + << "\n Transport time: " << total_time << std::endl; + } + + +} // namespace Opm diff --git a/opm/core/simulator/SimulatorReport.hpp b/opm/core/simulator/SimulatorReport.hpp new file mode 100644 index 000000000..a763156c1 --- /dev/null +++ b/opm/core/simulator/SimulatorReport.hpp @@ -0,0 +1,45 @@ +/* + Copyright 2012 SINTEF ICT, Applied Mathematics. + + This file is part of the Open Porous Media project (OPM). + + OPM is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + OPM is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with OPM. If not, see . +*/ + +#ifndef OPM_SIMULATORREPORT_HEADER_INCLUDED +#define OPM_SIMULATORREPORT_HEADER_INCLUDED + +#include + +namespace Opm +{ + + /// A struct for returning timing data from a simulator to its caller. + struct SimulatorReport + { + double pressure_time; + double transport_time; + double total_time; + + /// Default constructor initializing all times to 0.0. + SimulatorReport(); + /// Increment this report's times by those in sr. + void operator+=(const SimulatorReport& sr); + /// Print a report to the given stream. + void report(std::ostream& os); + }; + +} // namespace Opm + +#endif // OPM_SIMULATORREPORT_HEADER_INCLUDED