mirror of
https://github.com/OPM/opm-simulators.git
synced 2025-02-25 18:55:30 -06:00
added: ability to specify .OPMRST file to be used
useful, in particular for testing.
This commit is contained in:
parent
72133deadc
commit
a60b7e50ca
@ -81,6 +81,12 @@ struct LoadStep
|
|||||||
using type = UndefinedProperty;
|
using type = UndefinedProperty;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
template <class TypeTag, class MyTypeTag>
|
||||||
|
struct SaveFile
|
||||||
|
{
|
||||||
|
using type = UndefinedProperty;
|
||||||
|
};
|
||||||
|
|
||||||
template<class TypeTag>
|
template<class TypeTag>
|
||||||
struct EnableTerminalOutput<TypeTag, TTag::EclFlowProblem> {
|
struct EnableTerminalOutput<TypeTag, TTag::EclFlowProblem> {
|
||||||
static constexpr bool value = true;
|
static constexpr bool value = true;
|
||||||
@ -106,6 +112,12 @@ struct SaveStep<TypeTag, TTag::EclFlowProblem>
|
|||||||
static constexpr auto* value = "";
|
static constexpr auto* value = "";
|
||||||
};
|
};
|
||||||
|
|
||||||
|
template <class TypeTag>
|
||||||
|
struct SaveFile<TypeTag, TTag::EclFlowProblem>
|
||||||
|
{
|
||||||
|
static constexpr auto* value = "";
|
||||||
|
};
|
||||||
|
|
||||||
template <class TypeTag>
|
template <class TypeTag>
|
||||||
struct LoadStep<TypeTag, TTag::EclFlowProblem>
|
struct LoadStep<TypeTag, TTag::EclFlowProblem>
|
||||||
{
|
{
|
||||||
@ -194,6 +206,11 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
loadStep_ = EWOMS_GET_PARAM(TypeTag, int, LoadStep);
|
loadStep_ = EWOMS_GET_PARAM(TypeTag, int, LoadStep);
|
||||||
|
|
||||||
|
saveFile_ = EWOMS_GET_PARAM(TypeTag, std::string, SaveFile);
|
||||||
|
if (saveFile_.empty()) {
|
||||||
|
saveFile_ = ebosSimulator_.vanguard().caseName() + ".OPMRST";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
~SimulatorFullyImplicitBlackoilEbos()
|
~SimulatorFullyImplicitBlackoilEbos()
|
||||||
@ -231,6 +248,10 @@ public:
|
|||||||
"Load serialized state from .OPMRST file. "
|
"Load serialized state from .OPMRST file. "
|
||||||
"Either a specific report step, or 0 to load last "
|
"Either a specific report step, or 0 to load last "
|
||||||
"stored report step.");
|
"stored report step.");
|
||||||
|
EWOMS_REGISTER_PARAM(TypeTag, std::string, SaveFile,
|
||||||
|
"FileName for .OPMRST file used for serialized state. "
|
||||||
|
"If empty, CASENAME.OPMRST is used.");
|
||||||
|
EWOMS_HIDE_PARAM(TypeTag, SaveFile);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Run the simulation.
|
/// Run the simulation.
|
||||||
@ -555,12 +576,11 @@ protected:
|
|||||||
#if !HAVE_HDF5
|
#if !HAVE_HDF5
|
||||||
OpmLog::error("Saving of serialized state requested, but no HDF5 support available.");
|
OpmLog::error("Saving of serialized state requested, but no HDF5 support available.");
|
||||||
#else
|
#else
|
||||||
const std::string fileName = ebosSimulator_.vanguard().caseName() + ".OPMRST";
|
|
||||||
const std::string groupName = "/report_step/" + std::to_string(nextStep);
|
const std::string groupName = "/report_step/" + std::to_string(nextStep);
|
||||||
if (nextStep == saveStride_ || nextStep == saveStep_) {
|
if (nextStep == saveStride_ || nextStep == saveStep_) {
|
||||||
std::filesystem::remove(fileName);
|
std::filesystem::remove(saveFile_);
|
||||||
}
|
}
|
||||||
HDF5Serializer writer(fileName, HDF5File::OpenMode::APPEND);
|
HDF5Serializer writer(saveFile_, HDF5File::OpenMode::APPEND);
|
||||||
if (nextStep == saveStride_ || nextStep == saveStep_) {
|
if (nextStep == saveStride_ || nextStep == saveStep_) {
|
||||||
std::ostringstream str;
|
std::ostringstream str;
|
||||||
Parameters::printValues<TypeTag>(str);
|
Parameters::printValues<TypeTag>(str);
|
||||||
@ -585,7 +605,6 @@ protected:
|
|||||||
OpmLog::error("Loading of serialized state requested, but no HDF5 support available.");
|
OpmLog::error("Loading of serialized state requested, but no HDF5 support available.");
|
||||||
loadStep_ = -1;
|
loadStep_ = -1;
|
||||||
#else
|
#else
|
||||||
const std::string fileName = ebosSimulator_.vanguard().caseName() + ".OPMRST";
|
|
||||||
HDF5Serializer reader(saveFile_, HDF5File::OpenMode::READ);
|
HDF5Serializer reader(saveFile_, HDF5File::OpenMode::READ);
|
||||||
if (loadStep_ == 0)
|
if (loadStep_ == 0)
|
||||||
loadStep_ = reader.lastReportStep();
|
loadStep_ = reader.lastReportStep();
|
||||||
@ -600,8 +619,7 @@ protected:
|
|||||||
void loadSimulatorState()
|
void loadSimulatorState()
|
||||||
{
|
{
|
||||||
#if HAVE_HDF5
|
#if HAVE_HDF5
|
||||||
const std::string fileName = ebosSimulator_.vanguard().caseName() + ".OPMRST";
|
HDF5Serializer reader(saveFile_, HDF5File::OpenMode::READ);
|
||||||
HDF5Serializer reader(fileName, HDF5File::OpenMode::READ);
|
|
||||||
const std::string groupName = "/report_step/" + std::to_string(loadStep_);
|
const std::string groupName = "/report_step/" + std::to_string(loadStep_);
|
||||||
reader.read(*this, groupName, "simulator_data");
|
reader.read(*this, groupName, "simulator_data");
|
||||||
#endif
|
#endif
|
||||||
@ -631,6 +649,7 @@ protected:
|
|||||||
int saveStride_ = -1; //!< Stride to save serialized state at
|
int saveStride_ = -1; //!< Stride to save serialized state at
|
||||||
int saveStep_ = -1; //!< Specific step to save serialized state at
|
int saveStep_ = -1; //!< Specific step to save serialized state at
|
||||||
int loadStep_ = -1; //!< Step to load serialized state from
|
int loadStep_ = -1; //!< Step to load serialized state from
|
||||||
|
std::string saveFile_; //!< File to load/save serialized state from/to.
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace Opm
|
} // namespace Opm
|
||||||
|
Loading…
Reference in New Issue
Block a user