OOFEM 3.0
Loading...
Searching...
No Matches
fei2dlinehermite.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 "fei2dlinehermite.h"
36#include "mathfem.h"
37#include "floatmatrix.h"
38#include "floatarray.h"
39
40namespace oofem {
41double FEI2dLineHermite :: giveLength(const FEICellGeometry &cellgeo) const
42{
43 double x2_x1 = cellgeo.giveVertexCoordinates(2).at(xind) - cellgeo.giveVertexCoordinates(1).at(xind);
44 double y2_y1 = cellgeo.giveVertexCoordinates(2).at(yind) - cellgeo.giveVertexCoordinates(1).at(yind);
45 return sqrt(x2_x1 * x2_x1 + y2_y1 * y2_y1);
46}
47
48void FEI2dLineHermite :: evalN(FloatArray &answer, const FloatArray &lcoords, const FEICellGeometry &cellgeo) const
49{
50 double ksi = lcoords.at(1);
51 double l = this->giveLength(cellgeo);
52
53 answer.resize(4);
54 answer.zero();
55
56 answer.at(1) = 0.25 * ( 1.0 - ksi ) * ( 1.0 - ksi ) * ( 2.0 + ksi );
57 answer.at(2) = 0.125 * l * ( 1.0 - ksi ) * ( 1.0 - ksi ) * ( 1.0 + ksi );
58 answer.at(3) = 0.25 * ( 1.0 + ksi ) * ( 1.0 + ksi ) * ( 2.0 - ksi );
59 answer.at(4) = -0.125 * l * ( 1.0 + ksi ) * ( 1.0 + ksi ) * ( 1.0 - ksi );
60}
61
62double FEI2dLineHermite :: evaldNdx(FloatMatrix &answer, const FloatArray &lcoords, const FEICellGeometry &cellgeo) const
63{
64 // This is dNds projected on the direction if the linear edge. If any other interpolation is used for geometry, this can't be used anymore.
65 FloatArray dNds;
66 this->edgeEvaldNds(dNds, 1, lcoords, cellgeo);
67 // Tangent line to project on
68 FloatArray vec(2);
69 vec.at(1) = cellgeo.giveVertexCoordinates(2).at(xind) - cellgeo.giveVertexCoordinates(1).at(xind);
70 vec.at(2) = cellgeo.giveVertexCoordinates(2).at(yind) - cellgeo.giveVertexCoordinates(1).at(yind);
71 double detJ = vec.normalize_giveNorm() * 0.5;
72
73 answer.beDyadicProductOf(dNds, vec);
74 return detJ;
75}
76
77void FEI2dLineHermite :: local2global(FloatArray &answer, const FloatArray &lcoords, const FEICellGeometry &cellgeo) const
78{
79 FloatArray n;
80 this->evalN(n, lcoords, cellgeo);
81 answer.resize( max(xind, yind) );
82 answer.zero();
83 answer.at(xind) = n.at(1) * cellgeo.giveVertexCoordinates(1).at(xind) +
84 n.at(2) * cellgeo.giveVertexCoordinates(2).at(xind);
85 answer.at(yind) = n.at(1) * cellgeo.giveVertexCoordinates(1).at(yind) +
86 n.at(2) * cellgeo.giveVertexCoordinates(2).at(yind);
87}
88
89int FEI2dLineHermite :: global2local(FloatArray &answer, const FloatArray &gcoords, const FEICellGeometry &cellgeo) const
90{
91 double x2_x1 = cellgeo.giveVertexCoordinates(2).at(xind) - cellgeo.giveVertexCoordinates(1).at(xind);
92 double y2_y1 = cellgeo.giveVertexCoordinates(2).at(yind) - cellgeo.giveVertexCoordinates(1).at(yind);
93
94 // Projection of the global coordinate gives the value interpolated in [0,1].
95 double xi = ( x2_x1 * gcoords(0) + y2_y1 * gcoords(1) ) / ( sqrt(x2_x1 * x2_x1 + y2_y1 * y2_y1) );
96 // Map to [-1,1] domain.
97 xi = xi * 2.0 - 1.0;
98
99 answer.resize(1);
100 answer(0) = clamp(xi, -1., 1.);
101 return false;
102}
103
104void FEI2dLineHermite :: edgeEvaldNds(FloatArray &answer, int iedge, const FloatArray &lcoords, const FEICellGeometry &cellgeo) const
105{
106 double l_inv = this->giveLength(cellgeo);
107 double ksi = lcoords.at(1);
108
109 answer.resize(4);
110 answer.at(1) = 1.5 * ( ksi * ksi - 1.0 ) * l_inv;
111 answer.at(2) = 0.25 * ( ksi - 1.0 ) * ( 3.0 * ksi + 1.0 );
112 answer.at(3) = -1.5 * ( ksi * ksi - 1.0 ) * l_inv;
113 answer.at(4) = 0.25 * ( ksi + 1.0 ) * ( 3.0 * ksi - 1.0 );
114}
115
116void FEI2dLineHermite :: edgeEvald2Nds2(FloatArray &answer, int iedge, const FloatArray &lcoords, const FEICellGeometry &cellgeo) const
117{
118 double l_inv = this->giveLength(cellgeo);
119 double ksi = lcoords.at(1);
120
121 answer.resize(4);
122 answer.at(1) = l_inv * 6.0 * ksi * l_inv;
123 answer.at(2) = l_inv * ( 3.0 * ksi - 1.0 );
124 answer.at(3) = -l_inv * 6.0 * ksi * l_inv;
125 answer.at(4) = l_inv * ( 3.0 * ksi + 1.0 );
126}
127
128double FEI2dLineHermite :: edgeEvalNormal(FloatArray &normal, int iedge, const FloatArray &lcoords, const FEICellGeometry &cellgeo) const
129{
130 normal.resize(2);
131 normal.at(1) = cellgeo.giveVertexCoordinates(2).at(yind) - cellgeo.giveVertexCoordinates(1).at(yind);
132 normal.at(2) = -( cellgeo.giveVertexCoordinates(2).at(xind) - cellgeo.giveVertexCoordinates(1).at(xind) );
133
134 return normal.normalize_giveNorm() * 0.5;
135}
136
137double FEI2dLineHermite :: giveTransformationJacobian(const FloatArray &lcoords, const FEICellGeometry &cellgeo) const
138{
139 double x2_x1, y2_y1;
140 x2_x1 = cellgeo.giveVertexCoordinates(2).at(xind) - cellgeo.giveVertexCoordinates(1).at(xind);
141 y2_y1 = cellgeo.giveVertexCoordinates(2).at(yind) - cellgeo.giveVertexCoordinates(1).at(yind);
142 return sqrt(x2_x1 * x2_x1 + y2_y1 * y2_y1) * 0.5;
143}
144
145std::unique_ptr<IntegrationRule> FEI2dLineHermite :: giveIntegrationRule(int order, Element_Geometry_Type egt) const
146{
147 OOFEM_ERROR("Not supported.");
148 //return nullptr;
149}
150} // end namespace oofem
double giveLength(const FEICellGeometry &cellgeo) const
void evalN(FloatArray &answer, const FloatArray &lcoords, const FEICellGeometry &cellgeo) const override
void edgeEvaldNds(FloatArray &answer, int iedge, const FloatArray &lcoords, const FEICellGeometry &cellgeo) const override
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 beDyadicProductOf(const FloatArray &vec1, const FloatArray &vec2)
#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