OOFEM 3.0
Loading...
Searching...
No Matches
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 - 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 "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
43namespace oofem {
44ActiveDof :: ActiveDof(DofManager *aNode, DofIDItem id, int bc) : Dof(aNode, id), equationNumber(0), bc(bc), activeBC(NULL)
45{
46}
47
48void ActiveDof :: initialize(int cntOfMstrDfMngr, const IntArray &masterNodes, const IntArray *mstrDofID, const FloatArray &mstrContribution)
49{
50 OOFEM_ERROR("Shouldn't be statically initialized.");
51}
52
53ActiveBoundaryCondition *ActiveDof :: giveActiveBoundaryCondition()
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
64int ActiveDof :: giveNumberOfPrimaryMasterDofs()
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++ ) {
73 k += this->giveMasterDof(i)->giveNumberOfPrimaryMasterDofs();
74 }
75 return k;
76}
77
78bool ActiveDof :: isPrimaryDof()
79{
80 return this->giveActiveBoundaryCondition()->isPrimaryDof(this);
81}
82
83int ActiveDof :: giveNumberOfMasterDofs()
84{
85 return this->giveActiveBoundaryCondition()->giveNumberOfMasterDofs(this);
86}
87
88
89void ActiveDof :: giveEquationNumbers(IntArray &masterEqNumbers, const UnknownNumberingScheme &s)
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
108void ActiveDof :: giveDofIDs(IntArray &masterDofIDs)
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
127void ActiveDof :: giveMasterDofManArray(IntArray &answer)
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
146void 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
159void 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
172void ActiveDof :: computeDofTransformation(FloatArray &primaryMasterContribs)
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
193double ActiveDof :: giveUnknown(ValueModeType mode, TimeStep *tStep)
194{
195 return this->giveActiveBoundaryCondition()->giveUnknown(mode, tStep, this);
196}
197
198double ActiveDof :: giveUnknown(PrimaryField &field, ValueModeType mode, TimeStep *tStep)
199{
200 return this->giveActiveBoundaryCondition()->giveUnknown(field, mode, tStep, this);
201}
202
203
204int ActiveDof :: __giveEquationNumber() const
205{
206 return this->equationNumber > 0 ? equationNumber : 0;
207}
208
209int ActiveDof :: __givePrescribedEquationNumber()
210{
211 return this->equationNumber < 0 ? -equationNumber : 0;
212}
213
214int ActiveDof :: askNewEquationNumber(TimeStep *tStep)
215{
216 if ( !this->isPrimaryDof() ) {
217 return 0;
218 }
219
220 EngngModel *model = dofManager->giveDomain()->giveEngngModel();
221
222 if ( dofManager->giveParallelMode() == DofManager_null ) {
223 equationNumber = 0;
224 return 0;
225 }
226
227 if ( this->hasBc(tStep) ) {
228 equationNumber = -model->giveNewPrescribedEquationNumber(dofManager->giveDomain()->giveNumber(), this->dofID);
229 } else {
230 equationNumber = model->giveNewEquationNumber(dofManager->giveDomain()->giveNumber(), this->dofID);
231 }
232
233 return equationNumber;
234}
235
236bool ActiveDof :: hasBc(TimeStep *tStep)
237{
238 return this->giveActiveBoundaryCondition()->hasBc(this, tStep);
239}
240
241int ActiveDof :: giveBcId()
242{
243 return this->bc;
244}
245
246void ActiveDof :: setBcId(int bcId)
247{
248 bc = bcId;
249 activeBC = NULL;
250}
251
252double ActiveDof :: giveBcValue(ValueModeType mode, TimeStep *tStep)
253{
254 return this->giveActiveBoundaryCondition()->giveBcValue(this, mode, tStep);
255}
256
257
258// Not sure of initial conditions yet.
259bool ActiveDof :: hasIcOn(ValueModeType type) { return false; }
260bool ActiveDof :: hasIc() { return false; }
261int ActiveDof :: giveIcId() { return 0; }
262InitialCondition *ActiveDof :: giveIc() { return NULL; }
263
264
265void ActiveDof :: saveContext(DataStream &stream, ContextMode mode)
266{
267 // Nothing here since the boundary condition deals with all the values.
268}
269
270void ActiveDof :: restoreContext(DataStream &stream, ContextMode mode)
271{
272}
273
274inline Dof *ActiveDof :: giveMasterDof(int i)
275{
276 return this->giveActiveBoundaryCondition()->giveMasterDof(this, i);
277}
278
279void ActiveDof :: updateLocalNumbering(EntityRenumberingFunctor &f)
280{
281 // No numbering is stored.
282}
283} // end namespace oofem
int equationNumber
Corresponding equation number (positive value) or prescribed equation number (negative value).
Definition activedof.h:52
Dof * giveMasterDof(int i)
Definition activedof.C:274
ActiveBoundaryCondition * activeBC
Active boundary condition number.
Definition activedof.h:56
bool isPrimaryDof() override
Definition activedof.C:78
int giveNumberOfMasterDofs()
Definition activedof.C:83
bool hasBc(TimeStep *tStep) override
Definition activedof.C:236
ActiveBoundaryCondition * giveActiveBoundaryCondition()
Definition activedof.C:53
int bc
Boundary condition number.
Definition activedof.h:54
int giveNumberOfPrimaryMasterDofs() override
Definition activedof.C:64
DofIDItem giveDofID() const
Definition dof.h:276
Dof(DofManager *aNode, DofIDItem id=Undef)
Definition dof.C:50
int giveEquationNumber(const UnknownNumberingScheme &s)
Definition dof.C:56
DofManager * dofManager
Link to related DofManager.
Definition dof.h:97
virtual BoundaryCondition * giveBc()
Definition dof.h:448
int giveDofManNumber() const
Definition dof.C:72
virtual int giveNewPrescribedEquationNumber(int domain, DofIDItem)
Definition engngm.h:821
virtual int giveNewEquationNumber(int domain, DofIDItem)
Definition engngm.h:813
void resize(Index s)
Definition floatarray.C:94
double & at(Index i)
Definition floatarray.h:202
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
void resize(int n)
Definition intarray.C:73
void preallocate(int futureSize)
Definition intarray.C:79
int & at(std::size_t i)
Definition intarray.h:104
#define OOFEM_ERROR(...)
Definition error.h:79
long ContextMode
Definition contextmode.h:43
@ DofManager_null
Definition dofmanager.h:74

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