OOFEM 3.0
Loading...
Searching...
No Matches
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 - 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 "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"
43
44#include <cstring>
45#include <cstdlib>
46#include <cstdarg>
47
48namespace oofem {
49
50Dof :: Dof(DofManager *aNode, DofIDItem id)
51{
52 dofManager = aNode;
53 dofID = id;
54}
55
56int Dof :: giveEquationNumber(const UnknownNumberingScheme &s)
57{
58 return s.giveDofEquationNumber(this);
59}
60
61void Dof :: giveEquationNumbers(IntArray &masterEqNumbers, const UnknownNumberingScheme &s)
62{
63 masterEqNumbers.resize(1);
64 masterEqNumbers.at(1) = s.giveDofEquationNumber(this);
65}
66
67void Dof :: giveDofIDs(IntArray &masterDofIDs)
68{
69 masterDofIDs = {this->giveDofID()};
70}
71
72int Dof :: giveDofManNumber() const { return this->dofManager->giveNumber(); }
73
74int Dof :: giveDofManGlobalNumber() const { return this->dofManager->giveGlobalNumber(); }
75
76void 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 %-3d %c % .8e\n", dofID, ch, x);
82}
83
84void 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 %-3d %c % .8e\n", dofID, ch, x);
90}
91
92void 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
107void Dof :: printYourself()
108{
109 printf( "dof %d of %s %d :\n", dofID, dofManager->giveClassName(), dofManager->giveNumber() );
110}
111
112
113std :: 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
119double
120Dof :: giveBcValue(ValueModeType mode, TimeStep *tStep)
121{
122 if ( this->hasBc(tStep) ) {
123 double rel = 0.0;
124 if ( mode == VM_Incremental && tStep->isTheFirstStep() && hasIcOn(VM_Total) ) {
125 FloatArray c = this->giveDofManager()->giveCoordinates();
126 rel = giveIc()->give(VM_Total, c);
127 return this->giveBc()->give(this, VM_Total, tStep) - rel;
128 } else {
129 return this->giveBc()->give(this, mode, tStep) - rel;
130 }
131 } else {
132 return 0.0;
133 }
134}
135
136void
137Dof :: saveContext(DataStream &stream, ContextMode mode)
138{
139 int _val = dofID;
140 if ( !stream.write(_val) ) {
142 }
143}
144
145
146void
147Dof :: restoreContext(DataStream &stream, ContextMode mode)
148{
149 // restore dofid
150 int _val;
151 if ( !stream.read(_val) ) {
153 }
154
155 dofID = ( DofIDItem ) _val;
156}
157
158void
159Dof :: giveUnknowns(FloatArray &masterUnknowns, ValueModeType mode, TimeStep *tStep)
160{
161 masterUnknowns.resize(1);
162 masterUnknowns.at(1) = this->giveUnknown(mode, tStep);
163}
164
165void
166Dof :: giveUnknowns(FloatArray &masterUnknowns, PrimaryField &field, ValueModeType mode, TimeStep *tStep)
167{
168 masterUnknowns.resize(1);
169 masterUnknowns.at(1) = this->giveUnknown(field, mode, tStep);
170}
171
172void
173Dof :: computeDofTransformation(FloatArray &masterContribs)
174{
175 masterContribs.resize(1);
176 masterContribs.at(1) = 1.0;
177}
178
179void
180Dof :: giveMasterDofManArray(IntArray &answer)
181{
182 answer.resize(1);
183 answer.at(1) = this->giveDofManNumber();
184}
185} // end namespace oofem
virtual int read(int *data, std::size_t count)=0
Reads count integer values into array pointed by data.
virtual int write(const int *data, std::size_t count)=0
Writes count integer values from array pointed by data.
DofIDItem dofID
Physical meaning of DOF.
Definition dof.h:99
DofIDItem giveDofID() const
Definition dof.h:276
virtual double giveUnknown(ValueModeType mode, TimeStep *tStep)=0
DofManager * dofManager
Link to related DofManager.
Definition dof.h:97
DofManager * giveDofManager() const
Definition dof.h:123
virtual bool hasIcOn(ValueModeType u)=0
virtual bool hasBc(TimeStep *tStep)=0
virtual BoundaryCondition * giveBc()
Definition dof.h:448
virtual const char * giveClassName() const
Returns class name of the receiver.
Definition dof.h:117
virtual InitialCondition * giveIc()
Definition dof.h:453
int giveDofManNumber() const
Definition dof.C:72
void resize(Index s)
Definition floatarray.C:94
double & at(Index i)
Definition floatarray.h:202
void resize(int n)
Definition intarray.C:73
int & at(std::size_t i)
Definition intarray.h:104
bool isTheFirstStep()
Definition timestep.C:148
virtual int giveDofEquationNumber(Dof *dof) const =0
#define THROW_CIOERR(e)
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