Moved SimulatorReport class into its own file, for reusability.

This commit is contained in:
Atgeirr Flø Rasmussen 2012-06-14 14:13:03 +02:00
parent 3f630b8d6b
commit 95bf53cc30
6 changed files with 105 additions and 47 deletions

View File

@ -108,6 +108,7 @@ opm/core/pressure/ifsh.c \
opm/core/pressure/mimetic/mimetic.c \
opm/core/pressure/mimetic/hybsys_global.c \
opm/core/pressure/mimetic/hybsys.c \
opm/core/simulator/SimulatorReport.cpp \
opm/core/simulator/SimulatorTimer.cpp \
opm/core/simulator/SimulatorTwophase.cpp \
opm/core/transport/spu_explicit.c \
@ -229,6 +230,7 @@ opm/core/pressure/mimetic/hybsys_global.h \
opm/core/pressure/mimetic/hybsys.h \
opm/core/pressure/mimetic/mimetic.h \
opm/core/simulator/BlackoilState.hpp \
opm/core/simulator/SimulatorReport.hpp \
opm/core/simulator/SimulatorTimer.hpp \
opm/core/simulator/SimulatorTwophase.hpp \
opm/core/simulator/TwophaseState.hpp \

View File

@ -30,6 +30,7 @@
#include <opm/core/wells/WellsManager.hpp>
#include <opm/core/utility/ErrorMacros.hpp>
#include <opm/core/utility/initState.hpp>
#include <opm/core/simulator/SimulatorReport.hpp>
#include <opm/core/simulator/SimulatorTimer.hpp>
#include <opm/core/utility/miscUtilities.hpp>
#include <opm/core/utility/parameters/ParameterGroup.hpp>
@ -173,7 +174,7 @@ main(int argc, char** argv)
<< " (number of epochs: "
<< (use_deck ? deck->numberOfEpochs() : 1) << ")\n\n" << std::flush;
SimulatorTwophase::SimulatorReport rep;
SimulatorReport rep;
if (!use_deck) {
// Simple simulation without a deck.
SimulatorTwophase simulator(param,
@ -239,8 +240,7 @@ main(int argc, char** argv)
bcs.c_bcs(),
linsolver,
grav);
SimulatorTwophase::SimulatorReport epoch_rep
= simulator.run(simtimer, state, well_state);
SimulatorReport epoch_rep = simulator.run(simtimer, state, well_state);
// Update total timing report and remember step number.
rep += epoch_rep;

View File

@ -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 <http://www.gnu.org/licenses/>.
*/
#include <opm/core/simulator/SimulatorReport.hpp>
#include <iostream>
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

View File

@ -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 <http://www.gnu.org/licenses/>.
*/
#ifndef OPM_SIMULATORREPORT_HEADER_INCLUDED
#define OPM_SIMULATORREPORT_HEADER_INCLUDED
#include <iosfwd>
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

View File

@ -31,6 +31,7 @@
#include <opm/core/newwells.h>
#include <opm/core/pressure/flow_bc.h>
#include <opm/core/simulator/SimulatorReport.hpp>
#include <opm/core/simulator/SimulatorTimer.hpp>
#include <opm/core/utility/StopWatch.hpp>
#include <opm/core/utility/writeVtkData.hpp>
@ -120,10 +121,9 @@ namespace Opm
SimulatorTwophase::SimulatorReport
SimulatorTwophase::run(SimulatorTimer& timer,
TwophaseState& state,
WellState& well_state)
SimulatorReport SimulatorTwophase::run(SimulatorTimer& timer,
TwophaseState& state,
WellState& well_state)
{
return pimpl_->run(timer, state, well_state);
}
@ -253,10 +253,9 @@ namespace Opm
SimulatorTwophase::SimulatorReport
SimulatorTwophase::Impl::run(SimulatorTimer& timer,
TwophaseState& state,
WellState& well_state)
SimulatorReport SimulatorTwophase::Impl::run(SimulatorTimer& timer,
TwophaseState& state,
WellState& well_state)
{
std::vector<double> transport_src;
@ -397,29 +396,4 @@ namespace Opm
}
// Methods for SimulatorReport.
SimulatorTwophase::SimulatorReport::SimulatorReport()
: pressure_time(0.0),
transport_time(0.0),
total_time(0.0)
{
}
void SimulatorTwophase::SimulatorReport::operator+=(const SimulatorReport& sr)
{
pressure_time += sr.pressure_time;
transport_time += sr.transport_time;
total_time += sr.total_time;
}
void SimulatorTwophase::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

View File

@ -36,6 +36,7 @@ namespace Opm
class SimulatorTimer;
class TwophaseState;
class WellState;
class SimulatorReport;
/// Class collecting all necessary components for a two-phase simulation.
class SimulatorTwophase
@ -75,17 +76,6 @@ namespace Opm
LinearSolverInterface& linsolver,
const double* gravity);
/// A struct for returning timing data to the client.
struct SimulatorReport
{
double pressure_time;
double transport_time;
double total_time;
SimulatorReport();
void operator+=(const SimulatorReport& sr);
void report(std::ostream& os);
};
/// Run the simulation.
/// This will run succesive timesteps until timer.done() is true. It will
/// modify the reservoir and well states.