diff --git a/ebos/eclbasevanguard.hh b/ebos/eclbasevanguard.hh index 33d54625b..e2029814e 100644 --- a/ebos/eclbasevanguard.hh +++ b/ebos/eclbasevanguard.hh @@ -62,11 +62,10 @@ NEW_PROP_TAG(Grid); NEW_PROP_TAG(EquilGrid); NEW_PROP_TAG(Scalar); NEW_PROP_TAG(EclDeckFileName); -NEW_PROP_TAG(EclOutputDir); +NEW_PROP_TAG(OutputDir); NEW_PROP_TAG(EclOutputInterval); SET_STRING_PROP(EclBaseVanguard, EclDeckFileName, ""); -SET_STRING_PROP(EclBaseVanguard, EclOutputDir, "."); SET_INT_PROP(EclBaseVanguard, EclOutputInterval, -1); // use the deck-provided value END_PROPERTIES @@ -101,8 +100,6 @@ public: { EWOMS_REGISTER_PARAM(TypeTag, std::string, EclDeckFileName, "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, "The number of report steps that ought to be skipped between two writes of ECL results"); } @@ -243,31 +240,6 @@ public: 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 // written to disk (every N report step) int outputInterval = EWOMS_GET_PARAM(TypeTag, int, EclOutputInterval); @@ -276,6 +248,7 @@ public: asImp_().createGrids_(); asImp_().filterConnections_(); + asImp_().updateOutputDir_(); asImp_().finalizeInit_(); } @@ -391,6 +364,32 @@ public: { return std::unordered_set(); } 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_() { return *static_cast(this); } diff --git a/ebos/eclproblem.hh b/ebos/eclproblem.hh index 357ef3151..88c4fc96c 100644 --- a/ebos/eclproblem.hh +++ b/ebos/eclproblem.hh @@ -255,7 +255,7 @@ SET_BOOL_PROP(EclBaseProblem, EnableAsyncEclOutput, true); SET_BOOL_PROP(EclBaseProblem, EclOutputDoublePrecision, false); // 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 // decent speedup... @@ -392,6 +392,12 @@ public: "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 */