OOFEM  2.4
OOFEM.org - Object Oriented Finite Element Solver
activedof.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 "activedof.h"
36 #include "activebc.h"
37 #include "domain.h"
38 #include "dofmanager.h"
39 #include "contextioerr.h"
40 #include "activebc.h"
41 #include "engngm.h"
42 
43 namespace oofem {
44 ActiveDof :: ActiveDof(DofManager *aNode, DofIDItem id, int bc) : Dof(aNode, id), equationNumber(0), bc(bc), activeBC(NULL)
45 {
46 }
47 
48 void ActiveDof :: initialize(int cntOfMstrDfMngr, const IntArray &masterNodes, const IntArray *mstrDofID, const FloatArray &mstrContribution)
49 {
50  OOFEM_ERROR("Shouldn't be statically initialized.");
51 }
52 
54 {
55  if ( !activeBC ) {
56  activeBC = dynamic_cast< ActiveBoundaryCondition * >( this->dofManager->giveDomain()->giveBc(bc) );
57  if ( !activeBC ) {
58  OOFEM_ERROR("No active bc at %d\n", bc);
59  }
60  }
61  return activeBC;
62 }
63 
65 {
66  if ( this->isPrimaryDof() ) {
67  return 1;
68  }
69 
70  int countOfMasterDofs = this->giveActiveBoundaryCondition()->giveNumberOfMasterDofs(this);
71  int k = 0;
72  for ( int i = 1; i <= countOfMasterDofs; i++ ) {
74  }
75  return k;
76 }
77 
79 {
80  return this->giveActiveBoundaryCondition()->isPrimaryDof(this);
81 }
82 
84 {
86 }
87 
88 
90 {
91  if ( this->isPrimaryDof() ) {
92  masterEqNumbers.resize(1);
93  masterEqNumbers.at(1) = this->giveEquationNumber(s);
94  return;
95  }
96 
97  IntArray mstrEqNmbrs;
98 
99  int countOfMasterDofs = this->giveNumberOfMasterDofs();
100  masterEqNumbers.preallocate(countOfMasterDofs);
101  masterEqNumbers.clear();
102  for ( int i = 1; i <= countOfMasterDofs; i++ ) {
103  this->giveMasterDof(i)->giveEquationNumbers(mstrEqNmbrs, s);
104  masterEqNumbers.followedBy(mstrEqNmbrs);
105  }
106 }
107 
109 {
110  if ( this->isPrimaryDof() ) {
111  masterDofIDs.resize(1);
112  masterDofIDs.at(1) = this->giveDofID();
113  return;
114  }
115 
116  IntArray mstrDofIDs;
117 
118  int countOfMasterDofs = this->giveNumberOfMasterDofs();
119  masterDofIDs.preallocate(countOfMasterDofs);
120  masterDofIDs.clear();
121  for ( int i = 1; i <= countOfMasterDofs; i++ ) {
122  this->giveMasterDof(i)->giveDofIDs(mstrDofIDs);
123  masterDofIDs.followedBy(mstrDofIDs);
124  }
125 }
126 
128 {
129  if ( this->isPrimaryDof() ) {
130  answer.resize(1);
131  answer.at(1) = this->giveDofManNumber();
132  return;
133  }
134 
135  IntArray subMasterDofManArray;
136 
137  answer.resize( this->giveNumberOfPrimaryMasterDofs() );
138  int countOfMasterDofs = this->giveNumberOfMasterDofs();
139  for ( int i = 1; i <= countOfMasterDofs; i++ ) {
140  this->giveMasterDof(i)->giveMasterDofManArray(subMasterDofManArray);
141  answer.followedBy(subMasterDofManArray);
142  }
143 }
144 
145 
146 void ActiveDof :: giveUnknowns(FloatArray &masterUnknowns, ValueModeType mode, TimeStep *tStep)
147 {
148  FloatArray mstrUnknwns;
149 
150  masterUnknowns.resize( this->giveNumberOfPrimaryMasterDofs() );
151  int countOfMasterDofs = this->giveNumberOfMasterDofs();
152  for ( int k = 1, i = 1; i <= countOfMasterDofs; i++ ) {
153  this->giveMasterDof(i)->giveUnknowns(mstrUnknwns, mode, tStep);
154  masterUnknowns.copySubVector(mstrUnknwns, k);
155  k += mstrUnknwns.giveSize();
156  }
157 }
158 
159 void ActiveDof :: giveUnknowns(FloatArray &masterUnknowns, PrimaryField &field, ValueModeType mode, TimeStep *tStep)
160 {
161  FloatArray mstrUnknwns;
162 
163  masterUnknowns.resize( this->giveNumberOfPrimaryMasterDofs() );
164  int countOfMasterDofs = this->giveNumberOfMasterDofs();
165  for ( int k = 1, i = 1; i <= countOfMasterDofs; i++ ) {
166  this->giveMasterDof(i)->giveUnknowns(mstrUnknwns, field, mode, tStep);
167  masterUnknowns.copySubVector(mstrUnknwns, k);
168  k += mstrUnknwns.giveSize();
169  }
170 }
171 
173 {
174  if ( this->isPrimaryDof() ) {
175  primaryMasterContribs.resize(1);
176  primaryMasterContribs.at(1) = 1.0;
177  return;
178  }
179 
180  FloatArray masterContribution, subPrimaryMasterContribs;
181  this->giveActiveBoundaryCondition()->computeDofTransformation(this, masterContribution);
182 
183  primaryMasterContribs.resize( this->giveNumberOfPrimaryMasterDofs() );
184  int countOfMasterDofs = this->giveNumberOfMasterDofs();
185  for ( int k = 1, i = 1; i <= countOfMasterDofs; i++ ) {
186  this->giveMasterDof(i)->computeDofTransformation(subPrimaryMasterContribs);
187  subPrimaryMasterContribs.times( masterContribution.at(i) );
188  primaryMasterContribs.copySubVector(subPrimaryMasterContribs, k);
189  k += subPrimaryMasterContribs.giveSize();
190  }
191 }
192 
194 {
195  return this->giveActiveBoundaryCondition()->giveUnknown(mode, tStep, this);
196 }
197 
199 {
200  return this->giveActiveBoundaryCondition()->giveUnknown(field, mode, tStep, this);
201 }
202 
203 
205 {
206  return this->equationNumber > 0 ? equationNumber : 0;
207 }
208 
210 {
211  return this->equationNumber < 0 ? -equationNumber : 0;
212 }
213 
215 {
216  if ( !this->isPrimaryDof() ) {
217  return 0;
218  }
219 
221 
223  equationNumber = 0;
224  return 0;
225  }
226 
227  if ( this->hasBc(tStep) ) {
229  } else {
231  }
232 
233  return equationNumber;
234 }
235 
237 {
238  return this->giveActiveBoundaryCondition()->hasBc(this, tStep);
239 }
240 
242 {
243  return this->bc;
244 }
245 
246 void ActiveDof :: setBcId(int bcId)
247 {
248  bc = bcId;
249  activeBC = NULL;
250 }
251 
253 {
254  return this->giveActiveBoundaryCondition()->giveBcValue(this, mode, tStep);
255 }
256 
257 
258 // Not sure of initial conditions yet.
259 bool ActiveDof :: hasIc(TimeStep *tStep) { return false; }
260 bool ActiveDof :: hasIcOn(ValueModeType type) { return false; }
261 bool ActiveDof :: hasIc() { return false; }
262 int ActiveDof :: giveIcId() { return 0; }
264 
265 
267 {
268  // Nothing here since the boundary condition deals with all the values.
269  return CIO_OK;
270 }
271 
273 {
274  return CIO_OK;
275 }
276 
278 {
279  return this->giveActiveBoundaryCondition()->giveMasterDof(this, i);
280 }
281 
283 {
284  // No numbering is stored.
285 }
286 } // end namespace oofem
virtual bool isPrimaryDof()
Tests if receiver is primary DOF.
Definition: activedof.C:78
DofManager in active domain is shared only by remote elements (these are only introduced for nonlocal...
Definition: dofmanager.h:88
void copySubVector(const FloatArray &src, int si)
Copy the given vector as sub-vector to receiver.
Definition: floatarray.C:864
Dof * giveMasterDof(int i)
Definition: activedof.C:277
Class implementing general initial condition.
Abstract class representing field of primary variables (those, which are unknown and are typically as...
Definition: primaryfield.h:104
virtual void initialize(int cntOfMstrDfMngr, const IntArray &masterNodes, const IntArray *mstrDofID, const FloatArray &mstrContribution)
Definition: activedof.C:48
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 int giveNumberOfPrimaryMasterDofs()
Definition: activedof.C:64
virtual Dictionary * giveUnknowns()
Receives the dictionary of unknowns in receiver.
Definition: dof.h:401
virtual double giveBcValue(Dof *dof, ValueModeType mode, TimeStep *tStep)
Returns the prescribed value of a dof (if any).
Definition: activebc.h:161
virtual int giveNumberOfMasterDofs(ActiveDof *dof)
Allows for active boundary conditions to handle their own special DOF.
Definition: activebc.h:172
virtual Dof * giveMasterDof(ActiveDof *dof, int mdof)
Give the pointer to master dof belonging to active DOF.
Definition: activebc.h:183
virtual void computeDofTransformation(FloatArray &primaryMasterContribs)
Computes dof transformation array, which describes the dependence of receiver value on values of mast...
Definition: activedof.C:172
EngngModel * giveEngngModel()
Returns engineering model to which receiver is associated.
Definition: domain.C:433
virtual InitialCondition * giveIc()
Returns initial condition of dof if it is prescribed.
Definition: activedof.C:263
virtual int giveBcId()
Returns the id of associated boundary condition, if there is any.
Definition: activedof.C:241
Base class for dof managers.
Definition: dofmanager.h:113
int giveNumber()
Returns domain number.
Definition: domain.h:266
virtual double giveUnknown(PrimaryField &field, ValueModeType mode, TimeStep *tStep, ActiveDof *dof)
Computes the value of the dof.
Definition: activebc.h:200
virtual int giveNewPrescribedEquationNumber(int domain, DofIDItem)
Increases number of prescribed equations of receiver&#39;s domain and returns newly created equation numb...
Definition: engngm.h:777
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 bool hasIc()
Test if Dof has initial condition.
Definition: activedof.C:261
virtual void giveUnknowns(FloatArray &masterUnknowns, ValueModeType mode, TimeStep *tStep)
The key method of class Dof.
Definition: dof.C:162
GeneralBoundaryCondition * giveBc(int n)
Service for accessing particular domain bc.
Definition: domain.C:243
int giveNumberOfMasterDofs()
Definition: activedof.C:83
virtual int giveNewEquationNumber(int domain, DofIDItem)
Increases number of equations of receiver&#39;s domain and returns newly created equation number...
Definition: engngm.h:769
virtual bool hasBc(Dof *dof, TimeStep *tStep)
Returns the prescribed value of a dof (if any).
Definition: activebc.h:166
virtual void updateLocalNumbering(EntityRenumberingFunctor &f)
Local renumbering support.
Definition: activedof.C:282
virtual void computeDofTransformation(ActiveDof *dof, FloatArray &masterContribs)
Definition: activebc.h:188
int equationNumber
Corresponding equation number (positive value) or prescribed equation number (negative value)...
Definition: activedof.h:52
#define OOFEM_ERROR(...)
Definition: error.h:61
virtual contextIOResultType restoreContext(DataStream &stream, ContextMode mode, void *obj=NULL)
Restores the receiver state previously written in stream.
Definition: activedof.C:272
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 giveEquationNumbers(IntArray &masterEqNumbers, const UnknownNumberingScheme &s)
Returns equation number of receiver.
Definition: activedof.C:89
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
virtual int giveIcId()
Returns the id of associated initial condition, if there is any.
Definition: activedof.C:262
Abstract base class for all active boundary conditions.
Definition: activebc.h:63
void resize(int n)
Checks size of receiver towards requested bounds.
Definition: intarray.C:124
virtual void setBcId(int bcId)
Overwrites the boundary condition id (0-inactive BC), intended for specific purposes such as coupling...
Definition: activedof.C:246
int giveDofManNumber() const
Definition: dof.C:72
virtual int __giveEquationNumber() const
Returns equation number of receiver, usually assigned by emodel.
Definition: activedof.C:204
Class representing vector of real numbers.
Definition: floatarray.h:82
virtual void giveDofIDs(IntArray &masterDofIDs)
As giveEquationNumbers but for dof IDs.
Definition: activedof.C:108
virtual int askNewEquationNumber(TimeStep *tStep)
Asks EngngModel for new equation number.
Definition: activedof.C:214
virtual double giveUnknown(ValueModeType mode, TimeStep *tStep)
The key method of class Dof.
Definition: activedof.C:193
DofIDItem dofID
Physical meaning of DOF.
Definition: dof.h:99
ActiveDof(DofManager *aNode, DofIDItem id=Undef, int bc=0)
Constructor.
Definition: activedof.C:44
void followedBy(const IntArray &b, int allocChunk=0)
Appends array b at the end of receiver.
Definition: intarray.C:145
virtual bool isPrimaryDof(ActiveDof *dof)
Checks to see if the dof is a primary DOF.
Definition: activebc.h:157
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
ActiveBoundaryCondition * giveActiveBoundaryCondition()
Definition: activedof.C:53
int bc
Boundary condition number.
Definition: activedof.h:54
long ContextMode
Context mode (mask), defining the type of information written/read to/from context.
Definition: contextmode.h:43
virtual bool hasBc(TimeStep *tStep)
Test if Dof has active boundary condition.
Definition: activedof.C:236
Domain * giveDomain() const
Definition: femcmpnn.h:100
int giveEquationNumber(const UnknownNumberingScheme &s)
Returns equation number of receiver for given equation numbering scheme.
Definition: dof.C:56
virtual contextIOResultType saveContext(DataStream &stream, ContextMode mode, void *obj=NULL)
Stores receiver state to output stream.
Definition: activedof.C:266
virtual void giveMasterDofManArray(IntArray &answer)
Definition: activedof.C:127
Abstract base class representing the "problem" under consideration.
Definition: engngm.h:181
virtual int giveNumberOfPrimaryMasterDofs()
Definition: dof.h:252
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.
virtual double giveBcValue(ValueModeType mode, TimeStep *tStep)
Returns value of boundary condition of dof if it is prescribed.
Definition: activedof.C:252
Abstract class Dof represents Degree Of Freedom in finite element mesh.
Definition: dof.h:93
virtual void giveDofIDs(IntArray &masterDofIDs)
As giveEquationNumbers but for dof IDs.
Definition: dof.C:67
virtual int __givePrescribedEquationNumber()
Returns prescribed equation number of receiver.
Definition: activedof.C:209
ActiveBoundaryCondition * activeBC
Active boundary condition number.
Definition: activedof.h:56
Class representing solution step.
Definition: timestep.h:80
dofManagerParallelMode giveParallelMode() const
Return dofManagerParallelMode of receiver.
Definition: dofmanager.h:512
virtual bool hasIcOn(ValueModeType type)
Test if Dof has initial condition of required ValueModeType.
Definition: activedof.C:260
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