OOFEM  2.4
OOFEM.org - Object Oriented Finite Element Solver
dof.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 "dof.h"
36 #include "dofmanager.h"
37 #include "timestep.h"
38 #include "boundarycondition.h"
39 #include "initialcondition.h"
40 #include "datastream.h"
41 #include "contextioerr.h"
42 #include "unknownnumberingscheme.h"
43 
44 #include <cstring>
45 #include <cstdlib>
46 #include <cstdarg>
47 
48 namespace oofem {
49 
51 {
52  dofManager = aNode;
53  dofID = id;
54 }
55 
57 {
58  return s.giveDofEquationNumber(this);
59 }
60 
62 {
63  masterEqNumbers.resize(1);
64  masterEqNumbers.at(1) = s.giveDofEquationNumber(this);
65 }
66 
67 void Dof :: giveDofIDs(IntArray &masterDofIDs)
68 {
69  masterDofIDs = {this->giveDofID()};
70 }
71 
72 int Dof :: giveDofManNumber() const { return this->dofManager->giveNumber(); }
73 
75 
76 void Dof :: printSingleOutputAt(FILE *File, TimeStep *tStep, char ch, ValueModeType mode, double scale)
77 // Prints in the data file the unknown 'u' (for example, the displacement
78 // 'd') of the receiver, at tStep.
79 {
80  double x = scale * this->giveUnknown(mode, tStep);
81  fprintf(File, " dof %d %c % .8e\n", dofID, ch, x);
82 }
83 
84 void Dof :: printSingleOutputWithAdditionAt(FILE *File, TimeStep *tStep, char ch, ValueModeType mode, double addend)
85 // Prints in the data file the unknown 'u' (for example, the displacement
86 // 'd') of the receiver, at tStep.
87 {
88  double x = addend + this->giveUnknown(mode, tStep);
89  fprintf(File, " dof %d %c % .8e\n", dofID, ch, x);
90 }
91 
92 void Dof :: printMultipleOutputAt(FILE *File, TimeStep *tStep, char *ch,
93  ValueModeType *mode, int nite)
94 // Prints in the data file the unknown 'u' (for example, the displacement
95 // 'd') of the receiver, at tStep.
96 {
97  fprintf(File, " dof %d", dofID);
98  for ( int i = 1; i <= nite; i++ ) {
99  double x = this->giveUnknown(mode [ i - 1 ], tStep);
100  fprintf(File, " %c % .8e", ch [ i - 1 ], x);
101  }
102 
103  fprintf(File, "\n");
104 }
105 
106 
108 {
109  printf( "dof %d of %s %d :\n", dofID, dofManager->giveClassName(), dofManager->giveNumber() );
110 }
111 
112 
113 std :: string Dof :: errorInfo(const char *func) const
114 {
115  return std::string(this->giveClassName()) + "::" + func + " id " + std::to_string(dofID) + ", of DofManager " + std::to_string(dofManager->giveNumber());
116 }
117 
118 
119 double
121 {
122  if ( this->hasBc(tStep) ) {
123  double rel = 0.0;
124  if ( mode == VM_Incremental && tStep->isTheFirstStep() && hasIcOn(VM_Total) ) {
125  rel = giveIc()->give(VM_Total);
126  return this->giveBc()->give(this, VM_Total, tStep) - rel;
127  } else {
128  return this->giveBc()->give(this, mode, tStep) - rel;
129  }
130  } else {
131  return 0.0;
132  }
133 }
134 
136 Dof :: saveContext(DataStream &stream, ContextMode mode, void *obj)
137 {
138  int _val = dofID;
139  if ( !stream.write(_val) ) {
141  }
142 
143  return CIO_OK;
144 }
145 
146 
149 {
150  // restore dofid
151  int _val;
152  if ( !stream.read(_val) ) {
154  }
155 
156  dofID = ( DofIDItem ) _val;
157 
158  return CIO_OK;
159 }
160 
161 void
162 Dof :: giveUnknowns(FloatArray &masterUnknowns, ValueModeType mode, TimeStep *tStep)
163 {
164  masterUnknowns.resize(1);
165  masterUnknowns.at(1) = this->giveUnknown(mode, tStep);
166 }
167 
168 void
169 Dof :: giveUnknowns(FloatArray &masterUnknowns, PrimaryField &field, ValueModeType mode, TimeStep *tStep)
170 {
171  masterUnknowns.resize(1);
172  masterUnknowns.at(1) = this->giveUnknown(field, mode, tStep);
173 }
174 
175 void
177 {
178  masterContribs.resize(1);
179  masterContribs.at(1) = 1.0;
180 }
181 
182 void
184 {
185  answer.resize(1);
186  answer.at(1) = this->giveDofManNumber();
187 }
188 } // end namespace oofem
Dof(DofManager *aNode, DofIDItem id=Undef)
Constructor.
Definition: dof.C:50
int giveGlobalNumber() const
Definition: dofmanager.h:501
virtual double give(Dof *dof, ValueModeType mode, TimeStep *tStep)
Returns the value of a prescribed unknown, respecting requested mode for given time.
Abstract class representing field of primary variables (those, which are unknown and are typically as...
Definition: primaryfield.h:104
The purpose of DataStream abstract class is to allow to store/restore context to different streams...
Definition: datastream.h:54
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
virtual Dictionary * giveUnknowns()
Receives the dictionary of unknowns in receiver.
Definition: dof.h:401
virtual double giveUnknown(ValueModeType mode, TimeStep *tStep)=0
The key method of class Dof.
Base class for dof managers.
Definition: dofmanager.h:113
virtual InitialCondition * giveIc()
Returns initial condition of dof if it is prescribed.
Definition: dof.h:453
General IO error.
virtual void printYourself()
Prints the receiver state on stdout.
Definition: dof.C:107
virtual void printMultipleOutputAt(FILE *File, TimeStep *tStep, char *ch, ValueModeType *mode, int nite)
Prints Dof output (it prints value of unknown related to dof at given timeStep).
Definition: dof.C:92
virtual void giveEquationNumbers(IntArray &masterEqNumbers, const UnknownNumberingScheme &s)
Returns equation number of receiver.
Definition: dof.C:61
Class implementing an array of integers.
Definition: intarray.h:61
int & at(int i)
Coefficient access function.
Definition: intarray.h:103
virtual int read(int *data, int count)=0
Reads count integer values into array pointed by data.
#define THROW_CIOERR(e)
Definition: contextioerr.h:61
virtual int giveDofEquationNumber(Dof *dof) const =0
Returns the equation number for corresponding DOF.
virtual BoundaryCondition * giveBc()
Returns boundary condition of dof if it is prescribed.
Definition: dof.h:448
bool isTheFirstStep()
Check if receiver is first step.
Definition: timestep.C:134
virtual int write(const int *data, int count)=0
Writes count integer values from array pointed by data.
DofIDItem
Type representing particular dof type.
Definition: dofiditem.h:86
DofManager * dofManager
Link to related DofManager.
Definition: dof.h:97
Abstract base class allowing to control the way, how equations are assigned to individual DOFs...
DofIDItem giveDofID() const
Returns DofID value of receiver, which determines type of of unknown connected to receiver (e...
Definition: dof.h:276
virtual void giveMasterDofManArray(IntArray &answer)
Definition: dof.C:183
std::string errorInfo(const char *func) const
Returns string for prepending output (used by error reporting macros).
Definition: dof.C:113
virtual bool hasIcOn(ValueModeType u)=0
Test if Dof has initial condition of required ValueModeType.
void resize(int n)
Checks size of receiver towards requested bounds.
Definition: intarray.C:124
double give(ValueModeType mode)
Returns value of initial condition for given unknown mode (determines whether total or velocity or ac...
int giveDofManNumber() const
Definition: dof.C:72
int giveDofManGlobalNumber() const
Definition: dof.C:74
Class representing vector of real numbers.
Definition: floatarray.h:82
virtual contextIOResultType saveContext(DataStream &stream, ContextMode mode, void *obj=NULL)
Stores receiver state to output stream.
Definition: dof.C:136
virtual const char * giveClassName() const =0
DofIDItem dofID
Physical meaning of DOF.
Definition: dof.h:99
virtual contextIOResultType restoreContext(DataStream &stream, ContextMode mode, void *obj=NULL)
Restores the receiver state previously written in stream.
Definition: dof.C:148
virtual double giveBcValue(ValueModeType mode, TimeStep *tStep)
Returns value of boundary condition of dof if it is prescribed.
Definition: dof.C:120
virtual void computeDofTransformation(FloatArray &masterContribs)
Computes dof transformation array, which describes the dependence of receiver value on values of mast...
Definition: dof.C:176
long ContextMode
Context mode (mask), defining the type of information written/read to/from context.
Definition: contextmode.h:43
virtual bool hasBc(TimeStep *tStep)=0
Test if Dof has active boundary condition.
int giveEquationNumber(const UnknownNumberingScheme &s)
Returns equation number of receiver for given equation numbering scheme.
Definition: dof.C:56
virtual const char * giveClassName() const
Returns class name of the receiver.
Definition: dof.h:117
the oofem namespace is to define a context or scope in which all oofem names are defined.
int giveNumber() const
Definition: femcmpnn.h:107
virtual void giveDofIDs(IntArray &masterDofIDs)
As giveEquationNumbers but for dof IDs.
Definition: dof.C:67
Class representing solution step.
Definition: timestep.h:80
virtual void printSingleOutputAt(FILE *file, TimeStep *tStep, char ch, ValueModeType mode, double scale=1.0)
Prints Dof output (it prints value of unknown related to dof at given timeStep).
Definition: dof.C:76
void resize(int s)
Resizes receiver towards requested size.
Definition: floatarray.C:631
void printSingleOutputWithAdditionAt(FILE *File, TimeStep *tStep, char ch, ValueModeType mode, double addend)
Definition: dof.C:84

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