OOFEM  2.4
OOFEM.org - Object Oriented Finite Element Solver
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 - 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 
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 
45 namespace oofem {
46 REGISTER_BoundaryCondition(BoundaryCondition);
47 
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 
58 double 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 
81 {
82  IRResultType result; // Required by IR_GIVE_FIELD macro
83 
85  if ( result != IRRT_OK ) {
86  return result;
87  }
88 
91  } else {
92  double prescribedValue;
95  } else {
97  }
98  // Backwards compatibility with old input method:
99  if ( this->dofs.giveSize() ) {
100  values.resize( this->dofs.giveSize() );
101  } else {
102  values.resize(1);
103  }
104  values.zero();
105  values.add(prescribedValue);
106  }
107 
108  return IRRT_OK;
109 }
110 
111 
112 void
114 {
117 }
118 
119 
120 void
122 {
123  values.zero();
124  values.add(s);
125 }
126 
127 
128 void
130 {
131  values.times(s);
132 }
133 
134 
137 {
138  contextIOResultType iores;
139  if ( ( iores = GeneralBoundaryCondition :: saveContext(stream, mode, obj) ) != CIO_OK ) {
140  THROW_CIOERR(iores);
141  }
142 
143  if ( mode & CM_Definition ) {
144  if ( (iores = values.storeYourself(stream) ) != CIO_OK ) {
146  }
147  }
148 
149  return CIO_OK;
150 }
151 
152 
155 {
156  contextIOResultType iores;
157  if ( ( iores = GeneralBoundaryCondition :: restoreContext(stream, mode, obj) ) != CIO_OK ) {
158  THROW_CIOERR(iores);
159  }
160 
161  if ( mode & CM_Definition ) {
162  if ( (iores = values.restoreYourself(stream) ) != CIO_OK ) {
164  }
165  }
166 
167  return CIO_OK;
168 }
169 } // end namespace oofem
virtual contextIOResultType restoreContext(DataStream &stream, ContextMode mode, void *obj=NULL)
Restores the receiver state previously written in stream.
void setField(int item, InputFieldType id)
REGISTER_BoundaryCondition(BoundaryCondition)
virtual double evaluateAccelerationAtTime(double t)=0
Returns the second time derivative of the function at given time.
virtual double give(Dof *dof, ValueModeType mode, TimeStep *tStep)
Returns the value of a prescribed unknown, respecting requested mode for given time.
The purpose of DataStream abstract class is to allow to store/restore context to different streams...
Definition: datastream.h:54
contextIOResultType storeYourself(DataStream &stream) const
Definition: floatarray.C:872
double & at(int i)
Coefficient access function.
Definition: floatarray.h:131
ValueModeType
Type representing the mode of UnknownType or CharType, or similar types.
Definition: valuemodetype.h:78
void setPrescribedValue(double s)
Set prescribed value at the input record string of receiver.
virtual void giveInputRecord(DynamicInputRecord &input)
Setups the input record string of receiver.
virtual bool hasField(InputFieldType id)=0
Returns true if record contains field identified by idString keyword.
double giveTargetTime()
Returns target time.
Definition: timestep.h:146
General IO error.
virtual void scale(double s)
Scales the receiver according to given value.
#define _IFT_BoundaryCondition_values
[ra,optional] Vector of prescribed values for each respective DOF.
virtual contextIOResultType restoreContext(DataStream &stream, ContextMode mode, void *obj=NULL)
Restores the receiver state previously written in stream.
#define THROW_CIOERR(e)
Definition: contextioerr.h:61
double giveTimeIncrement()
Returns solution step associated time increment.
Definition: timestep.h:150
virtual IRResultType initializeFrom(InputRecord *ir)
Initializes receiver according to object description stored in input record.
#define _IFT_BoundaryCondition_PrescribedValue_d
[rn,optional] Alternative input field
#define OOFEM_ERROR(...)
Definition: error.h:61
contextIOResultType restoreYourself(DataStream &stream)
Definition: floatarray.C:895
DofIDItem giveDofID() const
Returns DofID value of receiver, which determines type of of unknown connected to receiver (e...
Definition: dof.h:276
IntArray dofs
Dofs that b.c. is applied to (relevant for Dirichlet type b.c.s).
double giveIntrinsicTime()
Returns intrinsic time, e.g. time in which constitutive model is evaluated.
Definition: timestep.h:148
virtual double evaluateVelocityAtTime(double t)=0
Returns the first time derivative of the function at given time.
Initializes the variable VERBOSE, in order to get a few intermediate messages on screen: beginning an...
IRResultType
Type defining the return values of InputRecord reading operations.
Definition: irresulttype.h:47
Class representing the general Input Record.
Definition: inputrecord.h:101
void zero()
Zeroes all coefficients of receiver.
Definition: floatarray.C:658
Class representing the a dynamic Input Record.
void times(double s)
Multiplies receiver with scalar.
Definition: floatarray.C:818
long ContextMode
Context mode (mask), defining the type of information written/read to/from context.
Definition: contextmode.h:43
#define CM_Definition
Definition: contextmode.h:47
#define _IFT_BoundaryCondition_PrescribedValue
[rn,optional] Prescribed value of all DOFs
virtual void giveInputRecord(DynamicInputRecord &input)
Setups the input record string of receiver.
int giveSize() const
Definition: intarray.h:203
FloatArray values
Prescribed values for each resp. dof.
virtual contextIOResultType saveContext(DataStream &stream, ContextMode mode, void *obj=NULL)
Stores receiver state to output stream.
the oofem namespace is to define a context or scope in which all oofem names are defined.
#define IR_GIVE_FIELD(__ir, __value, __id)
Macro facilitating the use of input record reading methods.
Definition: inputrecord.h:69
Abstract class Dof represents Degree Of Freedom in finite element mesh.
Definition: dof.h:93
virtual IRResultType initializeFrom(InputRecord *ir)
Initializes receiver according to object description stored in input record.
virtual double evaluateAtTime(double t)
Returns the value of the function at given time.
Definition: function.C:76
Class representing solution step.
Definition: timestep.h:80
void add(const FloatArray &src)
Adds array src to receiver.
Definition: floatarray.C:156
int findFirstIndexOf(int value) const
Finds index of first occurrence of given value in array.
Definition: intarray.C:331
virtual contextIOResultType saveContext(DataStream &stream, ContextMode mode, void *obj=NULL)
Stores receiver state to output stream.
void resize(int s)
Resizes receiver towards requested size.
Definition: floatarray.C:631

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:27 for OOFEM by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2011