OOFEM 3.0
Loading...
Searching...
No Matches
fei3dtrlin.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 "fei3dtrlin.h"
36
37#include "mathfem.h"
38#include "floatmatrix.h"
39#include "floatarray.h"
41#include <stdexcept>
42
43namespace oofem {
44void
45FEI3dTrLin :: evalN(FloatArray &answer, const FloatArray &lcoords, const FEICellGeometry &cellgeo) const
46{
47 this->surfaceEvalN(answer, 1, lcoords, cellgeo);
48}
49
50double
51FEI3dTrLin :: evaldNdx(FloatMatrix &answer, const FloatArray &lcoords, const FEICellGeometry &cellgeo) const
52{
53 OOFEM_ERROR("FEI3dTrLin :: evaldNdx - Not supported");
54 //return 0.;
55}
56
57
58void
59FEI3dTrLin :: evaldNdxi(FloatMatrix &answer, const FloatArray &lcoords, const FEICellGeometry &cellgeo) const
60{
61 this->surfaceEvaldNdxi(answer, lcoords);
62}
63
64
65void
66FEI3dTrLin :: giveDerivativeXi(FloatArray &n, const FloatArray &lc) const
67{
68 n.resize(3);
69 n.at(1) = 1.0;;
70 n.at(2) = 0.0;
71 n.at(3) = -1.0;
72}
73
74void
75FEI3dTrLin :: giveDerivativeEta(FloatArray &n, const FloatArray &lc) const
76{
77 n.resize(3);
78 n.at(1) = 0.0;;
79 n.at(2) = 1.0;
80 n.at(3) = -1.0;
81}
82
83
84void
85FEI3dTrLin :: local2global(FloatArray &answer, const FloatArray &lcoords, const FEICellGeometry &cellgeo) const
86{
87 FloatArray n;
88 this->evalN(n, lcoords, cellgeo);
89 answer.resize(0);
90 for ( int i = 1; i <= 3; ++i ) {
91 answer.add( n.at(i), cellgeo.giveVertexCoordinates(i) );
92 }
93}
94
95#define POINT_TOL 1.e-3
96int
97FEI3dTrLin :: global2local(FloatArray &answer, const FloatArray &gcoords, const FEICellGeometry &cellgeo) const
98{
99 OOFEM_ERROR("FEI3dTrLin :: global2local - Not supported");
100 //return -1;
101
102}
103
104
105void
106FEI3dTrLin :: giveJacobianMatrixAt(FloatMatrix &jacobianMatrix, const FloatArray &lcoords, const FEICellGeometry &cellgeo) const
107{
108 OOFEM_ERROR("FEI3dTrLin :: giveJacobianMatrixAt - Not supported");
109}
110
111
112void
113FEI3dTrLin :: edgeEvalN(FloatArray &answer, int iedge, const FloatArray &lcoords, const FEICellGeometry &cellgeo) const
114{
115 double xi = lcoords.at(1);
116 answer.resize(2);
117 answer.at(1) = ( 1. - xi ) * 0.5;
118 answer.at(2) = ( 1. + xi ) * 0.5;
119}
120
121
122
123void
124FEI3dTrLin :: edgeEvaldNdx(FloatMatrix &answer, int iedge,
125 const FloatArray &lcoords, const FEICellGeometry &cellgeo) const
126{
127 OOFEM_ERROR("FEI3dTrLin :: edgeEvaldNdx - Not supported");
128}
129
130void
131FEI3dTrLin :: edgeEvaldNdxi(FloatArray &answer, int iedge, const FloatArray &lcoords, const FEICellGeometry &cellgeo) const
132{
133 answer.resize(2);
134 answer(0) = -0.5;
135 answer(1) = 0.5;
136}
137
138void
139FEI3dTrLin :: edgeLocal2global(FloatArray &answer, int iedge,
140 const FloatArray &lcoords, const FEICellGeometry &cellgeo) const
141{
143 const auto &edgeNodes = this->computeLocalEdgeMapping(iedge);
144 this->edgeEvalN(N, iedge, lcoords, cellgeo);
145
146 answer.resize(0);
147 for ( int i = 0; i < N.giveSize(); ++i ) {
148 answer.add( N[i], cellgeo.giveVertexCoordinates( edgeNodes[i] ) );
149 }
150}
151
152
153double
154FEI3dTrLin :: edgeGiveTransformationJacobian(int iedge, const FloatArray &lcoords, const FEICellGeometry &cellgeo) const
155{
156 //const auto &edgeNodes = this->computeLocalEdgeMapping(iedge);
158 OOFEM_ERROR("FEI3dTrLin :: edgeGiveTransformationJacobian - Not supported");
159 return -1;
160}
161
162
164FEI3dTrLin :: computeLocalEdgeMapping(int iedge) const
165{
166 if ( iedge == 1 ) { // edge between nodes 1 2
167 return { 1, 2 };
168 } else if ( iedge == 2 ) { // edge between nodes 2 3
169 return { 2, 3 };
170 } else if ( iedge == 3 ) { // edge between nodes 2 3
171 return { 3, 1 };
172 } else {
173 throw std::range_error("invalid edge number");
174 //return {};
175 }
176}
177
178double
179FEI3dTrLin :: edgeComputeLength(const IntArray &edgeNodes, const FEICellGeometry &cellgeo) const
180{
182 OOFEM_ERROR("FEI3dTrLin :: edgeComputeLength - Not supported");
183 //return -1;
184}
185
186void
187FEI3dTrLin :: surfaceEvalN(FloatArray &answer, int isurf, const FloatArray &lcoords, const FEICellGeometry &cellgeo) const
188{
189 answer.resize(3);
190 answer.at(1) = lcoords.at(1);
191 answer.at(2) = lcoords.at(2);
192 answer.at(3) = 1. - lcoords.at(1) - lcoords.at(2);
193}
194
195void
196FEI3dTrLin :: surfaceEvaldNdxi(FloatMatrix &answer, const FloatArray &lcoords) const
197{
198 // Returns matrix with derivatives wrt local coordinates
199 answer.resize(3, 2);
200 FloatArray dndxi(3), dndeta(3);
201
202 this->giveDerivativeXi(dndxi, lcoords);
203 this->giveDerivativeEta(dndeta, lcoords);
204 for ( int i = 1; i <= 3; ++i ) {
205 answer.at(i, 1) = dndxi.at(i);
206 answer.at(i, 2) = dndeta.at(i);
207 }
208}
209
210void
211FEI3dTrLin :: surfaceEvald2Ndxi2(FloatMatrix &answer, const FloatArray &lcoords) const
212{
213
214 answer.resize(3, 3);
215 // d2n/dxidxi
216 answer.at(1, 1) = 0.;
217 answer.at(2, 1) = 0.;
218 answer.at(3, 1) = 0.;
219
220 // d2n/detadeta
221 answer.at(1, 2) = 0.;
222 answer.at(2, 2) = 0.;
223 answer.at(3, 2) = 0.;
224
225 // d2n/dxideta
226 answer.at(1, 3) = 0.;
227 answer.at(2, 3) = 0.;
228 answer.at(3, 3) = 0.;
229
230}
231
232
233
234
235void
236FEI3dTrLin :: surfaceLocal2global(FloatArray &answer, int isurf,
237 const FloatArray &lcoords, const FEICellGeometry &cellgeo) const
238{
239 //Note: This gives the coordinate in the reference system
241 this->surfaceEvalN(N, isurf, lcoords, cellgeo);
242
243 answer.resize(0);
244 for ( int i = 1; i <= N.giveSize(); ++i ) {
245 answer.add( N.at(i), cellgeo.giveVertexCoordinates(i) );
246 }
247}
248
249void
250FEI3dTrLin :: surfaceEvaldNdx(FloatMatrix &answer, int isurf, const FloatArray &lcoords, const FEICellGeometry &cellgeo) const
251{
253 OOFEM_ERROR("FEI3dTrLin :: surfaceEvaldNdx - Not supported");
254}
255
256void
257FEI3dTrLin :: surfaceEvalBaseVectorsAt(FloatArray &G1, FloatArray &G2, const FloatArray &lcoords, const FEICellGeometry &cellgeo) const
258{
259 // Note: These are not normalized. Returns the two tangent vectors to the surface.
260 FloatMatrix dNdxi;
261 this->surfaceEvaldNdxi(dNdxi, lcoords);
262
263 G1.resize(0);
264 G2.resize(0);
265 for ( int i = 0; i < 3; ++i ) {
266 G1.add( dNdxi(i, 1), cellgeo.giveVertexCoordinates(i) );
267 G2.add( dNdxi(i, 2), cellgeo.giveVertexCoordinates(i) );
268 }
269}
270
271double
272FEI3dTrLin :: surfaceEvalNormal(FloatArray &answer, int isurf, const FloatArray &lcoords, const FEICellGeometry &cellgeo) const
273{
274 FloatArray G1, G2; // local curvilinear base vectors
275 this->surfaceEvalBaseVectorsAt(G1, G2, lcoords, cellgeo);
276 answer.beVectorProductOf(G1, G2);
277 double J = answer.computeNorm();
278 answer.times(1 / J);
279 return J;
280}
281
282void
283FEI3dTrLin :: surfaceGiveJacobianMatrixAt(FloatMatrix &jacobianMatrix, const FloatArray &lcoords, const FEICellGeometry &cellgeo) const
284{
285 // Jacobian matrix consists of the three curvilinear base vectors. The third is taken as the normal to the surface.
286 // Note! The base vectors are not normalized except the third (normal)
287 FloatArray G1, G2, G3;
288 this->surfaceEvalBaseVectorsAt(G1, G2, lcoords, cellgeo);
289 G3.beVectorProductOf(G1, G2);
290
291 jacobianMatrix.resize(3, 3);
292 jacobianMatrix.at(1, 1) = G1.at(1);
293 jacobianMatrix.at(1, 2) = G2.at(1);
294 jacobianMatrix.at(1, 3) = G3.at(1);
295 jacobianMatrix.at(2, 1) = G1.at(2);
296 jacobianMatrix.at(2, 2) = G2.at(2);
297 jacobianMatrix.at(2, 3) = G3.at(2);
298 jacobianMatrix.at(3, 1) = G1.at(3);
299 jacobianMatrix.at(3, 2) = G2.at(3);
300 jacobianMatrix.at(3, 3) = G3.at(3);
301}
302
303double
304FEI3dTrLin :: surfaceGiveTransformationJacobian(int isurf, const FloatArray &lcoords, const FEICellGeometry &cellgeo) const
305{
306 OOFEM_ERROR("FEI3dTrLin :: surfaceGiveTransformationJacobian - Not supported yet");
307 //return 0;
308}
309
311FEI3dTrLin :: computeLocalSurfaceMapping(int isurf) const
312{
313 //surfNodes.setValues(3, 1, 2, 3);
314 return computeLocalEdgeMapping(isurf);
315
316}
317
318std::unique_ptr<IntegrationRule>
319FEI3dTrLin :: giveIntegrationRule(int order, Element_Geometry_Type egt) const
320{
321 auto iRule = std::make_unique<GaussIntegrationRule>(1, nullptr);
322 int points = iRule->getRequiredNumberOfIntegrationPoints(_Triangle, order);
323 iRule->SetUpPointsOnTriangle(points, _Unknown);
324 return std::move(iRule);
325}
326
327std::unique_ptr<IntegrationRule>
328FEI3dTrLin :: giveBoundaryIntegrationRule(int order, int boundary, Element_Geometry_Type egt) const
329{
331 OOFEM_ERROR("FEI3dTrLin :: giveBoundaryIntegrationRule - Not supported");
332 //return nullptr;
333}
334
335
336double
337FEI3dTrLin :: giveArea(const FEICellGeometry &cellgeo) const
338{
339 // A = 0.5 * |AB x AC|
340 FloatArray AB = cellgeo.giveVertexCoordinates(2) - cellgeo.giveVertexCoordinates(1);
341 FloatArray AC = cellgeo.giveVertexCoordinates(3) - cellgeo.giveVertexCoordinates(1);
342 FloatArray temp;
343 temp.beVectorProductOf(AB, AC);
344 return 0.5 * temp.computeNorm();
345
346}
347} // end namespace oofem
#define N(a, b)
IntArray computeLocalEdgeMapping(int iedge) const override
Definition fei3dtrlin.C:164
void surfaceEvaldNdxi(FloatMatrix &answer, const FloatArray &lcoords) const override
Definition fei3dtrlin.C:196
void giveDerivativeXi(FloatArray &n, const FloatArray &lcoords) const
Definition fei3dtrlin.C:66
void surfaceEvalBaseVectorsAt(FloatArray &G1, FloatArray &G2, const FloatArray &lcoords, const FEICellGeometry &cellgeo) const
Definition fei3dtrlin.C:257
void giveDerivativeEta(FloatArray &n, const FloatArray &lcoords) const
Definition fei3dtrlin.C:75
void edgeEvalN(FloatArray &answer, int iedge, const FloatArray &lcoords, const FEICellGeometry &cellgeo) const override
Definition fei3dtrlin.C:113
void evalN(FloatArray &answer, const FloatArray &lcoords, const FEICellGeometry &cellgeo) const override
Definition fei3dtrlin.C:45
void surfaceEvalN(FloatArray &answer, int isurf, const FloatArray &lcoords, const FEICellGeometry &cellgeo) const override
Definition fei3dtrlin.C:187
virtual const FloatArray giveVertexCoordinates(int i) const =0
double computeNorm() const
Definition floatarray.C:861
void resize(Index s)
Definition floatarray.C:94
double & at(Index i)
Definition floatarray.h:202
void beVectorProductOf(const FloatArray &v1, const FloatArray &v2)
Definition floatarray.C:476
void add(const FloatArray &src)
Definition floatarray.C:218
void times(double s)
Definition floatarray.C:834
void resize(Index rows, Index cols)
Definition floatmatrix.C:79
double at(std::size_t i, std::size_t j) const
#define OOFEM_ERROR(...)
Definition error.h:79

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