OOFEM 3.0
Loading...
Searching...
No Matches
pulsefunction.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
35#include "pulsefunction.h"
36#include "mathfem.h"
37#include "timestep.h"
38#include "classfactory.h"
39
40namespace oofem {
42
43
44double
45PulseFunction :: evaluate(TimeStep *tStep, ValueModeType mode)
46{
47 if (this->mode == 0) {
48 return this->evaluateAtTime( this->time );
49 } else if (this->mode == 1) {
50 if (mode == VM_Total ) {
51 double ts = tStep->giveTargetTime()-tStep->giveTimeIncrement();
52 double te = tStep->giveTargetTime();
53 if ((this->time >= ts) && (this->time <= te)) {
54 return value;
55 } else {
56 return 0.;
57 }
58 } else {
59 OOFEM_ERROR("unsupported mode(%d)", mode);
60 }
61 }
62 return 0.0;
63}
64
65double
66PulseFunction :: evaluateAtTime(double time)
67// Returns the value of the receiver at time 'time'.
68{
69 if (this->mode == 0) {
70 if ( mode == VM_Total ) {
71 if ( (time >= tmin) && (time <= tmax) ) {
72 return value;
73 } else {
74 return 0.;
75 }
76 } else {
77 OOFEM_ERROR("unsupported mode(%d)", mode);
78 }
79 } else if (this->mode == 1) {
80 OOFEM_ERROR("unsupported mode(%d)", mode);
81 }
82 return 0.0;
83}
84
85void
86PulseFunction :: initializeFrom(InputRecord &ir)
87{
88 Function :: initializeFrom(ir);
89
91 mode = 1;
93 } else {
94 mode = 0;
97 }
98 this->value = 1.0;
100}
101
102} // end namespace oofem
#define REGISTER_Function(class)
virtual bool hasField(InputFieldType id)=0
Returns true if record contains field identified by idString keyword.
double value
Value of function within the interval.
double time
Specific time when function is nonzero.
int mode
mode of operation: 0 = interval [tmin,tmax], 1 = single time tstep
double tmax
End time of interval when function is nonzero.
double evaluateAtTime(double) override
double tmin
Start time of interval when function is nonzero.
double giveTimeIncrement()
Returns solution step associated time increment.
Definition timestep.h:168
double giveTargetTime()
Returns target time.
Definition timestep.h:164
#define OOFEM_ERROR(...)
Definition error.h:79
#define IR_GIVE_OPTIONAL_FIELD(__ir, __value, __id)
Definition inputrecord.h:75
#define IR_GIVE_FIELD(__ir, __value, __id)
Definition inputrecord.h:67
#define _IFT_PulseFunction_value
#define _IFT_PulseFunction_tmax
#define _IFT_PulseFunction_tsteptime
#define _IFT_PulseFunction_tmin

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