Merge pull request #679 from qilicun/log_simulation_messages

write simulation details to log file.
This commit is contained in:
Atgeirr Flø Rasmussen 2016-05-19 15:09:39 +02:00
commit bd774ed06c
3 changed files with 50 additions and 33 deletions

View File

@ -43,6 +43,7 @@
#include <opm/core/props/rock/RockCompressibility.hpp>
#include <opm/common/ErrorMacros.hpp>
#include <opm/common/Exceptions.hpp>
#include <opm/common/OpmLog/OpmLog.hpp>
#include <opm/core/utility/Units.hpp>
#include <opm/core/well_controls.h>
#include <opm/core/utility/parameters/ParameterGroup.hpp>
@ -282,8 +283,9 @@ namespace detail {
current_relaxation_ -= nonlinear_solver.relaxIncrement();
current_relaxation_ = std::max(current_relaxation_, nonlinear_solver.relaxMax());
if (terminalOutputEnabled()) {
std::cout << " Oscillating behavior detected: Relaxation set to "
<< current_relaxation_ << std::endl;
std::string msg = " Oscillating behavior detected: Relaxation set to "
+ std::to_string(current_relaxation_);
OpmLog::info(msg);
}
}
nonlinear_solver.stabilizeNonlinearUpdate(dx, dx_old_, current_relaxation_);
@ -1105,7 +1107,7 @@ namespace detail {
if (converged) {
if ( terminal_output_ ) {
std::cout << "well converged iter: " << it << std::endl;
OpmLog::info("well converged iter: " + std::to_string(it));
}
const int nw = wells().number_of_wells;
{
@ -1895,35 +1897,36 @@ namespace detail {
{
// Only rank 0 does print to std::cout
if (iteration == 0) {
std::cout << "\nIter";
std::string msg = "Iter";
for (int idx = 0; idx < nm; ++idx) {
std::cout << " MB(" << materialName(idx).substr(0, 3) << ") ";
msg += " MB(" + materialName(idx).substr(0, 3) + ") ";
}
for (int idx = 0; idx < nm; ++idx) {
std::cout << " CNV(" << materialName(idx).substr(0, 1) << ") ";
msg += " CNV(" + materialName(idx).substr(0, 1) + ") ";
}
for (int idx = 0; idx < np; ++idx) {
std::cout << " W-FLUX(" << materialName(idx).substr(0, 1) << ")";
msg += " W-FLUX(" + materialName(idx).substr(0, 1) + ")";
}
// std::cout << " WELL-CONT ";
std::cout << '\n';
OpmLog::info(msg);
}
const std::streamsize oprec = std::cout.precision(3);
const std::ios::fmtflags oflags = std::cout.setf(std::ios::scientific);
std::cout << std::setw(4) << iteration;
std::ostringstream ss;
const std::streamsize oprec = ss.precision(3);
const std::ios::fmtflags oflags = ss.setf(std::ios::scientific);
ss << std::setw(4) << iteration;
for (int idx = 0; idx < nm; ++idx) {
std::cout << std::setw(11) << mass_balance_residual[idx];
ss << std::setw(11) << mass_balance_residual[idx];
}
for (int idx = 0; idx < nm; ++idx) {
std::cout << std::setw(11) << CNV[idx];
ss << std::setw(11) << CNV[idx];
}
for (int idx = 0; idx < np; ++idx) {
std::cout << std::setw(11) << well_flux_residual[idx];
ss << std::setw(11) << well_flux_residual[idx];
}
// std::cout << std::setw(11) << residualWell;
std::cout << std::endl;
std::cout.precision(oprec);
std::cout.flags(oflags);
ss.precision(oprec);
ss.flags(oflags);
OpmLog::info(ss.str());
}
for (int idx = 0; idx < nm; ++idx) {
@ -2006,21 +2009,23 @@ namespace detail {
{
// Only rank 0 does print to std::cout
if (iteration == 0) {
std::cout << "\nIter";
std::string msg;
msg = "Iter";
for (int idx = 0; idx < np; ++idx) {
std::cout << " W-FLUX(" << materialName(idx).substr(0, 1) << ")";
msg += " W-FLUX(" + materialName(idx).substr(0, 1) + ")";
}
std::cout << '\n';
OpmLog::info(msg);
}
const std::streamsize oprec = std::cout.precision(3);
const std::ios::fmtflags oflags = std::cout.setf(std::ios::scientific);
std::cout << std::setw(4) << iteration;
std::ostringstream ss;
const std::streamsize oprec = ss.precision(3);
const std::ios::fmtflags oflags = ss.setf(std::ios::scientific);
ss << std::setw(4) << iteration;
for (int idx = 0; idx < np; ++idx) {
std::cout << std::setw(11) << well_flux_residual[idx];
ss << std::setw(11) << well_flux_residual[idx];
}
std::cout << std::endl;
std::cout.precision(oprec);
std::cout.flags(oflags);
ss.precision(oprec);
ss.flags(oflags);
OpmLog::info(ss.str());
}
return converged;
}

View File

@ -385,7 +385,12 @@ namespace Opm
ParserPtr parser(new Parser());
{
std::shared_ptr<EclipsePRTLog> prtLog = std::make_shared<EclipsePRTLog>(logFile_ , Log::DefaultMessageTypes);
std::shared_ptr<StreamLog> streamLog = std::make_shared<StreamLog>(std::cout, Log::DefaultMessageTypes);
OpmLog::addBackend( "ECLIPSEPRTLOG" , prtLog );
OpmLog::addBackend( "STREAMLOG", streamLog);
prtLog->setMessageFormatter(std::make_shared<SimpleMessageFormatter>(false, false));
streamLog->setMessageLimiter(std::make_shared<MessageLimiter>(10));
streamLog->setMessageFormatter(std::make_shared<SimpleMessageFormatter>(false, true));
}
// Create Deck and EclipseState.
@ -692,15 +697,18 @@ namespace Opm
if (!schedule->initOnly()) {
if (output_cout_) {
std::cout << "\n\n================ Starting main simulation loop ===============\n"
<< std::flush;
std::string msg;
msg = "\n\n================ Starting main simulation loop ===============\n";
OpmLog::info(msg);
}
SimulatorReport fullReport = simulator_->run(simtimer, *state_);
if (output_cout_) {
std::cout << "\n\n================ End of simulation ===============\n\n";
fullReport.reportFullyImplicit(std::cout);
std::ostringstream ss;
ss << "\n\n================ End of simulation ===============\n\n";
fullReport.reportFullyImplicit(ss);
OpmLog::info(ss.str());
if (param_.anyUnused()) {
// This allows a user to catch typos and misunderstandings in the
// use of simulator parameters.

View File

@ -131,7 +131,9 @@ namespace Opm
step_timer.start();
if ( terminal_output_ )
{
timer.report(std::cout);
std::ostringstream ss;
timer.report(ss);
OpmLog::info(ss.str());
}
// Create wells and well state.
@ -211,7 +213,9 @@ namespace Opm
if ( terminal_output_ )
{
std::cout << "Fully implicit solver took: " << st << " seconds. Total solver time taken: " << stime << " seconds." << std::endl;
std::string msg;
msg = "Fully implicit solver took: " + std::to_string(st) + " seconds. Total solver time taken: " + std::to_string(stime) + " seconds.";
OpmLog::info(msg);
}
if ( output_writer_.output() ) {