Force scale operator for reading two columns.
More...
#include <src/boundary_conditions/ScalingMethod.hpp>
Force scale operator for reading two columns.
- Examples
- dynamic_first_order_con_law.cpp, and plastic.cpp.
Definition at line 32 of file ScalingMethod.hpp.
◆ ScalingFun
◆ TimeScale() [1/2]
MoFEM::TimeScale::TimeScale |
( |
std::string |
file_name = "" , |
|
|
bool |
error_if_file_not_given = false , |
|
|
ScalingFun |
def_scaling_fun = [](double time) { return time; } |
|
) |
| |
TimeScale constructor.
- Parameters
-
file_name | Path to input CSV data file |
error_if_file_not_given | If file name is not provided, the constructor will throw an error if this flag is set to true or throw a warning and use linear scaling if this flag is set to false |
- Examples
- dynamic_first_order_con_law.cpp, and plastic.cpp.
Definition at line 22 of file ScalingMethod.cpp.
◆ TimeScale() [2/2]
MoFEM::TimeScale::TimeScale |
( |
std::string |
file_name, |
|
|
std::string |
delimiter, |
|
|
bool |
error_if_file_not_given = false , |
|
|
ScalingFun |
def_scaling_fun = [](double time) { return time; } |
|
) |
| |
TimeScale constructor.
- Parameters
-
file_name | Path to input CSV data file |
delimiter | Character which is used to separate the data in a csv row, by default it is ',' |
error_if_file_not_given | If file name is not provided, the constructor will throw an error if this flag is set to true or throw a warning and use linear scaling if this flag is set to false |
Definition at line 27 of file ScalingMethod.cpp.
32 "Error in reading time data");
◆ getLinearScale()
double MoFEM::TimeScale::getLinearScale |
( |
const double |
time | ) |
|
|
private |
Returns the value of time.
- Returns
- double
◆ getScale()
◆ getScaleFromData()
double MoFEM::TimeScale::getScaleFromData |
( |
const double |
time | ) |
|
|
private |
Get scaling at a given time when the scalar values have been provided. Uses linear interpolation on the nearest time range to calculate scaling if the provided time is not present in the data.
- Returns
- double
Definition at line 109 of file ScalingMethod.cpp.
117 auto it =
tSeries.lower_bound(time);
119 return (--it)->second;
130 double t = (time - lower.first) / (upper.first - lower.first);
131 double scale1 = upper.second;
132 double scale0 = lower.second;
133 return scale0 +
t * (scale1 - scale0);
◆ timeData()
MoFEMErrorCode MoFEM::TimeScale::timeData |
( |
std::string |
fileName, |
|
|
std::string |
delimiter |
|
) |
| |
|
private |
Definition at line 35 of file ScalingMethod.cpp.
40 char time_file_name[255] = {
'\0'};
47 fileName = std::string(time_file_name);
56 "*** ERROR %s (time_data FILE NEEDED)",
fileName.c_str());
59 "The %s file not provided. Loading scaled with time.",
67 std::ifstream in_file_stream(
fileName);
70 "*** ERROR data file < %s > open unsuccessful",
fileName.c_str());
73 <<
"*** Warning data file " <<
fileName
74 <<
" open unsuccessful. Using default time scaling.";
81 in_file_stream.seekg(0);
83 double time = 0.0, value = 0.0;
86 std::regex rgx(delimiter.c_str());
87 std::sregex_token_iterator end;
88 while (std::getline(in_file_stream, line)) {
89 std::sregex_token_iterator iter(line.begin(), line.end(), rgx, -1);
91 auto value_str = ++iter;
92 if (time_str == end || value_str == end) {
94 "*** ERROR read data file error (check input time data file) ");
96 time = std::stod(time_str->str());
97 value = std::stod(value_str->str());
100 in_file_stream.close();
102 if (in_file_stream.is_open()) {
104 "*** ERROR file close unsuccessful");
◆ argFileScale
PetscBool MoFEM::TimeScale::argFileScale = PETSC_FALSE |
◆ defaultDelimiter
const std::string MoFEM::TimeScale::defaultDelimiter |
|
staticprivate |
◆ defScalingMethod
ScalingFun MoFEM::TimeScale::defScalingMethod = [](double time) { return time; } |
|
private |
◆ errorIfFileNotGiven
bool MoFEM::TimeScale::errorIfFileNotGiven |
|
private |
◆ fileName
std::string MoFEM::TimeScale::fileName = "" |
◆ fileNameFlag
std::string MoFEM::TimeScale::fileNameFlag = "-time_scalar_file" |
|
private |
◆ scalingMethod
◆ tSeries
The documentation for this struct was generated from the following files: