make the "OutputDir" parameter apply universally

all disc output, i.e. VTK, restart files, ECL and -- in the future --
logfiles, goes to that directory. before this, only the ECL output
could be directed to a different than the current working directory
and the parameter for this was called "EclOutputDir".

note that the Dune VTK writing infrastructure makes it harder than it
needs to be: suddenly Dune::VTKWriter::write() does not work in
parallel anymore, but Dune::VTKWriter::pwrite() must be called with
the right arguments.
This commit is contained in:
Andreas Lauser 2018-08-14 10:26:36 +02:00
parent 0d864f8e71
commit 6e7be50610
2 changed files with 35 additions and 30 deletions

View File

@ -62,11 +62,10 @@ NEW_PROP_TAG(Grid);
NEW_PROP_TAG(EquilGrid); NEW_PROP_TAG(EquilGrid);
NEW_PROP_TAG(Scalar); NEW_PROP_TAG(Scalar);
NEW_PROP_TAG(EclDeckFileName); NEW_PROP_TAG(EclDeckFileName);
NEW_PROP_TAG(EclOutputDir); NEW_PROP_TAG(OutputDir);
NEW_PROP_TAG(EclOutputInterval); NEW_PROP_TAG(EclOutputInterval);
SET_STRING_PROP(EclBaseVanguard, EclDeckFileName, ""); SET_STRING_PROP(EclBaseVanguard, EclDeckFileName, "");
SET_STRING_PROP(EclBaseVanguard, EclOutputDir, ".");
SET_INT_PROP(EclBaseVanguard, EclOutputInterval, -1); // use the deck-provided value SET_INT_PROP(EclBaseVanguard, EclOutputInterval, -1); // use the deck-provided value
END_PROPERTIES END_PROPERTIES
@ -101,8 +100,6 @@ public:
{ {
EWOMS_REGISTER_PARAM(TypeTag, std::string, EclDeckFileName, EWOMS_REGISTER_PARAM(TypeTag, std::string, EclDeckFileName,
"The name of the file which contains the ECL deck to be simulated"); "The name of the file which contains the ECL deck to be simulated");
EWOMS_REGISTER_PARAM(TypeTag, std::string, EclOutputDir,
"The directory to which the ECL result files are written");
EWOMS_REGISTER_PARAM(TypeTag, int, EclOutputInterval, EWOMS_REGISTER_PARAM(TypeTag, int, EclOutputInterval,
"The number of report steps that ought to be skipped between two writes of ECL results"); "The number of report steps that ought to be skipped between two writes of ECL results");
} }
@ -243,31 +240,6 @@ public:
summaryConfig_ = externalSummaryConfig_; summaryConfig_ = externalSummaryConfig_;
} }
// retrieve the location set by the user
std::string outputDir = EWOMS_GET_PARAM(TypeTag, std::string, EclOutputDir);
// update the location for output
auto& ioConfig = eclState_->getIOConfig();
if (outputDir == "")
// If no output directory parameter is specified, use the output directory
// which Opm::IOConfig thinks that should be used. Normally this is the
// directory in which the input files are located.
outputDir = ioConfig.getOutputDir();
// ensure that the output directory exists and that it is a directory
if (!boost::filesystem::is_directory(outputDir)) {
try {
boost::filesystem::create_directories(outputDir);
}
catch (...) {
throw std::runtime_error("Creation of output directory '"+outputDir+"' failed\n");
}
}
// specify the directory output. This is not a very nice mechanism because
// the eclState is supposed to be immutable here, IMO.
ioConfig.setOutputDir(outputDir);
// Possibly override IOConfig setting for how often RESTART files should get // Possibly override IOConfig setting for how often RESTART files should get
// written to disk (every N report step) // written to disk (every N report step)
int outputInterval = EWOMS_GET_PARAM(TypeTag, int, EclOutputInterval); int outputInterval = EWOMS_GET_PARAM(TypeTag, int, EclOutputInterval);
@ -276,6 +248,7 @@ public:
asImp_().createGrids_(); asImp_().createGrids_();
asImp_().filterConnections_(); asImp_().filterConnections_();
asImp_().updateOutputDir_();
asImp_().finalizeInit_(); asImp_().finalizeInit_();
} }
@ -391,6 +364,32 @@ public:
{ return std::unordered_set<std::string>(); } { return std::unordered_set<std::string>(); }
private: private:
void updateOutputDir_()
{
// update the location for output
std::string outputDir = EWOMS_GET_PARAM(TypeTag, std::string, OutputDir);
auto& ioConfig = eclState_->getIOConfig();
if (outputDir == "")
// If no output directory parameter is specified, use the output directory
// which Opm::IOConfig thinks that should be used. Normally this is the
// directory in which the input files are located.
outputDir = ioConfig.getOutputDir();
// ensure that the output directory exists and that it is a directory
if (!boost::filesystem::is_directory(outputDir)) {
try {
boost::filesystem::create_directories(outputDir);
}
catch (...) {
throw std::runtime_error("Creation of output directory '"+outputDir+"' failed\n");
}
}
// specify the directory output. This is not a very nice mechanism because
// the eclState is supposed to be immutable here, IMO.
ioConfig.setOutputDir(outputDir);
}
Implementation& asImp_() Implementation& asImp_()
{ return *static_cast<Implementation*>(this); } { return *static_cast<Implementation*>(this); }

View File

@ -255,7 +255,7 @@ SET_BOOL_PROP(EclBaseProblem, EnableAsyncEclOutput, true);
SET_BOOL_PROP(EclBaseProblem, EclOutputDoublePrecision, false); SET_BOOL_PROP(EclBaseProblem, EclOutputDoublePrecision, false);
// The default location for the ECL output files // The default location for the ECL output files
SET_STRING_PROP(EclBaseProblem, EclOutputDir, "."); SET_STRING_PROP(EclBaseProblem, OutputDir, ".");
// the cache for intensive quantities can be used for ECL problems and also yields a // the cache for intensive quantities can be used for ECL problems and also yields a
// decent speedup... // decent speedup...
@ -392,6 +392,12 @@ public:
"The frequencies of which time steps are serialized to disk"); "The frequencies of which time steps are serialized to disk");
} }
/*!
* \copydoc FvBaseProblem::prepareOutputDir
*/
std::string prepareOutputDir() const
{ return this->simulator().vanguard().eclState().getIOConfig().getOutputDir(); }
/*! /*!
* \copydoc FvBaseProblem::handlePositionalParameter * \copydoc FvBaseProblem::handlePositionalParameter
*/ */