Go to the documentation of this file.
44#define StepFunction_PRECISION 1.e-12
51double StepFunction :: evaluateAtTime(
double time)
66 }
else if ( size == 1) {
70 if (time < std::get<0>(this->
datevalues.at(1))) {
72 }
else if (time > std::get<0>(this->
datevalues.at(size-1))) {
73 return std::get<1>(this->
datevalues.at(size-1));
77 auto it = std::upper_bound(
79 [](
const std::tuple<double, double>& a,
const std::tuple<double, double>& b) {
80 return std::get<0>(a) < std::get<0>(b);
85 return std::get<1>(*(it - 1));
87 return std::get<1>(this->
datevalues.at(size-1));
112double StepFunction :: evaluateVelocityAtTime(
double time)
123 Function :: initializeFrom(ir);
132 std :: ifstream file(fname.c_str(), std :: ios :: in);
133 if ( !file.is_open() ) {
134 OOFEM_ERROR(
"Failed to open data file: %s\n", fname.c_str());
137 double temp_t, temp_ft;
138 std :: string sLine =
"";
139 while ( !file.eof() ) {
140 getline(file, sLine);
141 if ( sLine [ 0 ] ==
'#' ) {
144 std :: stringstream ss1(sLine);
145 ss1 >> temp_t >> temp_ft;
146 datevalues.push_back(std::tuple<double, double>(temp_t, temp_ft));
156 if ( dates.
size() != values.
size() ) {
157 OOFEM_ERROR (
"Size of t and f(t) arrays must be equal");
161 for (
int i = 0; i < dates.
size(); i++ ) {
162 datevalues.push_back(std::tuple<double, double>(dates(i), values(i)));
170 Function :: giveInputRecord(input);
172 int numberOfPoints = (int) this->
datevalues.size();
173 input.
setField(numberOfPoints,
"npoints");
174 FloatArray dates(numberOfPoints), values(numberOfPoints);
175 for (
int i = 0; i < numberOfPoints; i++ ) {
176 dates(i) = std::get<0>(this->
datevalues.at(i));
177 values(i) = std::get<1>(this->
datevalues.at(i));
189 int numberOfPoints = (int) this->
datevalues.size();
190 FloatArray dates(numberOfPoints), values(numberOfPoints);
191 for (
int i = 0; i < numberOfPoints; i++ ) {
192 dates(i) = std::get<0>(this->
datevalues.at(i));
193 values(i) = std::get<1>(this->
datevalues.at(i));
195 dates.storeYourself(stream);
208 if ( dates.
size() != values.
size() ) {
209 OOFEM_ERROR (
"Size of t and f(t) arrays must be equal");
213 for (
int i = 0; i < dates.
size(); i++ ) {
214 datevalues.push_back(std::tuple<double, double>(dates(i), values(i)));
#define REGISTER_Function(class)
contextIOResultType storeYourself(DataStream &stream) const
contextIOResultType restoreYourself(DataStream &stream)
Function(int n, Domain *d)
std::vector< std::tuple< double, double > > datevalues
#define _IFT_StepFunction_ft
#define _IFT_StepFunction_dataFile
#define _IFT_StepFunction_t
This page is part of the
OOFEM-3.0 documentation. Copyright Copyright (C) 1994-2025 Borek Patzak
Bořek Patzák
Project e-mail:
oofem@fsv.cvut.cz
Generated at for OOFEM by
doxygen
1.15.0 written by Dimitri van Heesch,
© 1997-2011