Go to the documentation of this file.
44#define PiecewiseLinFunction_PRECISION 1.e-12
51double PiecewiseLinFunction :: evaluateAtTime(
double time)
57 double xa, xb, ya, yb;
59 if ( this->
dates.giveSize() == 0 ) {
63 for (
int i = 1; i <= this->
dates.giveSize(); i++ ) {
64 if ( fabs(this->
dates.at(i) - time) < precision ) {
66 }
else if ( this->
dates.at(i) > time ) {
68 OOFEM_WARNING(
"computational time %f is out of given time %f, using closest value", time,
dates.at(i) );
69 return this->
dates.at(i);
72 xa = this->
dates.at(i - 1);
73 xb = this->
dates.at(i);
74 ya = this->
values.at(i - 1);
77 return ya + ( time - xa ) * ( yb - ya ) / ( xb - xa );
81 OOFEM_WARNING(
"computational time %f is out of given time, using closest value", time );
85double PiecewiseLinFunction :: evaluateVelocityAtTime(
double time)
91 double xa, xb, ya, yb;
93 if ( this->
dates.giveSize() == 0 ) {
97 for (
int i = 1; i <= this->
dates.giveSize(); i++ ) {
98 if ( fabs(
dates.at(i) - time) < precision ) {
99 if ( i < this->
dates.giveSize() ) {
100 return ( this->
values.at(i + 1) - this->values.at(i) ) / ( this->
dates.at(i + 1) - this->
dates.at(i) );
102 return ( this->
values.at(i) - this->values.at(i - 1) ) / ( this->
dates.at(i) - this->
dates.at(i - 1) );
104 }
else if (
dates.at(i) > time ) {
109 xa = this->
dates.at(i - 1);
110 xb = this->
dates.at(i);
111 ya = this->
values.at(i - 1);
114 return ( yb - ya ) / ( xb - xa );
124 Function :: initializeFrom(ir);
128 std :: list< double >t, ft;
133 std :: ifstream file(fname.c_str(), std :: ios :: in);
134 if ( !file.is_open() ) {
135 OOFEM_ERROR(
"Failed to open data file: %s\n", fname.c_str());
138 double temp_t, temp_ft;
139 std :: string sLine =
"";
140 while ( !file.eof() ) {
141 getline(file, sLine);
142 if ( sLine [ 0 ] ==
'#' ) {
145 std :: stringstream ss1(sLine);
146 ss1 >> temp_t >> temp_ft;
148 ft.push_back(temp_ft);
152 dates.resize( t.size() );
153 values.resize( ft.size() );
154 std :: list< double > :: iterator it_t = t.begin(), it_ft = ft.begin();
155 for (
int i = 1; i <= ( int ) t.size(); ++i, ++it_t, ++it_ft ) {
156 dates.at(i) = * it_t;
172 Function :: giveInputRecord(input);
183 dates.storeYourself(stream);
184 values.storeYourself(stream);
193 dates.restoreYourself(stream);
194 values.restoreYourself(stream);
#define REGISTER_Function(class)
Function(int n, Domain *d)
#define OOFEM_WARNING(...)
#define PiecewiseLinFunction_PRECISION
#define _IFT_PiecewiseLinFunction_dataFile
#define _IFT_PiecewiseLinFunction_t
#define _IFT_PiecewiseLinFunction_ft
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