OOFEM 3.0
Loading...
Searching...
No Matches
coupledfieldselement.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 *
14 * Copyright (C) 1993 - 2025 Borek Patzak
15 *
16 *
17 *
18 * Czech Technical University, Faculty of Civil Engineering,
19 * Department of Structural Mechanics, 166 29 Prague, Czech Republic
20 *
21 * This library is free software; you can redistribute it and/or
22 * modify it under the terms of the GNU Lesser General Public
23 * License as published by the Free Software Foundation; either
24 * version 2.1 of the License, or (at your option) any later version.
25 *
26 * This program is distributed in the hope that it will be useful,
27 * but WITHOUT ANY WARRANTY; without even the implied warranty of
28 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
29 * Lesser General Public License for more details.
30 *
31 * You should have received a copy of the GNU Lesser General Public
32 * License along with this library; if not, write to the Free Software
33 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
34 */
35
36#if 1
41#include "node.h"
42#include "material.h"
43#include "gausspoint.h"
45#include "floatmatrix.h"
46#include "floatarray.h"
47#include "intarray.h"
48#include "domain.h"
49#include "cltypes.h"
50#include "mathfem.h"
52#include <cstdio>
53
54namespace oofem {
55CoupledFieldsElement :: CoupledFieldsElement(int i, Domain *aDomain) : NLStructuralElement(i, aDomain)
56{
57 nlGeo = 0;
58}
59
60
61void
62CoupledFieldsElement :: computeLocationArrayOfDofIDs(const IntArray &dofIdArray, IntArray &answer)
63{
64 // Routine to extract compute the location array an element given an dofid array.
65 answer.resize(0);
66
67 int k = 0;
68 for ( int i = 1; i <= numberOfDofMans; i++ ) {
69 DofManager *dMan = this->giveDofManager(i);
70 for (int j = 1; j <= dofIdArray.giveSize(); j++ ) {
71 if ( dMan->hasDofID( (DofIDItem) dofIdArray.at(j) ) ) {
72 Dof *d = dMan->giveDofWithID( dofIdArray.at(j) );
73 answer.followedBy( k + d->giveNumber() );
74 //answer.followedBy( k + j );
75 }
76 }
77 k += dMan->giveNumberOfDofs( );
78 }
79}
80
81
82void
83CoupledFieldsElement :: computeVectorOfDofIDs(const IntArray &dofIdArray, ValueModeType valueMode, TimeStep *stepN, FloatArray &answer)
84{
85 // Routine to extract the solution vector for an element given an dofid array.
86 // Size will be numberOfDofs and if a certain dofId does not exist a zero is used as value.
87 answer.resize( numberOfDofMans * dofIdArray.giveSize() ); // equal number of nodes for all fields
88 answer.zero();
89 int k = 1;
90 for ( int i = 1; i <= numberOfDofMans; i++ ) {
91 DofManager *dMan = this->giveDofManager(i);
92 for (int j = 1; j <= dofIdArray.giveSize(); j++ ) {
93 if ( dMan->hasDofID( (DofIDItem) dofIdArray.at(j) ) ) {
94 Dof *d = dMan->giveDofWithID( dofIdArray.at(j) );
95 answer.at(k) = d->giveUnknown(valueMode, stepN);
96 }
97 k++;
98 }
99 }
100}
101
102
103
104void
105CoupledFieldsElement :: giveInternalForcesVectorGen(FloatArray &answer, TimeStep *tStep, int useUpdatedGpRecord,
106 void (*Nfunc)(GaussPoint*, FloatMatrix), void (*Bfunc)(GaussPoint*, FloatMatrix, int, int), //(GaussPoint*, FloatMatrix)
107 void (*NStressFunc)(GaussPoint*, FloatArray), void (*BStressFunc)(GaussPoint*, FloatArray),
108 double (*dVFunc)(GaussPoint*))
109{
110 // General implementation of internal forces that computes
111 // f = sum_gp( N^T*GenStress_N + B^T*GenStress_B ) * dV
112
113 FloatArray NStress, BStress, vGenStress, NS, BS;
114 FloatMatrix N, B;
115
116 for ( int j = 0; j < this->giveNumberOfIntegrationRules(); j++ ) {
117 for ( auto &gp: this->giveIntegrationRule(j) ) {
118 double dV = this->computeVolumeAround(gp);
119
120 // compute generalized stress measures
121 if ( NStressFunc && Nfunc ) {
122 Nfunc(gp, N);
123 NStressFunc(gp, NStress);
124 NS.beTProductOf(N, NStress);
125 answer.add(dV, NS);
126 }
127
128 if ( BStressFunc && Bfunc ) {
129 Bfunc(gp, B, 1, 3);
130 BStressFunc(gp, BStress);
131 BS.beTProductOf(B, BStress);
132 answer.add(dV, BS);
133 }
134 }
135 }
136}
137
138
139void
140CoupledFieldsElement :: computeStiffnessMatrixGen(FloatMatrix &answer, MatResponseMode rMode, TimeStep *tStep,
141 void (*Nfunc)(GaussPoint*, FloatMatrix),
142 void (*Bfunc)(GaussPoint*, FloatMatrix),
143 void (*NStiffness)(FloatMatrix, MatResponseMode, GaussPoint*, TimeStep*),
144 void (*BStiffness)(FloatMatrix, MatResponseMode, GaussPoint*, TimeStep*),
145 double (*volumeAround)(GaussPoint*) )
146{
147 FloatMatrix B, DB, N, DN, D_B, D_N;
148
149 bool matStiffSymmFlag = this->giveCrossSection()->isCharacteristicMtrxSymmetric(rMode);
150 answer.resize(0,0);
151
152 for ( auto &gp: this->giveIntegrationRule(0) ) {
153 double dV = this->computeVolumeAround(gp);
154
155
156 // compute int_V ( N^t * D_N * N )dV
157 if ( NStiffness && Nfunc ) {
158 Nfunc(gp, N);
159 NStiffness(D_N, rMode, gp, tStep);
160 DN.beProductOf(D_N, N);
161 if ( matStiffSymmFlag ) {
162 answer.plusProductSymmUpper(N, DN, dV);
163 } else {
164 answer.plusProductUnsym(N, DN, dV);
165 }
166 }
167
168
169 // compute int_V ( B^t * D_B * B )dV
170 if ( BStiffness && Bfunc ) {
171 Bfunc(gp, B);
172 BStiffness(D_B, rMode, gp, tStep);
173 DB.beProductOf(D_B, B);
174 if ( matStiffSymmFlag ) {
175 answer.plusProductSymmUpper(B, DB, dV);
176 } else {
177 answer.plusProductUnsym(B, DB, dV);
178 }
179 }
180 }
181
182 if ( matStiffSymmFlag ) {
183 answer.symmetrized();
184 }
185}
186
187
188} // end namespace oofem
189
190#endif
#define N(a, b)
double computeVolumeAround(GaussPoint *) override=0
bool hasDofID(DofIDItem id) const
Definition dofmanager.C:174
int giveNumberOfDofs() const
Definition dofmanager.C:287
Dof * giveDofWithID(int dofID) const
Definition dofmanager.C:127
virtual double giveUnknown(ValueModeType mode, TimeStep *tStep)=0
int giveNumberOfIntegrationRules()
Definition element.h:894
int numberOfDofMans
Number of dofmanagers.
Definition element.h:136
virtual IntegrationRule * giveIntegrationRule(int i)
Definition element.h:899
DofManager * giveDofManager(int i) const
Definition element.C:553
CrossSection * giveCrossSection()
Definition element.C:534
void resize(Index s)
Definition floatarray.C:94
double & at(Index i)
Definition floatarray.h:202
void zero()
Zeroes all coefficients of receiver.
Definition floatarray.C:683
void beTProductOf(const FloatMatrix &aMatrix, const FloatArray &anArray)
Definition floatarray.C:721
void add(const FloatArray &src)
Definition floatarray.C:218
void plusProductSymmUpper(const FloatMatrix &a, const FloatMatrix &b, double dV)
void resize(Index rows, Index cols)
Definition floatmatrix.C:79
void plusProductUnsym(const FloatMatrix &a, const FloatMatrix &b, double dV)
void beProductOf(const FloatMatrix &a, const FloatMatrix &b)
void followedBy(const IntArray &b, int allocChunk=0)
Definition intarray.C:94
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
NLStructuralElement(int n, Domain *d)

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