OOFEM  2.4
OOFEM.org - Object Oriented Finite Element Solver
periodicpiecewiselinfunction.C
Go to the documentation of this file.
1 /*
2  *
3  * ##### ##### ###### ###### ### ###
4  * ## ## ## ## ## ## ## ### ##
5  * ## ## ## ## #### #### ## # ##
6  * ## ## ## ## ## ## ## ##
7  * ## ## ## ## ## ## ## ##
8  * ##### ##### ## ###### ## ##
9  *
10  *
11  * OOFEM : Object Oriented Finite Element Code
12  *
13  * Copyright (C) 1993 - 2013 Borek Patzak
14  *
15  *
16  *
17  * Czech Technical University, Faculty of Civil Engineering,
18  * Department of Structural Mechanics, 166 29 Prague, Czech Republic
19  *
20  * This library is free software; you can redistribute it and/or
21  * modify it under the terms of the GNU Lesser General Public
22  * License as published by the Free Software Foundation; either
23  * version 2.1 of the License, or (at your option) any later version.
24  *
25  * This program is distributed in the hope that it will be useful,
26  * but WITHOUT ANY WARRANTY; without even the implied warranty of
27  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
28  * Lesser General Public License for more details.
29  *
30  * You should have received a copy of the GNU Lesser General Public
31  * License along with this library; if not, write to the Free Software
32  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
33  */
34 
36 #include "mathfem.h"
37 #include "classfactory.h"
38 #include "dynamicinputrecord.h"
39 #include "domain.h"
40 
41 namespace oofem {
42 REGISTER_Function(PeriodicPiecewiseLinFunction);
43 
45 // Returns the value of the receiver at time 'time'. 'time' should be
46 // one of the dates of the receiver (currently there is no interpola-
47 // tion between two points).
48 {
49  double add, last;
50 
51  if ( !this->dates.giveSize() ) {
52  OOFEM_ERROR("Undefined dates and values!");
53  }
54 
55  if ( addTF && !domain->giveFunction(addTF) ) {
56  OOFEM_ERROR("Undefined time function to add!");
57  }
58 
59  if ( addTF ) {
60  add = domain->giveFunction(addTF)->evaluateAtTime(time);
61  } else {
62  add = 0.;
63  }
64 
65  // periodicity
66  last = dates.at( this->dates.giveSize() ); // time of last date
67  if ( ( period >= 0.0 ) && ( time > last ) ) {
68  double d = ( time - last ) / period; // periods after last
69  time = last + ( d - floor(d) - 1. ) * period;
70  }
71 
72  return add + PiecewiseLinFunction :: evaluateAtTime(time);
73 }
74 
75 
77 // Returns the value of the receiver at time 'time'. 'time' should be
78 // one of the dates of the receiver (currently there is no interpola-
79 // tion between two points).
80 {
81  double add, last;
82 
83  if ( !this->dates.giveSize() ) {
84  OOFEM_ERROR("Undefined dates and values!");
85  }
86 
87  if ( addTF && !domain->giveFunction(addTF) ) {
88  OOFEM_ERROR("Undefined time function to add!");
89  }
90 
91  if ( addTF ) {
93  } else {
94  add = 0.;
95  }
96 
97  // periodicity
98  last = dates.at( this->dates.giveSize() ); // time of last date
99  if ( ( period >= 0.0 ) && ( time > last ) ) {
100  double d = ( time - last ) / period; // periods after last
101  time = last + ( d - floor(d) - 1. ) * period;
102  }
103 
105 }
106 
109 {
110  IRResultType result; // Required by IR_GIVE_FIELD macro
111 
112  period = -1.0;
114  addTF = 0;
116 
118 }
119 
120 
122 {
126 }
127 } // end namespace oofem
void setField(int item, InputFieldType id)
double period
If less than zero no periodicity, if >=0 date time is computed as given timeperiod.
Domain * domain
Link to domain object, useful for communicating with other FEM components.
Definition: femcmpnn.h:82
virtual IRResultType initializeFrom(InputRecord *ir)
Initializes receiver according to object description stored in input record.
virtual double evaluateVelocityAtTime(double)
Returns the first time derivative of the function at given time.
double & at(int i)
Coefficient access function.
Definition: floatarray.h:131
virtual void giveInputRecord(DynamicInputRecord &input)
Setups the input record string of receiver.
REGISTER_Function(CalculatorFunction)
#define _IFT_PeriodicPiecewiseLinFunction_addtf
int addTF
If nonzero, the value of time function specified by addTF is added to computed value.
#define OOFEM_ERROR(...)
Definition: error.h:61
virtual double evaluateAtTime(double)
Returns the value of the function at given time.
#define _IFT_PeriodicPiecewiseLinFunction_period
Function * giveFunction(int n)
Service for accessing particular domain load time function.
Definition: domain.C:268
virtual double evaluateVelocityAtTime(double t)=0
Returns the first time derivative of the function at given time.
virtual double evaluateVelocityAtTime(double t)
Returns the first time derivative of the function at given time.
IRResultType
Type defining the return values of InputRecord reading operations.
Definition: irresulttype.h:47
virtual IRResultType initializeFrom(InputRecord *ir)
Initializes receiver according to object description stored in input record.
Class representing the general Input Record.
Definition: inputrecord.h:101
Class representing the a dynamic Input Record.
#define IR_GIVE_OPTIONAL_FIELD(__ir, __value, __id)
Macro facilitating the use of input record reading methods.
Definition: inputrecord.h:78
int giveSize() const
Returns the size of receiver.
Definition: floatarray.h:218
virtual double evaluateAtTime(double t)
Returns the value of the function at given time.
the oofem namespace is to define a context or scope in which all oofem names are defined.
virtual void giveInputRecord(DynamicInputRecord &input)
Setups the input record string of receiver.
virtual double evaluateAtTime(double t)
Returns the value of the function at given time.
Definition: function.C:76

This page is part of the OOFEM documentation. Copyright (c) 2011 Borek Patzak
Project e-mail: info@oofem.org
Generated at Tue Jan 2 2018 20:07:30 for OOFEM by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2011