36 {
39
40 char time_file_name[255] = {'\0'};
41
43
47 fileName = std::string(time_file_name);
48 }
49 } else {
50
51
53 }
56 "*** ERROR %s (time_data FILE NEEDED)",
fileName.c_str());
59 "The %s file not provided. Loading scaled with time.",
63 };
65 }
66
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.";
77 };
79 }
80
81 in_file_stream.seekg(0);
82 std::string line;
83 double time = 0.0, value = 0.0;
85
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);
90 auto time_str = iter;
91 auto value_str = ++iter;
92 if (time_str == end || value_str == end) {
94 "*** ERROR read data file error (check input time data file) ");
95 }
96 time = std::stod(time_str->str());
97 value = std::stod(value_str->str());
99 }
100 in_file_stream.close();
102 if (in_file_stream.is_open()) {
104 "*** ERROR file close unsuccessful");
105 }
107}
#define MOFEM_LOG_C(channel, severity, format,...)
#define MoFEMFunctionReturnHot(a)
Last executable line of each PETSc function used for error handling. Replaces return()
#define MoFEMFunctionBegin
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
@ MOFEM_DATA_INCONSISTENCY
#define MoFEMFunctionReturn(a)
Last executable line of each PETSc function used for error handling. Replaces return()
#define CHKERR
Inline error check.
#define MOFEM_LOG(channel, severity)
Log.
#define MOFEM_LOG_CHANNEL(channel)
Set and reset channel.
PetscErrorCode PetscOptionsGetString(PetscOptions *, const char pre[], const char name[], char str[], size_t size, PetscBool *set)
double getScaleFromData(const double time)
Get scaling at a given time when the scalar values have been provided. Uses linear interpolation on t...