OOFEM 3.0
Loading...
Searching...
No Matches
termlibrary2.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 "mpm.h"
36#include "termlibrary2.h"
37#include "element.h"
38#include "material.h"
39#include "crosssection.h"
40
41namespace oofem {
42
43
44void deltaB(FloatMatrix& answer, const Variable *v, const FEInterpolation* interpol, const Element& cell, const FloatArray& coords, const MaterialMode mmode) {
45 FloatMatrix dndx;
46 int nnodes = interpol->giveNumberOfNodes(cell.giveGeometryType());
47 int ndofs = v->size;
48 // evaluate matrix of derivatives, the member at i,j position contains value of dNi/dxj
49 interpol->evaldNdx(dndx, coords, FEIElementGeometryWrapper(&cell));
50 answer.resize(1, nnodes*ndofs);
51 answer.zero();
52
53
54 if (mmode == _3dUPV) {
55 // 3D mode only now
56 for (int i = 0; i< nnodes; i++) {
57 answer(0, i*ndofs+0) = dndx(i, 0);
58 answer(0, i*ndofs+1) = dndx(i, 1);
59 answer(0, i*ndofs+2) = dndx(i, 2);
60 }
61 } else if (mmode == _2dUPV) {
62 for (int i = 0; i< nnodes; i++) {
63 answer(0, i*ndofs+0) = dndx(i, 0);
64 answer(0, i*ndofs+1) = dndx(i, 1);
65 }
66 }
67}
68
69void evalB(FloatMatrix& answer, const Variable *v, const FEInterpolation* interpol, const Element& cell, const FloatArray& coords, const MaterialMode mmode) {
70 FloatMatrix dndx;
71 int nnodes = interpol->giveNumberOfNodes(cell.giveGeometryType());
72 int ndofs = v->size;
73 // evaluate matrix of derivatives, the member at i,j position contains value of dNi/dxj
74 interpol->evaldNdx(dndx, coords, FEIElementGeometryWrapper(&cell));
75 answer.resize(6, nnodes*ndofs);
76 answer.zero();
77 if ((mmode == _3dUPV)||(mmode == _3dMat)) {
78 // 3D mode
79 for (int i = 0; i< nnodes; i++) {
80 answer(0, i*ndofs+0) = dndx(i, 0); // e_11
81 answer(1, i*ndofs+1) = dndx(i, 1); // e_22
82 answer(2, i*ndofs+2) = dndx(i, 2); // e_33
83 answer(3, i*ndofs+1) = dndx(i, 2); // e_23
84 answer(3, i*ndofs+2) = dndx(i, 1);
85 answer(4, i*ndofs+0) = dndx(i, 2); // e_13
86 answer(4, i*ndofs+2) = dndx(i, 0);
87 answer(5, i*ndofs+0) = dndx(i, 1); // e_12
88 answer(5, i*ndofs+1) = dndx(i, 0);
89 }
90 } else if (mmode == _2dUPV) {
91 for (int i = 0; i< nnodes; i++) {
92 answer(0, i*ndofs+0) = dndx(i, 0); // e_11
93 answer(1, i*ndofs+1) = dndx(i, 1); // e_22
94 answer(5, i*ndofs+0) = dndx(i, 1); // e_12
95 answer(5, i*ndofs+1) = dndx(i, 0);
96 }
97 }
98}
99
100double evalVolumeFraction(const Variable* vf, MPElement& e, const FloatArray& coords, TimeStep* tstep)
101{
102 FloatArray rvf, Nvf;
103 e.getUnknownVector(rvf, vf, VM_TotalIntrinsic, tstep);
104 vf->interpolation->evalN(Nvf, coords, FEIElementGeometryWrapper(&e));
105 return Nvf.dotProduct(rvf);
106}
107
108NTBdivTerm::NTBdivTerm (const Variable *testField, const Variable* unknownField, ValueModeType m) : Term(testField, unknownField), m(m) {}
109
110
111void NTBdivTerm::evaluate_lin (FloatMatrix& answer, MPElement& e, GaussPoint* gp, TimeStep* tstep) const {
112 FloatArray Np;
113 this->testField->interpolation->evalN(Np, gp->giveNaturalCoordinates(), FEIElementGeometryWrapper(&e));
115 deltaB(B, this->field, this->field->interpolation, e, gp->giveNaturalCoordinates(), gp->giveMaterialMode());
116 answer.beTProductOf(Npm,B);
117}
118
119void NTBdivTerm::evaluate (FloatArray& answer, MPElement& cell, GaussPoint* gp, TimeStep* tstep) const {
120 FloatMatrix A;
121 FloatArray u;
122 this->evaluate_lin(A, cell, gp, tstep);
123 cell.getUnknownVector(u, this->field, this->m, tstep);
124 answer.beProductOf(A, u);
125}
126
128 //int nnodes = interpol.giveNumberOfNodes();
129 //int ndofs = v.size;
130 //return nnodes*ndofs;
131}
133
134
135// deltaBTfiNpTerm
136
138
139
141 FloatArray Nvf, Np;
142 FloatMatrix B;
143 deltaB(B, this->testField, this->testField->interpolation, e, gp->giveNaturalCoordinates(), gp->giveMaterialMode());
144 double vf = evalVolumeFraction(this->volumeFraction, e, gp->giveNaturalCoordinates(), tstep);
145 this->field->interpolation->evalN(Np, gp->giveNaturalCoordinates(), FEIElementGeometryWrapper(&e));
147 answer.beTProductOf(B,Npm);
148 answer.times(vf);
149}
150
151void deltaBTfiNpTerm::evaluate (FloatArray& answer, MPElement& cell, GaussPoint* gp, TimeStep* tstep) const {
152 FloatMatrix A;
153 FloatArray p;
154 this->evaluate_lin(A, cell, gp, tstep);
155 cell.getUnknownVector(p, this->field, VM_TotalIntrinsic, tstep);
156 answer.beProductOf(A, p);
157}
158
160
161}
163
164
165// NdTdvfNpTerm
166
168
169
171 FloatArray nvec,dvf,rvf,Np;
172 FloatMatrix N,dndx,help;
173 this->testField->interpolation->evalN(nvec, gp->giveNaturalCoordinates(), FEIElementGeometryWrapper(&e));
174 N.beNMatrixOf(nvec, testField->size);
175 // evaluate derivatives of volume fraction
176 this->volumeFraction->interpolation->evaldNdx(dndx, gp->giveNaturalCoordinates(), FEIElementGeometryWrapper(&e));
177 e.getUnknownVector(rvf, this->volumeFraction, VM_TotalIntrinsic, tstep);
178 dvf.beTProductOf(dndx, rvf);
179 this->field->interpolation->evalN(Np, gp->giveNaturalCoordinates(), FEIElementGeometryWrapper(&e));
181 help.beTProductOf(N,FloatMatrix::fromArray(dvf)); // Nv * dv
182 answer.beProductOf(help, Npm);
183}
184
185void NdTdvfNpTerm::evaluate (FloatArray& answer, MPElement& cell, GaussPoint* gp, TimeStep* tstep) const {
186 FloatMatrix A;
187 FloatArray p;
188 this->evaluate_lin(A, cell, gp, tstep);
189 cell.getUnknownVector(p, this->field, VM_TotalIntrinsic, tstep);
190 answer.beProductOf(A, p);
191}
192
194
195}
197
198// BTmuBTerm
199
200BTmuBTerm::BTmuBTerm (const Variable *testField, const Variable* unknownField) : Term(testField, unknownField) {}
201
202
203void BTmuBTerm::evaluate_lin (FloatMatrix& answer, MPElement& e, GaussPoint* gp, TimeStep* tstep) const {
204 FloatArray nvec,dvf,rvf,Np;
205 FloatMatrix B, M(6,6), MB;
206
207 evalB(B, this->field, this->field->interpolation, e,gp->giveNaturalCoordinates(), gp->giveMaterialMode());
208 double m = e.giveCrossSection()->giveMaterial(gp)->giveCharacteristicValue(FluidViscosity, gp, tstep);
209 M(0,0) = M(1,1) = M(2,2) = 2*m;
210 M(3,3) = M(4,4) = M(5,5) = m;
211 MB.beProductOf(M,B);
212 answer.beTProductOf(B, MB);
213}
214
215void BTmuBTerm::evaluate (FloatArray& answer, MPElement& cell, GaussPoint* gp, TimeStep* tstep) const {
216 FloatMatrix A;
217 FloatArray r;
218 this->evaluate_lin(A, cell, gp, tstep);
219 cell.getUnknownVector(r, this->field, VM_TotalIntrinsic, tstep);
220 answer.beTProductOf(A, r);
221}
222
224
225}
227
228// BTmuVfBTerm
229
231
232
234 FloatMatrix B, M(6,6), MB;
235
236 evalB(B, this->field, this->field->interpolation, e,gp->giveNaturalCoordinates(), gp->giveMaterialMode());
237 double m = e.giveCrossSection()->giveMaterial(gp)->giveCharacteristicValue(FluidViscosity, gp, tstep);
238 double vf = evalVolumeFraction(this->volumeFraction, e, gp->giveNaturalCoordinates(), tstep);
239
240 M(0,0) = M(1,1) = M(2,2) = 2*m*vf;
241 M(3,3) = M(4,4) = M(5,5) = m*vf;
242 MB.beProductOf(M,B);
243 answer.beTProductOf(B, MB);
244}
245
246void BTmuVfBTerm::evaluate (FloatArray& answer, MPElement& cell, GaussPoint* gp, TimeStep* tstep) const {
247 FloatMatrix A;
248 FloatArray r;
249 this->evaluate_lin(A, cell, gp, tstep);
250 cell.getUnknownVector(r, this->field, VM_Velocity, tstep);
251 answer.beTProductOf(A, r);
252}
253
255
256}
258
259// NTmuVfSNTerm
260
262
263
265
266 FloatMatrix S, SI, SIN, Nd;
268
269 this->field->interpolation->evalN(N, gp->giveNaturalCoordinates(), FEIElementGeometryWrapper(&e));
270 Nd.beNMatrixOf (N, testField->size);
271 e.giveCrossSection()->giveMaterial(gp)->giveCharacteristicMatrix(S, Permeability, gp, tstep);
272 double m = e.giveCrossSection()->giveMaterial(gp)->giveCharacteristicValue(FluidViscosity, gp, tstep);
273 double vf = evalVolumeFraction(this->volumeFraction, e, gp->giveNaturalCoordinates(), tstep);
274 SI.beInverseOf(S);
275 SI.times(m*vf);
276
277 SIN.beProductOf(SI,Nd);
278 answer.beTProductOf(Nd, SIN);
279}
280
281void NTmuVfSNTerm::evaluate (FloatArray& answer, MPElement& cell, GaussPoint* gp, TimeStep* tstep) const {
282 FloatMatrix A;
283 FloatArray r;
284 this->evaluate_lin(A, cell, gp, tstep);
285 cell.getUnknownVector(r, this->field, VM_TotalIntrinsic, tstep);
286 answer.beTProductOf(A, r);
287}
288
290
291}
293
294
295
296// deltaBTNpTerm
297
298deltaBTNpTerm::deltaBTNpTerm (const Variable *testField, const Variable* unknownField) : Term(testField, unknownField) {}
299
300
302 FloatArray Nvf, Np;
303 FloatMatrix B;
304 deltaB(B, this->testField, this->testField->interpolation, e, gp->giveNaturalCoordinates(), gp->giveMaterialMode());
305 this->field->interpolation->evalN(Np, gp->giveNaturalCoordinates(), FEIElementGeometryWrapper(&e));
307 answer.beTProductOf(B,Npm);
308}
309
310void deltaBTNpTerm::evaluate (FloatArray& answer, MPElement& cell, GaussPoint* gp, TimeStep* tstep) const {
311 FloatMatrix A;
312 FloatArray p;
313 this->evaluate_lin(A, cell, gp, tstep);
314 cell.getUnknownVector(p, this->field, VM_TotalIntrinsic, tstep);
315 answer.beProductOf(A, p);
316}
317
319
320}
322
323} // end namespace oofem
#define N(a, b)
void evaluate(FloatArray &, MPElement &cell, GaussPoint *gp, TimeStep *tstep) const override
Evaluates Internal forces vector, i.e. $b^T\sigma(u)$.
void evaluate_lin(FloatMatrix &answer, MPElement &e, GaussPoint *gp, TimeStep *tstep) const override
Evaluates the linearization of $B^T\sigma(u)$, i.e. $B^TDBu$.
void getDimensions(Element &cell) const override
void initializeCell(Element &cell) const override
BTmuBTerm(const Variable *testField, const Variable *unknownField)
Constructor.
void evaluate(FloatArray &, MPElement &cell, GaussPoint *gp, TimeStep *tstep) const override
Evaluates Internal forces vector, i.e. $b^T\sigma(u)$.
const Variable * volumeFraction
void getDimensions(Element &cell) const override
void initializeCell(Element &cell) const override
BTmuVfBTerm(const Variable *testField, const Variable *unknownField, const Variable *volumeFraction)
Constructor.
void evaluate_lin(FloatMatrix &answer, MPElement &e, GaussPoint *gp, TimeStep *tstep) const override
Evaluates the linearization of $B^T\sigma(u)$, i.e. $B^TDBu$.
virtual Material * giveMaterial(IntegrationPoint *ip) const =0
hidden by virtual oofem::Material* TransportCrossSection::giveMaterial() const
CrossSection * giveCrossSection()
Definition element.C:534
virtual Element_Geometry_Type giveGeometryType() const =0
virtual int giveNumberOfNodes(const Element_Geometry_Type) const
Definition feinterpol.h:557
virtual void evalN(FloatArray &answer, const FloatArray &lcoords, const FEICellGeometry &cellgeo) const =0
virtual double evaldNdx(FloatMatrix &answer, const FloatArray &lcoords, const FEICellGeometry &cellgeo) const =0
double dotProduct(const FloatArray &x) const
Definition floatarray.C:524
void beProductOf(const FloatMatrix &aMatrix, const FloatArray &anArray)
Definition floatarray.C:689
void beTProductOf(const FloatMatrix &aMatrix, const FloatArray &anArray)
Definition floatarray.C:721
void times(double f)
static FloatMatrix fromArray(const FloatArray &vector, bool transpose=false)
void resize(Index rows, Index cols)
Definition floatmatrix.C:79
void beProductOf(const FloatMatrix &a, const FloatMatrix &b)
void beNMatrixOf(const FloatArray &n, int nsd)
void zero()
Zeroes all coefficient of receiver.
bool beInverseOf(const FloatMatrix &src)
void beTProductOf(const FloatMatrix &a, const FloatMatrix &b)
const FloatArray & giveNaturalCoordinates() const
Returns coordinate array of receiver.
Definition gausspoint.h:138
MaterialMode giveMaterialMode()
Returns corresponding material mode of receiver.
Definition gausspoint.h:190
Base class for elements based on mp (multi-physics) concept.
Definition mpm.h:282
virtual const void getUnknownVector(FloatArray &answer, const Variable *field, ValueModeType mode, TimeStep *tstep)
Returns vector of nodal unknowns for given Variable.
Definition mpm.h:473
virtual void giveCharacteristicMatrix(FloatMatrix &answer, MatResponseMode type, GaussPoint *gp, TimeStep *tStep) const
Returns characteristic matrix of the receiver.
Definition material.h:140
virtual double giveCharacteristicValue(MatResponseMode type, GaussPoint *gp, TimeStep *tStep) const
Returns characteristic value of the receiver.
Definition material.C:68
ValueModeType m
void evaluate(FloatArray &, MPElement &cell, GaussPoint *gp, TimeStep *tstep) const override
Evaluates Internal forces vector, i.e. $b^T\sigma(u)$.
void initializeCell(Element &cell) const override
void evaluate_lin(FloatMatrix &answer, MPElement &e, GaussPoint *gp, TimeStep *tstep) const override
Evaluates the linearization of $B^T\sigma(u)$, i.e. $B^TDBu$.
NTBdivTerm(const Variable *testField, const Variable *unknownField, ValueModeType m)
void getDimensions(Element &cell) const override
const Variable * volumeFraction
void evaluate_lin(FloatMatrix &answer, MPElement &e, GaussPoint *gp, TimeStep *tstep) const override
Evaluates the linearization of $B^T\sigma(u)$, i.e. $B^TDBu$.
void getDimensions(Element &cell) const override
NTmuVfSNTerm(const Variable *testField, const Variable *unknownField, const Variable *volumeFraction)
Constructor.
void initializeCell(Element &cell) const override
void evaluate(FloatArray &, MPElement &cell, GaussPoint *gp, TimeStep *tstep) const override
Evaluates Internal forces vector, i.e. $b^T\sigma(u)$.
void initializeCell(Element &cell) const override
NdTdvfNpTerm(const Variable *testField, const Variable *unknownField, const Variable *volumeFraction)
Constructor.
const Variable * volumeFraction
void evaluate(FloatArray &, MPElement &cell, GaussPoint *gp, TimeStep *tstep) const override
Evaluates Internal forces vector, i.e. $b^T\sigma(u)$.
void evaluate_lin(FloatMatrix &answer, MPElement &e, GaussPoint *gp, TimeStep *tstep) const override
Evaluates the linearization of $B^T\sigma(u)$, i.e. $B^TDBu$.
void getDimensions(Element &cell) const override
const Variable * field
Definition mpm.h:136
const Variable * testField
Definition mpm.h:137
const FEInterpolation * interpolation
Definition mpm.h:94
void initializeCell(Element &cell) const override
deltaBTNpTerm(const Variable *testField, const Variable *unknownField)
void getDimensions(Element &cell) const override
void evaluate_lin(FloatMatrix &answer, MPElement &e, GaussPoint *gp, TimeStep *tstep) const override
Evaluates the linearization of $B^T\sigma(u)$, i.e. $B^TDBu$.
void evaluate(FloatArray &, MPElement &cell, GaussPoint *gp, TimeStep *tstep) const override
Evaluates Internal forces vector, i.e. $b^T\sigma(u)$.
void evaluate_lin(FloatMatrix &answer, MPElement &e, GaussPoint *gp, TimeStep *tstep) const override
Evaluates the linearization of $B^T\sigma(u)$, i.e. $B^TDBu$.
void getDimensions(Element &cell) const override
const Variable * volumeFraction
void evaluate(FloatArray &, MPElement &cell, GaussPoint *gp, TimeStep *tstep) const override
Evaluates Internal forces vector, i.e. $b^T\sigma(u)$.
void initializeCell(Element &cell) const override
deltaBTfiNpTerm(const Variable *testField, const Variable *unknownField, const Variable *volumeFraction)
#define S(p)
Definition mdm.C:469
void evalB(FloatMatrix &answer, const Variable *v, const FEInterpolation *interpol, const Element &cell, const FloatArray &coords, const MaterialMode mmode)
Evaluates $B$ = matrix;.
void deltaB(FloatMatrix &answer, const Variable *v, const FEInterpolation *interpol, const Element &cell, const FloatArray &coords, const MaterialMode mmode)
Evaluates $\delta B = B_{div}$ matrix;.
double evalVolumeFraction(const Variable *vf, MPElement &e, const FloatArray &coords, TimeStep *tstep)

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