OOFEM 3.0
Loading...
Searching...
No Matches
slavedof.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 "slavedof.h"
36#include "domain.h"
37#include "dofmanager.h"
38#include "error.h"
39#include "datastream.h"
41#include "contextioerr.h"
42
43namespace oofem {
44SlaveDof :: SlaveDof(DofManager *aNode, DofIDItem id) : Dof(aNode, id), masterContribution()
45{
48}
49
50
51void
52SlaveDof :: initialize(const IntArray &masterNodes, const IntArray &mstrDofID, const FloatArray &mstrContribution)
53{
54 int id;
55 bool idSame = false;
56
57
58 if ( mstrDofID.isEmpty() ) {
59 idSame = true;
60 } else if ( mstrDofID.giveSize() != mstrContribution.giveSize() ) {
61 OOFEM_ERROR("mstrDofID.giveSize %d != mstrContribution.giveSize %d", (int)mstrDofID.giveSize(), (int)mstrContribution.giveSize());
62 }
63
64
65 countOfMasterDofs = mstrContribution.giveSize();
66 masterContribution = mstrContribution;
67
70
71 for ( int i = 1; i <= countOfMasterDofs; i++ ) {
72 if ( idSame ) {
73 id = this->dofID;
74 } else {
75 id = mstrDofID.at(i);
76 }
77
78 masterDofMans.at(i) = masterNodes.at(i);
79 dofIDs.at(i) = id;
80 }
81}
82
83int
84SlaveDof :: giveNumberOfPrimaryMasterDofs()
85{
86 if ( countOfPrimaryMasterDofs > 0 ) {
88 } else
89 //if ( countOfPrimaryMasterDofs == 0 ) {
90 //OOFEM_ERROR("slaveDof is own master");
91 //}
92
94
95 int c = 0;
96 for ( int i = 1; i <= countOfMasterDofs; i++ ) {
97 c += this->giveMasterDof(i)->giveNumberOfPrimaryMasterDofs();
98 }
99 if ( c == 0 ) {
100 OOFEM_ERROR("slaveDof is own master");
101 }
102
103 return countOfPrimaryMasterDofs = c;
104}
105
106void
107SlaveDof :: giveUnknowns(FloatArray &masterUnknowns, ValueModeType mode, TimeStep *tStep)
108{
109 FloatArray mstrUnknwns;
110
111 masterUnknowns.resize( this->giveNumberOfPrimaryMasterDofs() );
112
113 for ( int k = 1, i = 1; i <= countOfMasterDofs; i++ ) {
114 this->giveMasterDof(i)->giveUnknowns(mstrUnknwns, mode, tStep);
115 masterUnknowns.copySubVector(mstrUnknwns, k);
116 k += mstrUnknwns.giveSize();
117 }
118}
119
120void
121SlaveDof :: giveUnknowns(FloatArray &masterUnknowns, PrimaryField &field, ValueModeType mode, TimeStep *tStep)
122{
123 FloatArray mstrUnknwns;
124
125 masterUnknowns.resize( this->giveNumberOfPrimaryMasterDofs() );
126
127 for ( int k = 1, i = 1; i <= countOfMasterDofs; i++ ) {
128 this->giveMasterDof(i)->giveUnknowns(mstrUnknwns, field, mode, tStep);
129 masterUnknowns.copySubVector(mstrUnknwns, k);
130 k += mstrUnknwns.giveSize();
131 }
132}
133
134void
135SlaveDof :: computeDofTransformation(FloatArray &primaryMasterContribs)
136{
137 FloatArray subPrimaryMasterContribs;
138
139 primaryMasterContribs.resize( this->giveNumberOfPrimaryMasterDofs() );
140
141 for ( int k = 1, i = 1; i <= countOfMasterDofs; i++ ) {
142 this->giveMasterDof(i)->computeDofTransformation(subPrimaryMasterContribs);
143 subPrimaryMasterContribs.times( masterContribution.at(i) );
144 primaryMasterContribs.copySubVector(subPrimaryMasterContribs, k);
145 k += subPrimaryMasterContribs.giveSize();
146 }
147}
148
149void
150SlaveDof :: giveEquationNumbers(IntArray &masterEqNumbers, const UnknownNumberingScheme &s)
151{
152 IntArray mstrEqNmbrs;
153
154 int masterDofs = this->giveNumberOfPrimaryMasterDofs();
155 masterEqNumbers.preallocate(masterDofs);
156 masterEqNumbers.clear();
157
158 for ( int i = 1; i <= countOfMasterDofs; i++ ) {
159 this->giveMasterDof(i)->giveEquationNumbers(mstrEqNmbrs, s);
160 masterEqNumbers.followedBy(mstrEqNmbrs);
161 }
162}
163
164
165void
166SlaveDof :: giveDofIDs(IntArray &masterDofIDs)
167{
168 IntArray temp;
169
170 int masterDofs = this->giveNumberOfPrimaryMasterDofs();
171 masterDofIDs.preallocate(masterDofs);
172 masterDofIDs.clear();
173
174 for ( int i = 1; i <= countOfMasterDofs; i++ ) {
175 this->giveMasterDof(i)->giveDofIDs(temp);
176 masterDofIDs.followedBy(temp);
177 }
178}
179
180
181double SlaveDof :: giveUnknown(ValueModeType mode, TimeStep *tStep)
182{
183 FloatArray masterUnknowns, t;
184
185 this->giveUnknowns(masterUnknowns, mode, tStep);
187
188 return masterUnknowns.dotProduct(t);
189}
190
191double SlaveDof :: giveUnknown(PrimaryField &field, ValueModeType mode, TimeStep *tStep)
192{
193 FloatArray masterUnknowns, t;
194
195 giveUnknowns(masterUnknowns, field, mode, tStep);
197
198 return masterUnknowns.dotProduct(t);
199}
200
201
202int SlaveDof :: __giveEquationNumber() const
203{
204 OOFEM_ERROR("undefined");
205}
206
207
208int SlaveDof :: __givePrescribedEquationNumber()
209{
210 OOFEM_ERROR("undefined");
211}
212
213void SlaveDof :: saveContext(DataStream &stream, ContextMode mode)
214{
215 Dof :: saveContext(stream, mode);
216
217 if ( mode & CM_Definition ) {
219 if ( !stream.write(countOfMasterDofs) ) {
221 }
222
223 if ( !stream.write(countOfPrimaryMasterDofs) ) {
225 }
226
227 if ( ( iores = masterContribution.storeYourself(stream) ) != CIO_OK ) {
228 THROW_CIOERR(iores);
229 }
230
231 for ( int _idof = 1; _idof <= countOfMasterDofs; _idof++ ) {
232 int _idofmanNum;
233 if ( mode & CM_DefinitionGlobal ) {
234 _idofmanNum = dofManager->giveDomain()->giveDofManager( masterDofMans.at(_idof) )->giveGlobalNumber();
235 } else {
236 _idofmanNum = masterDofMans.at(_idof);
237 }
238
239 if ( !stream.write(_idofmanNum) ) {
241 }
242 }
243
244 if ( ( iores = dofIDs.storeYourself(stream) ) != CIO_OK ) {
245 THROW_CIOERR(iores);
246 }
247 } // if ( mode & CM_Definition )
248}
249
250void SlaveDof :: restoreContext(DataStream &stream, ContextMode mode)
251{
252 Dof :: restoreContext(stream, mode);
253
254 if ( mode & CM_Definition ) {
256 if ( !stream.read(countOfMasterDofs) ) {
258 }
259
260 if ( !stream.read(countOfPrimaryMasterDofs) ) {
262 }
263
264 if ( ( iores = masterContribution.restoreYourself(stream) ) != CIO_OK ) {
265 THROW_CIOERR(iores);
266 }
267
268 int _idof;
269
271 for ( _idof = 1; _idof <= countOfMasterDofs; _idof++ ) {
272 if ( !stream.read(masterDofMans.at(_idof)) ) {
274 }
275 }
276
277 if ( ( iores = dofIDs.restoreYourself(stream) ) != CIO_OK ) {
278 THROW_CIOERR(iores);
279 }
280 } // if ( mode & CM_Definition )
281}
282
283
284inline Dof *
285SlaveDof :: giveMasterDof(int i)
286{
287 return dofManager->giveDomain()->giveDofManager( masterDofMans.at(i) )->giveDofWithID( dofIDs.at(i) );
288}
289
290
291void
292SlaveDof :: updateLocalNumbering(EntityRenumberingFunctor &f)
293{
294 for ( int i = 1; i <= countOfMasterDofs; i++ ) {
296 }
297}
298
299
300void
301SlaveDof :: giveMasterDofManArray(IntArray &answer)
302{
303 IntArray mstrDofManArry;
304
305 int masterDofs = this->giveNumberOfPrimaryMasterDofs();
306 answer.preallocate(masterDofs);
307 answer.clear();
308
309 for ( int i = 1; i <= countOfMasterDofs; i++ ) {
310 this->giveMasterDof(i)->giveMasterDofManArray(mstrDofManArry);
311 answer.followedBy(mstrDofManArry);
312 }
313}
314} // 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
Dof(DofManager *aNode, DofIDItem id=Undef)
Definition dof.C:50
DofManager * dofManager
Link to related DofManager.
Definition dof.h:97
void resize(Index s)
Definition floatarray.C:94
double dotProduct(const FloatArray &x) const
Definition floatarray.C:524
Index giveSize() const
Returns the size of receiver.
Definition floatarray.h:261
void copySubVector(const FloatArray &src, int si)
Definition floatarray.C:886
void times(double s)
Definition floatarray.C:834
void followedBy(const IntArray &b, int allocChunk=0)
Definition intarray.C:94
bool isEmpty() const
Definition intarray.h:217
void preallocate(int futureSize)
Definition intarray.C:79
int & at(std::size_t i)
Definition intarray.h:104
int giveSize() const
Definition intarray.h:211
IntArray dofIDs
Array of master dofIDs.
Definition slavedof.h:57
Dof * giveMasterDof(int i)
Definition slavedof.C:285
int countOfPrimaryMasterDofs
Count of master DofManagers.
Definition slavedof.h:53
void computeDofTransformation(FloatArray &primaryMasterContribs) override
Definition slavedof.C:135
int countOfMasterDofs
Count of master DofManagers.
Definition slavedof.h:51
IntArray masterDofMans
Array of master DofManagers.
Definition slavedof.h:55
void giveUnknowns(FloatArray &masterUnknowns, ValueModeType mode, TimeStep *tStep) override
Definition slavedof.C:107
int giveNumberOfPrimaryMasterDofs() override
Definition slavedof.C:84
FloatArray masterContribution
Vector of master contribution coefficients.
Definition slavedof.h:59
#define THROW_CIOERR(e)
#define CM_DefinitionGlobal
Definition contextmode.h:48
#define CM_Definition
Definition contextmode.h:47
#define OOFEM_ERROR(...)
Definition error.h:79
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