mirror of
https://github.com/OPM/opm-simulators.git
synced 2025-02-16 20:24:48 -06:00
add utility function to read time step files
and use this in simulator.hh
This commit is contained in:
parent
478ddb5e52
commit
5d2a25ac14
@ -322,6 +322,7 @@ macro (sources_hook)
|
||||
list(APPEND qm_defs HAVE_QUAD=1)
|
||||
get_target_property(qm_options QuadMath::QuadMath INTERFACE_COMPILE_OPTIONS)
|
||||
set_source_files_properties(opm/models/utils/parametersystem.cpp
|
||||
opm/models/utils/simulatorutils.cpp
|
||||
PROPERTIES COMPILE_DEFINITIONS "${qm_defs}"
|
||||
COMPILE_OPTIONS "${qm_options}")
|
||||
endif()
|
||||
|
@ -44,10 +44,9 @@
|
||||
#include <opm/models/utils/timerguard.hh>
|
||||
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
#include <vector>
|
||||
#include <string>
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#define EWOMS_CATCH_PARALLEL_EXCEPTIONS_FATAL(code) \
|
||||
{ \
|
||||
@ -126,12 +125,7 @@ public:
|
||||
const std::string& predetTimeStepFile =
|
||||
Parameters::Get<Parameters::PredeterminedTimeStepsFile>();
|
||||
if (!predetTimeStepFile.empty()) {
|
||||
std::ifstream is(predetTimeStepFile);
|
||||
while (!is.eof()) {
|
||||
Scalar dt;
|
||||
is >> dt;
|
||||
forcedTimeSteps_.push_back(dt);
|
||||
}
|
||||
forcedTimeSteps_ = readTimeStepFile<Scalar>(predetTimeStepFile);
|
||||
}
|
||||
|
||||
episodeIdx_ = 0;
|
||||
|
@ -25,8 +25,14 @@
|
||||
#include <opm/models/utils/simulatorutils.hpp>
|
||||
|
||||
#include <cmath>
|
||||
#include <fstream>
|
||||
#include <iomanip>
|
||||
#include <sstream>
|
||||
#include <vector>
|
||||
|
||||
#if HAVE_QUAD
|
||||
#include <opm/material/common/quad.hpp>
|
||||
#endif
|
||||
|
||||
namespace Opm {
|
||||
|
||||
@ -104,4 +110,26 @@ std::string humanReadableTime(double timeInSeconds, bool isAmendment)
|
||||
return oss.str();
|
||||
}
|
||||
|
||||
template<class Scalar>
|
||||
std::vector<Scalar> readTimeStepFile(const std::string& file)
|
||||
{
|
||||
std::ifstream is(file);
|
||||
std::vector<Scalar> result;
|
||||
while (!is.eof()) {
|
||||
Scalar dt;
|
||||
is >> dt;
|
||||
result.push_back(dt);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
template std::vector<double> readTimeStepFile(const std::string&);
|
||||
template std::vector<float> readTimeStepFile(const std::string&);
|
||||
|
||||
#if HAVE_QUAD
|
||||
template std::vector<quad> readTimeStepFile(const std::string&);
|
||||
#endif
|
||||
|
||||
|
||||
} // end namespace Opm
|
||||
|
@ -25,6 +25,7 @@
|
||||
#define OPM_SIMULATOR_UTILS_HPP
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
namespace Opm {
|
||||
|
||||
@ -36,6 +37,13 @@ namespace Opm {
|
||||
*/
|
||||
std::string humanReadableTime(double timeInSeconds, bool isAmendment = true);
|
||||
|
||||
/*!
|
||||
* \brief Read explicitly defined time steps from file.
|
||||
* \param file File to read
|
||||
*/
|
||||
template<class Scalar>
|
||||
std::vector<Scalar> readTimeStepFile(const std::string& file);
|
||||
|
||||
} // namespace Opm
|
||||
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user