OOFEM 3.0
Loading...
Searching...
No Matches
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 - 2025 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
41namespace oofem {
43
44double PeriodicPiecewiseLinFunction :: evaluateAtTime(double time)
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
76double PeriodicPiecewiseLinFunction :: evaluateVelocityAtTime(double time)
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 ) {
92 add = domain->giveFunction(addTF)->evaluateVelocityAtTime(time);
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
104 return add + PiecewiseLinFunction :: evaluateVelocityAtTime(time);
105}
106
107void
108PeriodicPiecewiseLinFunction :: initializeFrom(InputRecord &ir)
109{
110 PiecewiseLinFunction :: initializeFrom(ir);
111 period = -1.0;
113 addTF = 0;
115}
116
117
118void PeriodicPiecewiseLinFunction :: giveInputRecord(DynamicInputRecord &input)
119{
120 PiecewiseLinFunction :: giveInputRecord(input);
123}
124} // end namespace oofem
#define REGISTER_Function(class)
void setField(int item, InputFieldType id)
Domain * domain
Link to domain object, useful for communicating with other FEM components.
Definition femcmpnn.h:79
int addTF
If nonzero, the value of time function specified by addTF is added to computed value.
#define OOFEM_ERROR(...)
Definition error.h:79
#define IR_GIVE_OPTIONAL_FIELD(__ir, __value, __id)
Definition inputrecord.h:75
#define _IFT_PeriodicPiecewiseLinFunction_period
#define _IFT_PeriodicPiecewiseLinFunction_addtf

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