OOFEM 3.0
Loading...
Searching...
No Matches
fei2dlineconst.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 "fei2dlineconst.h"
36#include "mathfem.h"
37#include "floatmatrix.h"
38#include "floatarray.h"
39#include "floatarrayf.h"
41
42namespace oofem {
43
44
45void FEI2dLineConst :: evalN(FloatArray &answer, const FloatArray &lcoords, const FEICellGeometry &cellgeo) const
46{
47 answer.resize(1);
48 answer.at(1) = 1.0;
49}
50
51double FEI2dLineConst :: evaldNdx(FloatMatrix &answer, const FloatArray &lcoords, const FEICellGeometry &cellgeo) const
52{
53 answer.clear();
54 return 0.;
55}
56
57void FEI2dLineConst :: local2global(FloatArray &answer, const FloatArray &lcoords, const FEICellGeometry &cellgeo) const
58{
59 FloatArray n(2);
60 double xi = lcoords(0);
61 n.at(1) = ( 1. - xi ) * 0.5;
62 n.at(2) = ( 1. + xi ) * 0.5;
63 answer.resize( max(xind, yind) );
64 answer.zero();
65 answer.at(xind) = n(0) * cellgeo.giveVertexCoordinates(1).at(xind) +
66 n(1) * cellgeo.giveVertexCoordinates(2).at(xind);
67 answer.at(yind) = n(0) * cellgeo.giveVertexCoordinates(1).at(yind) +
68 n(1) * cellgeo.giveVertexCoordinates(2).at(yind);
69}
70
71int FEI2dLineConst :: global2local(FloatArray &answer, const FloatArray &gcoords, const FEICellGeometry &cellgeo) const
72{
73 double x2_x1 = cellgeo.giveVertexCoordinates(2).at(xind) - cellgeo.giveVertexCoordinates(1).at(xind);
74 double y2_y1 = cellgeo.giveVertexCoordinates(2).at(yind) - cellgeo.giveVertexCoordinates(1).at(yind);
75
76 // Projection of the global coordinate gives the value interpolated in [0,1].
77 double dx = gcoords(0) - cellgeo.giveVertexCoordinates(1).at(xind);
78 double dy = gcoords(1) - cellgeo.giveVertexCoordinates(1).at(yind);
79 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) );
80 // Map to [-1,1] domain.
81 xi = xi * 2 - 1;
82
83 answer.resize(1);
84 answer(0) = clamp(xi, -1., 1.);
85 return false;
86}
87
88void FEI2dLineConst :: edgeEvaldNds(FloatArray &answer, int iedge,
89 const FloatArray &lcoords, const FEICellGeometry &cellgeo) const
90{
91 answer.resize(1);
92 answer.zero();
93}
94
95double FEI2dLineConst :: edgeEvalNormal(FloatArray &normal, int iedge, const FloatArray &lcoords, const FEICellGeometry &cellgeo) const
96{
97 normal.resize(2);
98 normal.at(1) = cellgeo.giveVertexCoordinates(2).at(yind) - cellgeo.giveVertexCoordinates(1).at(yind);
99 normal.at(2) = -( cellgeo.giveVertexCoordinates(2).at(xind) - cellgeo.giveVertexCoordinates(1).at(xind) );
100 return normal.normalize_giveNorm() * 0.5;
101}
102
103double FEI2dLineConst :: giveTransformationJacobian(const FloatArray &lcoords, const FEICellGeometry &cellgeo) const
104{
105 double x2_x1 = cellgeo.giveVertexCoordinates(2).at(xind) - cellgeo.giveVertexCoordinates(1).at(xind);
106 double y2_y1 = cellgeo.giveVertexCoordinates(2).at(yind) - cellgeo.giveVertexCoordinates(1).at(yind);
107 return sqrt(x2_x1 * x2_x1 + y2_y1 * y2_y1) / 2.0;
108}
109
110IntArray FEI2dLineConst :: boundaryEdgeGiveNodes(int boundary, Element_Geometry_Type egt, bool includeHierarchical) const
111{
112 return {1, 2};
113}
114
115IntArray FEI2dLineConst :: computeLocalEdgeMapping(int iedge) const
116{
117 if ( iedge != 1 ) {
118 OOFEM_ERROR("wrong egde number (%d)", iedge);
119 }
120
121 return {1, 2};
122}
123
124void FEI2dLineConst :: edgeEvalN(FloatArray &answer, int iedge, const FloatArray &lcoords, const FEICellGeometry &cellgeo) const
125{
126 this->evalN(answer, lcoords, cellgeo);
127}
128
129double FEI2dLineConst :: edgeComputeLength(const IntArray &edgeNodes, const FEICellGeometry &cellgeo) const
130{
131 double x2_x1 = cellgeo.giveVertexCoordinates(2).at(xind) - cellgeo.giveVertexCoordinates(1).at(xind);
132 double y2_y1 = cellgeo.giveVertexCoordinates(2).at(yind) - cellgeo.giveVertexCoordinates(1).at(yind);
133 return sqrt(x2_x1 * x2_x1 + y2_y1 * y2_y1);
134}
135
136double FEI2dLineConst :: evalNXIntegral(int iEdge, const FEICellGeometry &cellgeo) const
137{
138 const auto &node1 = cellgeo.giveVertexCoordinates(1);
139 double x1 = node1.at(xind);
140 double y1 = node1.at(yind);
141
142 const auto &node2 = cellgeo.giveVertexCoordinates(2);
143 double x2 = node2.at(xind);
144 double y2 = node2.at(yind);
145
146 return x2 * y1 - x1 * y2;
147}
148
149std::unique_ptr<IntegrationRule> FEI2dLineConst :: giveIntegrationRule(int order, Element_Geometry_Type egt) const
150{
151 auto iRule = std::make_unique<GaussIntegrationRule>(1, nullptr);
152 int points = iRule->getRequiredNumberOfIntegrationPoints(_Line, order + 0);
153 iRule->SetUpPointsOnLine(points, _Unknown);
154 return std::move(iRule);
155}
156} // end namespace oofem
void evalN(FloatArray &answer, 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
*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