OOFEM 3.0
Loading...
Searching...
No Matches
fei2dlinelin.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 "fei2dlinelin.h"
36#include "mathfem.h"
37#include "floatmatrix.h"
38#include "floatarray.h"
39#include "floatarrayf.h"
41
42namespace oofem {
43
44FloatArrayF<2> FEI2dLineLin :: evalN(double xi)
45{
46 return {( 1. - xi ) * 0.5, ( 1. + xi ) * 0.5};
47}
48
49void FEI2dLineLin :: evalN(FloatArray &answer, const FloatArray &lcoords, const FEICellGeometry &cellgeo) const
50{
51 double xi = lcoords(0);
52 answer.resize(2);
53 answer.at(1) = ( 1. - xi ) * 0.5;
54 answer.at(2) = ( 1. + xi ) * 0.5;
55}
56
57double FEI2dLineLin :: evaldNdx(FloatMatrix &answer, const FloatArray &lcoords, const FEICellGeometry &cellgeo) const
58{
59 // Not meaningful to return anything.
60 answer.clear();
61 return 0.;
62}
63
64void FEI2dLineLin :: evaldNdxi(FloatMatrix &answer, const FloatArray &lcoords, const FEICellGeometry &cellgeo) const
65{
66 answer.resize(2, 1);
67 answer(0, 0) = -0.5;
68 answer(1, 0) = 0.5;
69}
70
71void FEI2dLineLin :: local2global(FloatArray &answer, const FloatArray &lcoords, const FEICellGeometry &cellgeo) const
72{
73 FloatArray n;
74 this->evalN(n, lcoords, cellgeo);
75 answer.resize( max(xind, yind) );
76 answer.zero();
77 answer.at(xind) = n(0) * cellgeo.giveVertexCoordinates(1).at(xind) +
78 n(1) * cellgeo.giveVertexCoordinates(2).at(xind);
79 answer.at(yind) = n(0) * cellgeo.giveVertexCoordinates(1).at(yind) +
80 n(1) * cellgeo.giveVertexCoordinates(2).at(yind);
81}
82
83int FEI2dLineLin :: global2local(FloatArray &answer, const FloatArray &gcoords, const FEICellGeometry &cellgeo) const
84{
85 double x2_x1 = cellgeo.giveVertexCoordinates(2).at(xind) - cellgeo.giveVertexCoordinates(1).at(xind);
86 double y2_y1 = cellgeo.giveVertexCoordinates(2).at(yind) - cellgeo.giveVertexCoordinates(1).at(yind);
87
88 // Projection of the global coordinate gives the value interpolated in [0,1].
89 double dx = gcoords(0) - cellgeo.giveVertexCoordinates(1).at(xind);
90 double dy = gcoords(1) - cellgeo.giveVertexCoordinates(1).at(yind);
91 double xi = (x2_x1) ? ( sqrt( dx*dx*(1 + (y2_y1 / x2_x1)*(y2_y1 / x2_x1) )) ) / ( sqrt(x2_x1 * x2_x1 + y2_y1 * y2_y1) ) : sqrt(dy*dy) / ( sqrt(x2_x1 * x2_x1 + y2_y1 * y2_y1) );
92 // Map to [-1,1] domain.
93 xi = xi * 2 - 1;
94
95 answer.resize(1);
96 answer(0) = clamp(xi, -1., 1.);
97 return false;
98}
99
100void FEI2dLineLin :: edgeEvaldNds(FloatArray &answer, int iedge,
101 const FloatArray &lcoords, const FEICellGeometry &cellgeo) const
102{
103 double xi = lcoords(0);
104 answer.resize(2);
105 answer(0) = -0.5 * xi;
106 answer(1) = 0.5 * xi;
107
108 double es1 = answer(0) * cellgeo.giveVertexCoordinates(1).at(xind) +
109 answer(1) * cellgeo.giveVertexCoordinates(2).at(xind);
110 double es2 = answer(0) * cellgeo.giveVertexCoordinates(1).at(yind) +
111 answer(1) * cellgeo.giveVertexCoordinates(2).at(yind);
112
113 double J = sqrt(es1 * es1 + es2 * es2);
114 answer.times(1 / J);
115 //return J;
116}
117
118double FEI2dLineLin :: edgeEvalNormal(FloatArray &normal, int iedge, const FloatArray &lcoords, const FEICellGeometry &cellgeo) const
119{
120 normal.resize(2);
121 normal.at(1) = cellgeo.giveVertexCoordinates(2).at(yind) - cellgeo.giveVertexCoordinates(1).at(yind);
122 normal.at(2) = -( cellgeo.giveVertexCoordinates(2).at(xind) - cellgeo.giveVertexCoordinates(1).at(xind) );
123 return normal.normalize_giveNorm() * 0.5;
124}
125
126double FEI2dLineLin :: giveTransformationJacobian(const FloatArray &lcoords, const FEICellGeometry &cellgeo) const
127{
128 double x2_x1 = cellgeo.giveVertexCoordinates(2).at(xind) - cellgeo.giveVertexCoordinates(1).at(xind);
129 double y2_y1 = cellgeo.giveVertexCoordinates(2).at(yind) - cellgeo.giveVertexCoordinates(1).at(yind);
130 return sqrt(x2_x1 * x2_x1 + y2_y1 * y2_y1) / 2.0;
131}
132
133IntArray FEI2dLineLin :: boundaryEdgeGiveNodes(int boundary, Element_Geometry_Type egt, bool includeHierarchical) const
134{
135 return {1, 2};
136}
137
138IntArray FEI2dLineLin :: computeLocalEdgeMapping(int iedge) const
139{
140 if ( iedge != 1 ) {
141 OOFEM_ERROR("wrong egde number (%d)", iedge);
142 }
143
144 return {1, 2};
145}
146
147void FEI2dLineLin :: edgeEvalN(FloatArray &answer, int iedge, const FloatArray &lcoords, const FEICellGeometry &cellgeo) const
148{
149 this->evalN(answer, lcoords, cellgeo);
150}
151
152double FEI2dLineLin :: edgeComputeLength(const IntArray &edgeNodes, const FEICellGeometry &cellgeo) const
153{
154 double x2_x1 = cellgeo.giveVertexCoordinates(2).at(xind) - cellgeo.giveVertexCoordinates(1).at(xind);
155 double y2_y1 = cellgeo.giveVertexCoordinates(2).at(yind) - cellgeo.giveVertexCoordinates(1).at(yind);
156 return sqrt(x2_x1 * x2_x1 + y2_y1 * y2_y1);
157}
158
159double FEI2dLineLin :: evalNXIntegral(int iEdge, const FEICellGeometry &cellgeo) const
160{
161 const auto &node1 = cellgeo.giveVertexCoordinates(1);
162 double x1 = node1.at(xind);
163 double y1 = node1.at(yind);
164
165 const auto &node2 = cellgeo.giveVertexCoordinates(2);
166 double x2 = node2.at(xind);
167 double y2 = node2.at(yind);
168
169 return x2 * y1 - x1 * y2;
170}
171
172std::unique_ptr<IntegrationRule> FEI2dLineLin :: giveIntegrationRule(int order, Element_Geometry_Type egt) const
173{
174 auto iRule = std::make_unique<GaussIntegrationRule>(1, nullptr);
175 int points = iRule->getRequiredNumberOfIntegrationPoints(_Line, order + 0);
176 iRule->SetUpPointsOnLine(points, _Unknown);
177 return std::move(iRule);
178}
179
180void
181FEI2dLineLin :: surfaceEvaldNdxi(FloatMatrix &answer, const FloatArray &lcoords) const
182{
183 answer.resize(2, 1);
184 answer(0, 0) = -0.5;
185 answer(1, 0) = 0.5;
186}
187
188void
189FEI2dLineLin :: surfaceEvald2Ndxi2(FloatMatrix &answer, const FloatArray &lcoords) const
190{
191 answer.resize(2, 1);
192 answer(0, 0) = 0;
193 answer(1, 0) = 0;
194}
195
196
197} // end namespace oofem
static FloatArrayF< 2 > evalN(double xi)
virtual const FloatArray giveVertexCoordinates(int i) const =0
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
double normalize_giveNorm()
Definition floatarray.C:850
void times(double s)
Definition floatarray.C:834
void resize(Index rows, Index cols)
Definition floatmatrix.C:79
*Sets size of receiver to be an empty matrix It will have zero rows and zero columns size void clear()
#define OOFEM_ERROR(...)
Definition error.h:79
FloatArrayF< N > max(const FloatArrayF< N > &a, const FloatArrayF< N > &b)
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