OOFEM 3.0
Loading...
Searching...
No Matches
structengngmodel.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
40#include "dofmanager.h"
41#include "dof.h"
42#include "element.h"
43#include "timestep.h"
44#include "outputmanager.h"
45#include "activebc.h"
46#include "assemblercallback.h"
48
51
52namespace oofem {
53
54void LastEquilibratedInternalForceAssembler :: vectorFromElement(FloatArray& vec, Element& element, TimeStep* tStep, ValueModeType mode) const
55{
56 //static_cast< StructuralElement & >( element ).giveInternalForcesVector(vec, tStep, 1);
57 element.giveCharacteristicVector(vec, LastEquilibratedInternalForcesVector, mode, tStep);
58}
59
60void LinearizedDilationForceAssembler :: vectorFromElement(FloatArray &vec, Element &element, TimeStep *tStep, ValueModeType mode) const
61{
62 StructuralElement &selem = static_cast< StructuralElement & >( element );
63
64 vec.clear();
65 for ( auto &gp : *selem.giveDefaultIntegrationRulePtr() ) {
67 auto epsilonTemperature = static_cast< StructuralMaterial *>( selem.giveStructuralCrossSection()->giveMaterial(gp) )->computeStressIndependentStrainVector(gp, tStep, VM_Incremental);
68
69 if ( epsilonTemperature.giveSize() > 0 ) {
70 FloatMatrix D, B;
71 FloatArray s;
72 double dV = selem.computeVolumeAround(gp);
73 selem.computeBmatrixAt(gp, B);
74 selem.computeConstitutiveMatrixAt(D, ElasticStiffness, gp, tStep);
75 s.beProductOf(D, epsilonTemperature);
76 vec.plusProduct(B, s, dV);
77 }
78 }
79}
80
81void InitialStressMatrixAssembler :: matrixFromElement(FloatMatrix &answer, Element &element, TimeStep *tStep) const
82{
83 static_cast< StructuralElement & >( element ).computeInitialStressMatrix(answer, tStep);
84}
85
86void LumpedInitialStressMatrixAssembler :: matrixFromElement(FloatMatrix &answer, Element &element, TimeStep *tStep) const
87{
88 static_cast< StructuralElement & >( element ).computeLumpedInitialStressMatrix(answer, tStep);
89}
90
91
92
93StructuralEngngModel :: StructuralEngngModel(int i, EngngModel *_master) : EngngModel(i, _master),
95{ }
96
97
98StructuralEngngModel :: ~StructuralEngngModel()
99{ }
100
101
102void
103StructuralEngngModel :: printReactionForces(TimeStep *tStep, int di, FILE *out)
104//
105// computes and prints reaction forces in all supported or restrained dofs
106//
107{
108 FloatArray reactions;
109 IntArray dofManMap, dofidMap, eqnMap;
110
111 Domain *domain = this->giveDomain(di);
112
113 // map contains corresponding dofmanager and dofs numbers corresponding to prescribed equations
114 // sorted according to dofmanger number and as a minor crit. according to dof number
115 // this is necessary for extractor, since the sorted output is expected
116 this->buildReactionTable(dofManMap, dofidMap, eqnMap, tStep, di);
117
118 //
119 // print header
120 //
121 fprintf(out, "\n\n\tR E A C T I O N S O U T P U T:\n\t_______________________________\n\n\n");
122
123 // compute reaction forces
124 this->computeReaction(reactions, tStep, di);
125
126 //
127 // loop over reactions and print them
128 //
129 for ( int i = 1; i <= dofManMap.giveSize(); i++ ) {
130 if ( domain->giveOutputManager()->testDofManOutput(dofManMap.at(i), tStep) ) {
131 fprintf(out, "\tNode %8d iDof %2d reaction % .4e [bc-id: %d]\n",
132 domain->giveDofManager( dofManMap.at(i) )->giveLabel(),
133 dofidMap.at(i), reactions.at( eqnMap.at(i) ),
134 domain->giveDofManager( dofManMap.at(i) )->giveDofWithID( dofidMap.at(i) )->giveBcId() );
135 }
136 }
137}
138
139void StructuralEngngModel :: terminate(TimeStep *tStep){
140 EngngModel :: terminate(tStep);
141}
142
143void
144StructuralEngngModel :: buildReactionTable(IntArray &restrDofMans, IntArray &restrDofs,
145 IntArray &eqn, TimeStep *tStep, int di)
146{
147 // determine number of restrained dofs
148 Domain *domain = this->giveDomain(di);
150 int ndofMan = domain->giveNumberOfDofManagers();
151 int rindex, count = 0;
152
153 // initialize corresponding dofManagers and dofs for each restrained dof
154 restrDofMans.resize(numRestrDofs);
155 restrDofs.resize(numRestrDofs);
156 eqn.resize(numRestrDofs);
157
158 for ( int i = 1; i <= ndofMan; i++ ) {
159 DofManager *inode = domain->giveDofManager(i);
160 for ( Dof *jdof: *inode ) {
161 if ( jdof->isPrimaryDof() && ( jdof->hasBc(tStep) ) ) { // skip slave dofs
162 rindex = jdof->__givePrescribedEquationNumber();
163 if ( rindex ) {
164 count++;
165 restrDofMans.at(count) = i;
166 restrDofs.at(count) = jdof->giveDofID();
167 eqn.at(count) = rindex;
168 } else {
169 // NullDof has no equation number and no prescribed equation number
170 //_error("No prescribed equation number assigned to supported DOF");
171 }
172 }
173 }
174 }
175 // Trim to size.
176 restrDofMans.resizeWithValues(count);
177 restrDofs.resizeWithValues(count);
178 eqn.resizeWithValues(count);
179}
180
181
182void
183StructuralEngngModel :: computeReaction(FloatArray &answer, TimeStep *tStep, int di)
184{
185 FloatArray contribution;
186
188 answer.zero();
189
190 // Add internal forces
191 this->assembleVector( answer, tStep, LastEquilibratedInternalForceAssembler(), VM_Total,
193 // Subtract external loading
195 //this->assembleVector( answer, tStep, ExternalForceAssembler(), VM_Total,
196 // EModelDefaultPrescribedEquationNumbering(), this->giveDomain(di) );
198 this->computeExternalLoadReactionContribution(contribution, tStep, di);
199 answer.subtract(contribution);
201}
202
203
204void
205StructuralEngngModel :: computeExternalLoadReactionContribution(FloatArray &reactions, TimeStep *tStep, int di)
206{
208 reactions.zero();
209 this->assembleVector( reactions, tStep, ExternalForceAssembler(), VM_Total,
211}
212
213
214void
215StructuralEngngModel :: updateInternalRHS(FloatArray &answer, TimeStep *tStep, Domain *d, FloatArray *eNorm)
216{
217#ifdef VERBOSE
218 OOFEM_LOG_DEBUG("Updating internal forces\n");
219#endif
220 // Update solution state counter
221 tStep->incrementStateCounter();
222
224 answer.zero();
225 this->assembleVector(answer, tStep, InternalForceAssembler(), VM_Total, EModelDefaultEquationNumbering(), d, eNorm);
226
227 // Redistributes answer so that every process have the full values on all shared equations
229
230 // Remember last internal vars update time stamp.
232}
233
234
235void
236StructuralEngngModel :: updateYourself(TimeStep *tStep)
237{
238 this->updateInternalState(tStep);
239 EngngModel :: updateYourself(tStep);
240}
241
242
243int
244StructuralEngngModel :: checkConsistency()
245{
246 Domain *domain = this->giveDomain(1);
247 // check for proper element type
248 for ( auto &elem : domain->giveElements() ) {
249 StructuralElement *sePtr = dynamic_cast< StructuralElement * >( elem.get() );
250 StructuralInterfaceElement *siePtr = dynamic_cast< StructuralInterfaceElement * >( elem.get() );
251 StructuralElementEvaluator *see = dynamic_cast< StructuralElementEvaluator * >( elem.get() );
252 StructuralContactElement *sce = dynamic_cast< StructuralContactElement * >( elem.get() );
253 if ( sePtr == NULL && see == NULL && siePtr == NULL && sce == NULL ) {
254 OOFEM_WARNING("Element %d has no structural support", elem->giveLabel());
255 return 0;
256 }
257 }
258
259 EngngModel :: checkConsistency();
260
261 return 1;
262}
263
264
265void
266StructuralEngngModel :: printOutputAt(FILE *file, TimeStep *tStep)
267{
268 if ( !this->giveDomain(1)->giveOutputManager()->testTimeStepOutput(tStep) ) {
269 return; // Do not print even Solution step header
270 }
271
272 EngngModel :: printOutputAt(file, tStep);
273 this->printReactionForces(tStep, 1, file);
274}
275
276
277void
278StructuralEngngModel :: updateInternalState(TimeStep *tStep)
279{
280 for ( auto &domain: domainList ) {
282#ifdef _OPENMP
283#pragma omp parallel for
284#endif
285 for ( auto &dman : domain->giveDofManagers() ) {
286 this->updateDofUnknownsDictionary(dman.get(), tStep);
287 }
288 }
289
290#ifdef _OPENMP
291#pragma omp parallel for
292#endif
293 for ( auto &bc : domain->giveBcs() ) {
295
296 if ( ( abc = dynamic_cast< ActiveBoundaryCondition * >(bc.get()) ) ) {
297 int ndman = abc->giveNumberOfInternalDofManagers();
298 for ( int j = 1; j <= ndman; j++ ) {
300 }
301 }
302 }
303
305#ifdef _OPENMP
306#pragma omp parallel for
307#endif
308 for ( auto &elem : domain->giveElements() ) {
309 elem->updateInternalState(tStep);
310 }
312 }
313 }
314}
315
316
317
318#ifdef __OOFEG
319void
320StructuralEngngModel :: showSparseMtrxStructure(int type, oofegGraphicContext &gc, TimeStep *tStep)
321{
322 Domain *domain = this->giveDomain(1);
323
324 if ( type != 1 ) {
325 return;
326 }
327
328 for ( auto &elem : domain->giveElements() ) {
329 elem->showSparseMtrxStructure(TangentStiffnessMatrix, gc, tStep);
330 }
331}
332#endif
333} // end namespace oofem
int giveLabel() const
Definition dofmanager.h:516
Dof * giveDofWithID(int dofID) const
Definition dofmanager.C:127
virtual int giveBcId()=0
OutputManager * giveOutputManager()
Definition domain.C:1544
int giveNumber()
Returns domain number.
Definition domain.h:281
int giveNumberOfDofManagers() const
Returns number of dof managers in domain.
Definition domain.h:461
DofManager * giveDofManager(int n)
Definition domain.C:317
std ::vector< std ::unique_ptr< Element > > & giveElements()
Definition domain.h:294
virtual void giveCharacteristicVector(FloatArray &answer, CharType type, ValueModeType mode, TimeStep *tStep)
Definition element.C:631
virtual IntegrationRule * giveDefaultIntegrationRulePtr()
Definition element.h:886
virtual double computeVolumeAround(GaussPoint *gp)
Definition element.h:530
std ::vector< std ::unique_ptr< Domain > > domainList
List of problem domains.
Definition engngm.h:217
virtual int giveNumberOfDomainEquations(int di, const UnknownNumberingScheme &num)
Definition engngm.C:452
EngngModel(int i, EngngModel *_master=NULL)
Definition engngm.C:99
virtual void updateDofUnknownsDictionary(DofManager *, TimeStep *)
Definition engngm.h:922
Domain * giveDomain(int n)
Definition engngm.C:1936
@ InternalForcesExchangeTag
Definition engngm.h:321
virtual int requiresUnknownsDictionaryUpdate()
Definition engngm.h:908
int updateSharedDofManagers(FloatArray &answer, const UnknownNumberingScheme &s, int ExchangeTag)
Definition engngm.C:2162
void assembleVector(FloatArray &answer, TimeStep *tStep, const VectorAssembler &va, ValueModeType mode, const UnknownNumberingScheme &s, Domain *domain, FloatArray *eNorms=NULL)
Definition engngm.C:1106
void resize(Index s)
Definition floatarray.C:94
double & at(Index i)
Definition floatarray.h:202
void plusProduct(const FloatMatrix &b, const FloatArray &s, double dV)
Definition floatarray.C:288
void zero()
Zeroes all coefficients of receiver.
Definition floatarray.C:683
void beProductOf(const FloatMatrix &aMatrix, const FloatArray &anArray)
Definition floatarray.C:689
void subtract(const FloatArray &src)
Definition floatarray.C:320
virtual int giveNumberOfInternalDofManagers()
Gives the number of internal dof managers.
virtual DofManager * giveInternalDofManager(int i)
Gives an internal dof manager from receiver.
void resizeWithValues(int n, int allocChunk=0)
Definition intarray.C:64
void resize(int n)
Definition intarray.C:73
int & at(std::size_t i)
Definition intarray.h:104
int giveSize() const
Definition intarray.h:211
int testDofManOutput(int, TimeStep *)
virtual void computeConstitutiveMatrixAt(FloatMatrix &answer, MatResponseMode rMode, GaussPoint *gp, TimeStep *tStep)=0
StructuralCrossSection * giveStructuralCrossSection()
Helper function which returns the structural cross-section for the element.
virtual void computeBmatrixAt(GaussPoint *gp, FloatMatrix &answer, int lowerIndx=1, int upperIndx=ALL_STRAINS)=0
virtual void computeExternalLoadReactionContribution(FloatArray &reactions, TimeStep *tStep, int di)
StateCounterType internalVarUpdateStamp
FloatArray internalForcesEBENorm
Norm of nodal internal forces evaluated on element by element basis (squared).
void buildReactionTable(IntArray &restrDofMans, IntArray &restrDofs, IntArray &eqn, TimeStep *tStep, int di)
void updateInternalState(TimeStep *tStep)
void printReactionForces(TimeStep *tStep, int id, FILE *out)
void computeReaction(FloatArray &answer, TimeStep *tStep, int di)
virtual FloatArray computeStressIndependentStrainVector(GaussPoint *gp, TimeStep *tStep, ValueModeType mode) const
void incrementStateCounter()
Updates solution state counter.
Definition timestep.h:213
StateCounterType giveSolutionStateCounter()
Definition timestep.h:211
#define OOFEM_WARNING(...)
Definition error.h:80
#define OOFEM_LOG_DEBUG(...)
Definition logger.h:144
oofem::oofegGraphicContext gc[OOFEG_LAST_LAYER]

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