11#ifndef _TIME_SCALING_HPP_
12#define _TIME_SCALING_HPP_
24 virtual double getScale(
const double time);
45 std::string file_name =
"",
bool error_if_file_not_given =
false,
46 ScalingFun def_scaling_fun = [](
double time) {
return time; });
59 std::string file_name, std::string delimiter,
60 bool error_if_file_not_given =
false,
61 ScalingFun def_scaling_fun = [](
double time) {
return time; });
94 static const std::string
111 template <
typename... Args>
112 static boost::shared_ptr<ScalingMethod>
113 get(boost::shared_ptr<ScalingMethod> ts, std::string file_prefix,
114 std::string file_suffix, std::string block_name, Args &&...args) {
116 auto get_file_name = [&]() {
117 return file_prefix +
"_" + block_name + file_suffix;
124 <<
"Block history file found: " << get_file_name();
126 return boost::make_shared<TS>(get_file_name(), args...);
134 namespace fs = std::filesystem;
135 if (!fs::exists(file_name) || !fs::is_regular_file(file_name)) {
147 bool error_if_file_not_given =
false);
150 bool error_if_file_not_given =
false);
159 std::map<double, FTensor::Tensor1<double, 3>>
tSeries;
166 [
this](
double time) {
#define MOFEM_LOG(channel, severity)
Log.
#define MOFEM_LOG_TAG(channel, tag)
Tag channel.
#define MOFEM_LOG_CHANNEL(channel)
Set and reset channel.
FTensor::Index< 'i', SPACE_DIM > i
PetscErrorCode MoFEMErrorCode
MoFEM/PETSc error code.
implementation of Data Operators for Forces and Sources
static auto check_file_exists(std::string &&file_name)
GetBlockScalingMethod()=delete
static boost::shared_ptr< ScalingMethod > get(boost::shared_ptr< ScalingMethod > ts, std::string file_prefix, std::string file_suffix, std::string block_name, Args &&...args)
virtual double getScale(const double time)
Get scaling at given time.
virtual ~ScalingMethod()=default
Force scale operator for reading four columns (time and vector)
std::map< double, FTensor::Tensor1< double, 3 > > tSeries
TimeScaleVector(std::string name="-time_vector_file", bool error_if_file_not_given=false)
std::function< FTensor::Tensor1< double, SPACE_DIM >(double)> scalingMethod
MoFEMErrorCode timeData()
virtual FTensor::Tensor1< double, SPACE_DIM > getVector(const double time)
virtual FTensor::Tensor1< double, SPACE_DIM > getVectorFromData(const double time)
Force scale operator for reading two columns.
ScalingFun defScalingMethod
double getLinearScale(const double time)
Returns the value of time.
std::function< double(double)> ScalingFun
double getScaleFromData(const double time)
Get scaling at a given time when the scalar values have been provided. Uses linear interpolation on t...
MoFEMErrorCode timeData(std::string fileName, std::string delimiter)
double getScale(const double time)
Get scaling at a given time.
TimeScale(std::string file_name="", bool error_if_file_not_given=false, ScalingFun def_scaling_fun=[](double time) { return time;})
TimeScale constructor.
static const std::string defaultDelimiter
comma or space
std::map< double, double > tSeries