OOFEM 3.0
Loading...
Searching...
No Matches
fei3dlinelin.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 "fei3dlinelin.h"
36#include "mathfem.h"
37#include "floatmatrix.h"
38#include "floatarray.h"
40
41namespace oofem {
42double
43FEI3dLineLin :: giveLength(const FEICellGeometry &cellgeo) const
44{
45 return distance(cellgeo.giveVertexCoordinates(2), cellgeo.giveVertexCoordinates(1));
46}
47
48void
49FEI3dLineLin :: evalN(FloatArray &answer, const FloatArray &lcoords, const FEICellGeometry &cellgeo) const
50{
51 double ksi = lcoords.at(1);
52 answer.resize(2);
53
54 answer.at(1) = ( 1. - ksi ) * 0.5;
55 answer.at(2) = ( 1. + ksi ) * 0.5;
56}
57
58double
59FEI3dLineLin :: evaldNdx(FloatMatrix &answer, const FloatArray &lcoords, const FEICellGeometry &cellgeo) const
60{
62 FloatArray vec;
64
65 double detJ = vec.computeSquaredNorm() * 0.5;
66 double l2_inv = 0.5 / detJ;
67 answer.resize(2, 3);
68
69 answer.at(1, 1) = -vec.at(1) * l2_inv;
70 answer.at(2, 1) = vec.at(1) * l2_inv;
71 answer.at(1, 2) = -vec.at(2) * l2_inv;
72 answer.at(2, 2) = vec.at(2) * l2_inv;
73 answer.at(1, 3) = -vec.at(3) * l2_inv;
74 answer.at(2, 3) = vec.at(3) * l2_inv;
75
76 return detJ;
77}
78
79void
80FEI3dLineLin :: evald2Ndx2(FloatMatrix &answer, const FloatArray &lcoords, const FEICellGeometry &cellgeo) const
81{
82 answer.resize(2, 3);
83 answer.zero();
84}
85
86void
87FEI3dLineLin :: local2global(FloatArray &answer, const FloatArray &lcoords, const FEICellGeometry &cellgeo) const
88{
89 double ksi = lcoords.at(1);
90
91 answer.beScaled( ( 1. - ksi ) * 0.5, cellgeo.giveVertexCoordinates(1) );
92 answer.add( ( 1. + ksi ) * 0.5, cellgeo.giveVertexCoordinates(2) );
93}
94
95
96int
97FEI3dLineLin :: global2local(FloatArray &answer, const FloatArray &coords, const FEICellGeometry &cellgeo) const
98{
99 FloatArray vec, x;
100 vec.beDifferenceOf( cellgeo.giveVertexCoordinates(2), cellgeo.giveVertexCoordinates(1) );
101 x.beDifferenceOf( coords, cellgeo.giveVertexCoordinates(1) );
102 double l2 = vec.computeSquaredNorm();
103 double xvec = x.dotProduct(vec);
104
105 answer = Vec1(2.0 * xvec / l2 - 1.0);
106 answer.at(1) = clamp(answer.at(1), -1.0, 1.0);
107 return false; // No point to check if point is "inside".
108}
109
110
111double
112FEI3dLineLin :: giveTransformationJacobian(const FloatArray &lcoords, const FEICellGeometry &cellgeo) const
113{
114 return 0.5 * this->giveLength(cellgeo);
115}
116
117
118void
119FEI3dLineLin :: edgeEvalN(FloatArray &answer, int iedge, const FloatArray &lcoords, const FEICellGeometry &cellgeo) const
120{
121 this->evalN(answer, lcoords, cellgeo);
122}
123
124void
125FEI3dLineLin :: edgeEvaldNdx(FloatMatrix &answer, int iedge,
126 const FloatArray &lcoords, const FEICellGeometry &cellgeo) const
127{
128 double l_inv = 1.0 / this->giveLength(cellgeo);
129
130 answer.resize(2, 1);
131 answer.at(1, 1) = -l_inv;
132 answer.at(2, 1) = l_inv;
133}
134
135void
136FEI3dLineLin :: edgeLocal2global(FloatArray &answer, int iedge,
137 const FloatArray &lcoords, const FEICellGeometry &cellgeo) const
138{
139 return this->local2global(answer, lcoords, cellgeo);
140}
141
142
143double
144FEI3dLineLin :: edgeGiveTransformationJacobian(int iedge, const FloatArray &lcoords, const FEICellGeometry &cellgeo) const
145{
146 return this->giveTransformationJacobian(lcoords, cellgeo);
147}
148
149
151FEI3dLineLin :: computeLocalEdgeMapping(int iedge) const
152{
153 if ( iedge != 1 ) {
154 OOFEM_ERROR("wrong edge number (%d)", iedge);
155 }
156 return {1, 2};
157}
158
159void
160FEI3dLineLin :: surfaceEvalN(FloatArray &answer, int isurf, const FloatArray &lcoords, const FEICellGeometry &cellgeo) const
161{
162 OOFEM_ERROR("no surfaces available");
163}
164
165double
166FEI3dLineLin :: surfaceEvalNormal(FloatArray &answer, int isurf, const FloatArray &lcoords, const FEICellGeometry &cellgeo) const
167{
168 OOFEM_ERROR("no surfaces available");
169 //return 0.0;
170}
171
172void
173FEI3dLineLin :: surfaceLocal2global(FloatArray &answer, int iedge,
174 const FloatArray &lcoords, const FEICellGeometry &cellgeo) const
175{
176 OOFEM_ERROR("no surfaces available");
177}
178
179double
180FEI3dLineLin :: surfaceGiveTransformationJacobian(int isurf, const FloatArray &lcoords,
181 const FEICellGeometry &cellgeo) const
182{
183 OOFEM_ERROR("no surfaces available");
184 //return 0.0;
185}
186
188FEI3dLineLin :: computeLocalSurfaceMapping(int isurf) const
189{
190 OOFEM_ERROR("no surfaces available");
191 //return {};
192}
193
194
195void
196FEI3dLineLin :: giveJacobianMatrixAt(FloatMatrix &jacobianMatrix, const FloatArray &lcoords, const FEICellGeometry &cellgeo) const
197// Returns the jacobian matrix J (x,y,z)/(ksi,eta,dzeta) of the receiver.
198{
200 jacobianMatrix.resize(1, 1);
201 jacobianMatrix.at(1, 1) = 1.0;
202}
203
204std::unique_ptr<IntegrationRule>
205FEI3dLineLin :: giveIntegrationRule(int order, Element_Geometry_Type egt) const
206{
207 auto iRule = std::make_unique<GaussIntegrationRule>(1, nullptr);
208 int points = iRule->getRequiredNumberOfIntegrationPoints(_Line, order + 0);
209 iRule->SetUpPointsOnLine(points, _Unknown);
210 return std::move(iRule);
211}
212
213std::unique_ptr<IntegrationRule>
214FEI3dLineLin :: giveBoundaryIntegrationRule(int order, int boundary, Element_Geometry_Type egt) const
215{
217 OOFEM_ERROR("Not supported");
218 //return nullptr;
219}
220} // end namespace oofem
void local2global(FloatArray &answer, const FloatArray &lcoords, const FEICellGeometry &cellgeo) const override
double giveTransformationJacobian(const FloatArray &lcoords, const FEICellGeometry &cellgeo) const override
void evalN(FloatArray &answer, const FloatArray &lcoords, const FEICellGeometry &cellgeo) const override
double giveLength(const FEICellGeometry &cellgeo) const
virtual const FloatArray giveVertexCoordinates(int i) const =0
void resize(Index s)
Definition floatarray.C:94
double & at(Index i)
Definition floatarray.h:202
double computeSquaredNorm() const
Definition floatarray.C:867
double dotProduct(const FloatArray &x) const
Definition floatarray.C:524
void beDifferenceOf(const FloatArray &a, const FloatArray &b)
Definition floatarray.C:403
void beScaled(double s, const FloatArray &b)
Definition floatarray.C:208
void add(const FloatArray &src)
Definition floatarray.C:218
void resize(Index rows, Index cols)
Definition floatmatrix.C:79
void zero()
Zeroes all coefficient of receiver.
double at(std::size_t i, std::size_t j) const
#define OOFEM_ERROR(...)
Definition error.h:79
double distance(const FloatArray &x, const FloatArray &y)
static FloatArray Vec1(const double &a)
Definition floatarray.h:605
double clamp(int a, int lower, int upper)
Returns the clamped value of a between upper and lower.
Definition mathfem.h:88

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