OOFEM 3.0
Loading...
Searching...
No Matches
boundarycondition.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 "boundarycondition.h"
36#include "timestep.h"
37#include "function.h"
38#include "verbose.h"
39#include "dynamicinputrecord.h"
40#include "dof.h"
41#include "classfactory.h"
42#include "contextioerr.h"
43#include "error.h"
44
45namespace oofem {
47
48double BoundaryCondition :: give(Dof *dof, ValueModeType mode, TimeStep *tStep)
49{
50 if ( mode == VM_Incremental ) {
51 return this->give(dof, VM_Total, tStep->giveTargetTime()) - this->give(dof, VM_Total, tStep->giveTargetTime() - tStep->giveTimeIncrement());
52 } else {
53 return this->give(dof, mode, tStep->giveIntrinsicTime());
54 }
55}
56
57
58double BoundaryCondition :: give(Dof *dof, ValueModeType mode, double time)
59{
60 double factor = 0;
61 if ( (mode == VM_Total) || (mode == VM_TotalIntrinsic)) {
62 factor = this->giveTimeFunction()->evaluateAtTime(time);
63 } else if ( mode == VM_Velocity ) {
64 factor = this->giveTimeFunction()->evaluateVelocityAtTime(time);
65 } else if ( mode == VM_Acceleration ) {
66 factor = this->giveTimeFunction()->evaluateAccelerationAtTime(time);
67 } else {
68 OOFEM_ERROR("Should not be called for value mode type then total, velocity, or acceleration.");
69 }
70 int index = this->dofs.findFirstIndexOf( dof->giveDofID() );
71 if ( !index ) {
72 index = 1;
73 }
74 double prescribedValue = this->values.at(index);
75 return prescribedValue * factor;
76}
77
78
79void
80BoundaryCondition :: initializeFrom(InputRecord &ir)
81{
82 GeneralBoundaryCondition :: initializeFrom(ir);
83
86 } else {
87 double prescribedValue;
90 } else {
92 }
93 // Backwards compatibility with old input method:
94 if ( this->dofs.giveSize() ) {
95 values.resize( this->dofs.giveSize() );
96 } else {
97 values.resize(1);
98 }
99 values.zero();
100 values.add(prescribedValue);
101 }
102}
103
104
105void
106BoundaryCondition :: giveInputRecord(DynamicInputRecord &input)
107{
108 GeneralBoundaryCondition :: giveInputRecord(input);
110}
111
112
113void
114BoundaryCondition :: setPrescribedValue(double s)
115{
116 values.zero();
117 values.add(s);
118}
119
120
121void
122BoundaryCondition :: scale(double s)
123{
124 values.times(s);
125}
126
127
128void
129BoundaryCondition :: saveContext(DataStream &stream, ContextMode mode)
130{
131 GeneralBoundaryCondition :: saveContext(stream, mode);
132
133 if ( mode & CM_Definition ) {
135 if ( (iores = values.storeYourself(stream) ) != CIO_OK ) {
137 }
138 }
139}
140
141
142void
143BoundaryCondition :: restoreContext(DataStream &stream, ContextMode mode)
144{
145 GeneralBoundaryCondition :: restoreContext(stream, mode);
146
147 if ( mode & CM_Definition ) {
149 if ( (iores = values.restoreYourself(stream) ) != CIO_OK ) {
151 }
152 }
153}
154} // end namespace oofem
#define _IFT_BoundaryCondition_PrescribedValue
[rn,optional] Prescribed value of all DOFs
#define _IFT_BoundaryCondition_values
[ra,optional] Vector of prescribed values for each respective DOF.
#define _IFT_BoundaryCondition_PrescribedValue_d
[rn,optional] Alternative input field
#define REGISTER_BoundaryCondition(class)
FloatArray values
Prescribed values for each resp. dof.
virtual double give(Dof *dof, ValueModeType mode, TimeStep *tStep)
DofIDItem giveDofID() const
Definition dof.h:276
void setField(int item, InputFieldType id)
IntArray dofs
Dofs that b.c. is applied to (relevant for Dirichlet type b.c.s).
virtual bool hasField(InputFieldType id)=0
Returns true if record contains field identified by idString keyword.
double giveTimeIncrement()
Returns solution step associated time increment.
Definition timestep.h:168
double giveTargetTime()
Returns target time.
Definition timestep.h:164
double giveIntrinsicTime()
Returns intrinsic time, e.g. time in which constitutive model is evaluated.
Definition timestep.h:166
#define THROW_CIOERR(e)
#define CM_Definition
Definition contextmode.h:47
#define OOFEM_ERROR(...)
Definition error.h:79
#define IR_GIVE_FIELD(__ir, __value, __id)
Definition inputrecord.h:67
long ContextMode
Definition contextmode.h:43
@ CIO_IOERR
General IO error.

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