mirror of
https://github.com/OPM/opm-simulators.git
synced 2025-02-25 18:55:30 -06:00
Merge pull request #1226 from blattms/use-output-to-skip-debug-or-all-files
Use output to skip debug or all files
This commit is contained in:
commit
f48acb8807
@ -63,6 +63,15 @@ namespace Opm
|
|||||||
// The FlowMain class is the ebos based black-oil simulator.
|
// The FlowMain class is the ebos based black-oil simulator.
|
||||||
class FlowMainEbos
|
class FlowMainEbos
|
||||||
{
|
{
|
||||||
|
enum FileOutputValue{
|
||||||
|
//! \brief No output to files.
|
||||||
|
OUTPUT_NONE = 0,
|
||||||
|
//! \brief Output only to log files, no eclipse output.
|
||||||
|
OUTPUT_LOG_ONLY = 1,
|
||||||
|
//! \brief Output to all files.
|
||||||
|
OUTPUT_ALL = 3
|
||||||
|
};
|
||||||
|
|
||||||
public:
|
public:
|
||||||
typedef TTAG(EclFlowProblem) TypeTag;
|
typedef TTAG(EclFlowProblem) TypeTag;
|
||||||
typedef typename GET_PROP(TypeTag, MaterialLaw)::EclMaterialLawManager MaterialLawManager;
|
typedef typename GET_PROP(TypeTag, MaterialLaw)::EclMaterialLawManager MaterialLawManager;
|
||||||
@ -231,7 +240,26 @@ namespace Opm
|
|||||||
// Throws std::runtime_error if failed to create (if requested) output dir.
|
// Throws std::runtime_error if failed to create (if requested) output dir.
|
||||||
void setupOutput()
|
void setupOutput()
|
||||||
{
|
{
|
||||||
output_to_files_ = output_cout_ && param_.getDefault("output", true);
|
const std::string output = param_.getDefault("output", std::string("all"));
|
||||||
|
static std::map<std::string, FileOutputValue> string2OutputEnum =
|
||||||
|
{ {"none", OUTPUT_NONE },
|
||||||
|
{"false", OUTPUT_LOG_ONLY },
|
||||||
|
{"log", OUTPUT_LOG_ONLY },
|
||||||
|
{"all" , OUTPUT_ALL },
|
||||||
|
{"true" , OUTPUT_ALL }};
|
||||||
|
auto converted = string2OutputEnum.find(output);
|
||||||
|
if ( converted != string2OutputEnum.end() )
|
||||||
|
{
|
||||||
|
output_ = string2OutputEnum[output];
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
std::cerr << "Value " << output <<
|
||||||
|
" passed to option output was invalid. Using \"all\" instead."
|
||||||
|
<< std::endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
output_to_files_ = output_cout_ && output_ > OUTPUT_NONE;
|
||||||
|
|
||||||
// Setup output directory.
|
// Setup output directory.
|
||||||
auto& ioConfig = eclState().getIOConfig();
|
auto& ioConfig = eclState().getIOConfig();
|
||||||
@ -281,15 +309,25 @@ namespace Opm
|
|||||||
logFileStream << ".PRT";
|
logFileStream << ".PRT";
|
||||||
debugFileStream << ".DEBUG";
|
debugFileStream << ".DEBUG";
|
||||||
|
|
||||||
std::string debugFile = debugFileStream.str();
|
|
||||||
logFile_ = logFileStream.str();
|
logFile_ = logFileStream.str();
|
||||||
|
|
||||||
|
if( output_ > OUTPUT_NONE)
|
||||||
|
{
|
||||||
std::shared_ptr<EclipsePRTLog> prtLog = std::make_shared<EclipsePRTLog>(logFile_ , Log::NoDebugMessageTypes, false, output_cout_);
|
std::shared_ptr<EclipsePRTLog> prtLog = std::make_shared<EclipsePRTLog>(logFile_ , Log::NoDebugMessageTypes, false, output_cout_);
|
||||||
std::shared_ptr<StreamLog> streamLog = std::make_shared<StreamLog>(std::cout, Log::StdoutMessageTypes);
|
|
||||||
OpmLog::addBackend( "ECLIPSEPRTLOG" , prtLog );
|
OpmLog::addBackend( "ECLIPSEPRTLOG" , prtLog );
|
||||||
OpmLog::addBackend( "STREAMLOG", streamLog);
|
prtLog->setMessageLimiter(std::make_shared<MessageLimiter>());
|
||||||
|
prtLog->setMessageFormatter(std::make_shared<SimpleMessageFormatter>(false));
|
||||||
|
}
|
||||||
|
|
||||||
|
if( output_ >= OUTPUT_LOG_ONLY && !param_.getDefault("no_debug_log", false) )
|
||||||
|
{
|
||||||
|
std::string debugFile = debugFileStream.str();
|
||||||
std::shared_ptr<StreamLog> debugLog = std::make_shared<EclipsePRTLog>(debugFile, Log::DefaultMessageTypes, false, output_cout_);
|
std::shared_ptr<StreamLog> debugLog = std::make_shared<EclipsePRTLog>(debugFile, Log::DefaultMessageTypes, false, output_cout_);
|
||||||
OpmLog::addBackend( "DEBUGLOG" , debugLog);
|
OpmLog::addBackend( "DEBUGLOG" , debugLog);
|
||||||
|
}
|
||||||
|
|
||||||
|
std::shared_ptr<StreamLog> streamLog = std::make_shared<StreamLog>(std::cout, Log::StdoutMessageTypes);
|
||||||
|
OpmLog::addBackend( "STREAMLOG", streamLog);
|
||||||
const auto& msgLimits = eclState().getSchedule().getMessageLimits();
|
const auto& msgLimits = eclState().getSchedule().getMessageLimits();
|
||||||
const std::map<int64_t, int> limits = {{Log::MessageType::Note, msgLimits.getCommentPrintLimit(0)},
|
const std::map<int64_t, int> limits = {{Log::MessageType::Note, msgLimits.getCommentPrintLimit(0)},
|
||||||
{Log::MessageType::Info, msgLimits.getMessagePrintLimit(0)},
|
{Log::MessageType::Info, msgLimits.getMessagePrintLimit(0)},
|
||||||
@ -297,8 +335,6 @@ namespace Opm
|
|||||||
{Log::MessageType::Error, msgLimits.getErrorPrintLimit(0)},
|
{Log::MessageType::Error, msgLimits.getErrorPrintLimit(0)},
|
||||||
{Log::MessageType::Problem, msgLimits.getProblemPrintLimit(0)},
|
{Log::MessageType::Problem, msgLimits.getProblemPrintLimit(0)},
|
||||||
{Log::MessageType::Bug, msgLimits.getBugPrintLimit(0)}};
|
{Log::MessageType::Bug, msgLimits.getBugPrintLimit(0)}};
|
||||||
prtLog->setMessageLimiter(std::make_shared<MessageLimiter>());
|
|
||||||
prtLog->setMessageFormatter(std::make_shared<SimpleMessageFormatter>(false));
|
|
||||||
streamLog->setMessageLimiter(std::make_shared<MessageLimiter>(10, limits));
|
streamLog->setMessageLimiter(std::make_shared<MessageLimiter>(10, limits));
|
||||||
streamLog->setMessageFormatter(std::make_shared<SimpleMessageFormatter>(true));
|
streamLog->setMessageFormatter(std::make_shared<SimpleMessageFormatter>(true));
|
||||||
|
|
||||||
@ -548,7 +584,7 @@ namespace Opm
|
|||||||
|
|
||||||
void writeInit()
|
void writeInit()
|
||||||
{
|
{
|
||||||
bool output = param_.getDefault("output", true);
|
bool output = ( output_ > OUTPUT_LOG_ONLY );
|
||||||
bool output_ecl = param_.getDefault("output_ecl", true);
|
bool output_ecl = param_.getDefault("output_ecl", true);
|
||||||
if( output && output_ecl && grid().comm().rank() == 0 )
|
if( output && output_ecl && grid().comm().rank() == 0 )
|
||||||
{
|
{
|
||||||
@ -881,6 +917,7 @@ namespace Opm
|
|||||||
std::unique_ptr<EbosSimulator> ebosSimulator_;
|
std::unique_ptr<EbosSimulator> ebosSimulator_;
|
||||||
int mpi_rank_ = 0;
|
int mpi_rank_ = 0;
|
||||||
bool output_cout_ = false;
|
bool output_cout_ = false;
|
||||||
|
FileOutputValue output_ = OUTPUT_ALL;
|
||||||
bool must_distribute_ = false;
|
bool must_distribute_ = false;
|
||||||
ParameterGroup param_;
|
ParameterGroup param_;
|
||||||
bool output_to_files_ = false;
|
bool output_to_files_ = false;
|
||||||
|
@ -338,7 +338,12 @@ namespace Opm
|
|||||||
const Opm::EclipseState& eclipseState,
|
const Opm::EclipseState& eclipseState,
|
||||||
std::unique_ptr<EclipseIO>&& eclIO,
|
std::unique_ptr<EclipseIO>&& eclIO,
|
||||||
const Opm::PhaseUsage &phaseUsage)
|
const Opm::PhaseUsage &phaseUsage)
|
||||||
: output_( param.getDefault("output", true) ),
|
: output_( [ ¶m ] () -> bool {
|
||||||
|
// If output parameter is true or all, then we do output
|
||||||
|
const std::string outputString = param.getDefault("output", std::string("all"));
|
||||||
|
return ( outputString == "all" || outputString == "true" );
|
||||||
|
}()
|
||||||
|
),
|
||||||
parallelOutput_( output_ ? new ParallelDebugOutput< Grid >( grid, eclipseState, phaseUsage.num_phases, phaseUsage ) : 0 ),
|
parallelOutput_( output_ ? new ParallelDebugOutput< Grid >( grid, eclipseState, phaseUsage.num_phases, phaseUsage ) : 0 ),
|
||||||
outputDir_( eclipseState.getIOConfig().getOutputDir() ),
|
outputDir_( eclipseState.getIOConfig().getOutputDir() ),
|
||||||
restart_double_si_( output_ ? param.getDefault("restart_double_si", false) : false ),
|
restart_double_si_( output_ ? param.getDefault("restart_double_si", false) : false ),
|
||||||
|
Loading…
Reference in New Issue
Block a user