OOFEM  2.4
OOFEM.org - Object Oriented Finite Element Solver
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 - 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 "slavedof.h"
36 #include "domain.h"
37 #include "dofmanager.h"
38 #include "error.h"
39 #include "datastream.h"
41 #include "contextioerr.h"
42 
43 namespace oofem {
44 SlaveDof :: SlaveDof(DofManager *aNode, DofIDItem id) : Dof(aNode, id), masterContribution()
45 {
47  countOfMasterDofs = -1;
48 }
49 
50 
51 void
52 SlaveDof :: 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", mstrDofID.giveSize(), mstrContribution.giveSize());
62  }
63 
64 
65  countOfMasterDofs = mstrContribution.giveSize();
66  masterContribution = mstrContribution;
67 
68  masterDofMans.resize(countOfMasterDofs);
69  dofIDs.resize(countOfMasterDofs);
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 
83 int
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++ ) {
98  }
99  if ( c == 0 ) {
100  OOFEM_ERROR("slaveDof is own master");
101  }
102 
103  return countOfPrimaryMasterDofs = c;
104 }
105 
106 void
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 
120 void
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 
134 void
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 
149 void
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 
165 void
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 
182 {
183  FloatArray masterUnknowns, t;
184 
185  this->giveUnknowns(masterUnknowns, mode, tStep);
186  this->computeDofTransformation(t);
187 
188  return masterUnknowns.dotProduct(t);
189 }
190 
192 {
193  FloatArray masterUnknowns, t;
194 
195  giveUnknowns(masterUnknowns, field, mode, tStep);
197 
198  return masterUnknowns.dotProduct(t);
199 }
200 
201 
203 {
204  OOFEM_ERROR("undefined");
205  return 0;
206 }
207 
208 
210 {
211  OOFEM_ERROR("undefined");
212  return 0;
213 }
214 
216 {
217  contextIOResultType iores;
218  if ( ( iores = Dof :: saveContext(stream, mode, obj) ) != CIO_OK ) {
219  THROW_CIOERR(iores);
220  }
221 
222  if ( mode & CM_Definition ) {
223  if ( !stream.write(countOfMasterDofs) ) {
225  }
226 
227  if ( !stream.write(countOfPrimaryMasterDofs) ) {
229  }
230 
231  if ( ( iores = masterContribution.storeYourself(stream) ) != CIO_OK ) {
232  THROW_CIOERR(iores);
233  }
234 
235  for ( int _idof = 1; _idof <= countOfMasterDofs; _idof++ ) {
236  int _idofmanNum;
237  if ( mode & CM_DefinitionGlobal ) {
238  _idofmanNum = dofManager->giveDomain()->giveDofManager( masterDofMans.at(_idof) )->giveGlobalNumber();
239  } else {
240  _idofmanNum = masterDofMans.at(_idof);
241  }
242 
243  if ( !stream.write(_idofmanNum) ) {
245  }
246  }
247 
248  if ( ( iores = dofIDs.storeYourself(stream) ) != CIO_OK ) {
249  THROW_CIOERR(iores);
250  }
251  } // if ( mode & CM_Definition )
252 
253  return CIO_OK;
254 }
255 
257 {
258  contextIOResultType iores;
259  if ( ( iores = Dof :: restoreContext(stream, mode, obj) ) != CIO_OK ) {
260  THROW_CIOERR(iores);
261  }
262 
263  if ( mode & CM_Definition ) {
264  if ( !stream.read(countOfMasterDofs) ) {
266  }
267 
268  if ( !stream.read(countOfPrimaryMasterDofs) ) {
270  }
271 
272  if ( ( iores = masterContribution.restoreYourself(stream) ) != CIO_OK ) {
273  THROW_CIOERR(iores);
274  }
275 
276  int _idof;
277 
279  for ( _idof = 1; _idof <= countOfMasterDofs; _idof++ ) {
280  if ( !stream.read(masterDofMans.at(_idof)) ) {
282  }
283  }
284 
285  if ( ( iores = dofIDs.restoreYourself(stream) ) != CIO_OK ) {
286  THROW_CIOERR(iores);
287  }
288  } // if ( mode & CM_Definition )
289 
290  return CIO_OK;
291 }
292 
293 
294 inline Dof *
296 {
297  return dofManager->giveDomain()->giveDofManager( masterDofMans.at(i) )->giveDofWithID( dofIDs.at(i) );
298 }
299 
300 
301 void
303 {
304  for ( int i = 1; i <= countOfMasterDofs; i++ ) {
306  }
307 }
308 
309 
310 void
312 {
313  IntArray mstrDofManArry;
314 
315  int masterDofs = this->giveNumberOfPrimaryMasterDofs();
316  answer.preallocate(masterDofs);
317  answer.clear();
318 
319  for ( int i = 1; i <= countOfMasterDofs; i++ ) {
320  this->giveMasterDof(i)->giveMasterDofManArray(mstrDofManArry);
321  answer.followedBy(mstrDofManArry);
322  }
323 }
324 } // end namespace oofem
contextIOResultType storeYourself(DataStream &stream) const
Stores array to output stream.
Definition: intarray.C:289
void copySubVector(const FloatArray &src, int si)
Copy the given vector as sub-vector to receiver.
Definition: floatarray.C:864
IntArray dofIDs
Array of master dofIDs.
Definition: slavedof.h:57
virtual contextIOResultType restoreContext(DataStream &stream, ContextMode mode, void *obj=NULL)
Restores the receiver state previously written in stream.
Definition: slavedof.C:256
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
bool isEmpty() const
Checks if receiver is empty (i.e., zero sized).
Definition: intarray.h:208
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
virtual int __givePrescribedEquationNumber()
Returns equation number corresponding to receiver.
Definition: slavedof.C:209
FloatArray masterContribution
Vector of master contribution coefficients.
Definition: slavedof.h:59
virtual Dictionary * giveUnknowns()
Receives the dictionary of unknowns in receiver.
Definition: dof.h:401
virtual void giveEquationNumbers(IntArray &masterEqNumbers, const UnknownNumberingScheme &s)
Returns equation number of receiver.
Definition: slavedof.C:150
virtual int giveNumberOfPrimaryMasterDofs()
Definition: slavedof.C:84
SlaveDof(DofManager *aNode, DofIDItem id=Undef)
Constructor.
Definition: slavedof.C:44
Base class for dof managers.
Definition: dofmanager.h:113
General IO error.
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.
virtual int __giveEquationNumber() const
Returns equation number corresponding to receiver.
Definition: slavedof.C:202
#define THROW_CIOERR(e)
Definition: contextioerr.h:61
virtual void giveUnknowns(FloatArray &masterUnknowns, ValueModeType mode, TimeStep *tStep)
The key method of class Dof.
Definition: dof.C:162
int countOfPrimaryMasterDofs
Count of master DofManagers.
Definition: slavedof.h:53
virtual int write(const int *data, int count)=0
Writes count integer values from array pointed by data.
virtual void updateLocalNumbering(EntityRenumberingFunctor &f)
Local renumbering support.
Definition: slavedof.C:302
double dotProduct(const FloatArray &x) const
Computes the dot product (or inner product) of receiver and argument.
Definition: floatarray.C:463
#define OOFEM_ERROR(...)
Definition: error.h:61
void initialize(const IntArray &masterNodes, const IntArray &mstrDofID, const FloatArray &mstrContribution)
Definition: slavedof.C:52
void clear()
Clears the array (zero size).
Definition: intarray.h:177
DofIDItem
Type representing particular dof type.
Definition: dofiditem.h:86
DofManager * dofManager
Link to related DofManager.
Definition: dof.h:97
virtual void computeDofTransformation(FloatArray &primaryMasterContribs)
Computes dof transformation array, which describes the dependence of receiver value on values of mast...
Definition: slavedof.C:135
virtual double giveUnknown(ValueModeType mode, TimeStep *tStep)
Returns the value of the unknown associated with the receiver at given time step. ...
Definition: slavedof.C:181
Abstract base class allowing to control the way, how equations are assigned to individual DOFs...
contextIOResultType restoreYourself(DataStream &stream)
Definition: floatarray.C:895
virtual void giveMasterDofManArray(IntArray &answer)
Definition: dof.C:183
void resize(int n)
Checks size of receiver towards requested bounds.
Definition: intarray.C:124
contextIOResultType restoreYourself(DataStream &stream)
Restores array from image on stream.
Definition: intarray.C:305
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: slavedof.C:215
virtual contextIOResultType saveContext(DataStream &stream, ContextMode mode, void *obj=NULL)
Stores receiver state to output stream.
Definition: dof.C:136
virtual void giveMasterDofManArray(IntArray &answer)
Definition: slavedof.C:311
IntArray masterDofMans
Array of master DofManagers.
Definition: slavedof.h:55
DofIDItem dofID
Physical meaning of DOF.
Definition: dof.h:99
#define CM_DefinitionGlobal
Definition: contextmode.h:48
virtual contextIOResultType restoreContext(DataStream &stream, ContextMode mode, void *obj=NULL)
Restores the receiver state previously written in stream.
Definition: dof.C:148
void followedBy(const IntArray &b, int allocChunk=0)
Appends array b at the end of receiver.
Definition: intarray.C:145
void times(double s)
Multiplies receiver with scalar.
Definition: floatarray.C:818
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
#define CM_Definition
Definition: contextmode.h:47
Domain * giveDomain() const
Definition: femcmpnn.h:100
virtual void giveDofIDs(IntArray &masterDofIDs)
As giveEquationNumbers but for dof IDs.
Definition: slavedof.C:166
virtual int giveNumberOfPrimaryMasterDofs()
Definition: dof.h:252
int giveSize() const
Definition: intarray.h:203
int giveSize() const
Returns the size of receiver.
Definition: floatarray.h:218
void preallocate(int futureSize)
Preallocates receiver to given futureSize if larger then allocatedSize.
Definition: intarray.C:130
the oofem namespace is to define a context or scope in which all oofem names are defined.
Abstract class Dof represents Degree Of Freedom in finite element mesh.
Definition: dof.h:93
DofManager * giveDofManager(int n)
Service for accessing particular domain dof manager.
Definition: domain.C:314
virtual void giveDofIDs(IntArray &masterDofIDs)
As giveEquationNumbers but for dof IDs.
Definition: dof.C:67
int countOfMasterDofs
Count of master DofManagers.
Definition: slavedof.h:51
Class representing solution step.
Definition: timestep.h:80
Dof * giveMasterDof(int i)
Definition: slavedof.C:295
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:31 for OOFEM by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2011