write simulation details to log file.

This commit is contained in:
Liu Ming
2016-05-09 13:33:44 +08:00
parent 60b00a0ddf
commit 431a21d632
3 changed files with 56 additions and 34 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,10 @@ 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_);
std::cout << msg << std::endl;
OpmLog::info(msg);
}
}
nonlinear_solver.stabilizeNonlinearUpdate(dx, dx_old_, current_relaxation_);
@@ -1106,6 +1109,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 +1899,38 @@ 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';
std::cout << msg << std::endl;
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());
std::cout << ss.str() << std::endl;
}
for (int idx = 0; idx < nm; ++idx) {
@@ -2006,21 +2013,25 @@ 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);
std::cout << msg << std::endl;
}
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());
std::cout << ss.str() << std::endl;
}
return converged;
}

View File

@@ -264,9 +264,9 @@ namespace Opm
std::cout << "**********************************************************************\n";
std::cout << "* *\n";
std::cout << "* This is Flow (version " << version << ")"
<< std::string(26 - version.size(), ' ') << "*\n";
<< std::string(26 - version.size(), ' ') << "*\n";
std::cout << "* *\n";
std::cout << "* Flow is a simulator for fully implicit three-phase black-oil flow, *\n";
std::cout << "* Flow is a simulator for fully implicit three-phase black-oil flow, *\n";
std::cout << "* and is part of OPM. For more information see: *\n";
std::cout << "* http://opm-project.org *\n";
std::cout << "* *\n";
@@ -677,15 +677,20 @@ 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";
std::cout << msg << std::endl;
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);
std::cout << ss.str() << std::endl;
OpmLog::info(ss.str());
if (param_.anyUnused()) {
// This allows a user to catch typos and misunderstandings in the
// use of simulator parameters.

View File

@@ -129,7 +129,10 @@ namespace Opm
step_timer.start();
if ( terminal_output_ )
{
timer.report(std::cout);
std::ostringstream ss;
timer.report(ss);
OpmLog::info(ss.str());
std::cout << ss.str();
}
// Create wells and well state.
@@ -209,7 +212,10 @@ 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);
std::cout << msg << std::endl;
}
if ( output_writer_.output() ) {