OOFEM 3.0
Loading...
Searching...
No Matches
fei1dhermite.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 "fei1dhermite.h"
36#include "mathfem.h"
37#include "floatmatrix.h"
38#include "floatarray.h"
39#include "floatmatrixf.h"
40#include "floatarrayf.h"
41
42namespace oofem {
43
44void
45FEI1dHermite :: evalN(FloatArray &answer, const FloatArray &lcoords, const FEICellGeometry &cellgeo) const
46{
47 double ksi = lcoords.at(1);
48 double l = this->giveLength(cellgeo);
49
50 answer.resize(4);
51 answer.zero();
52
53 answer.at(1) = 0.25 * ( 1.0 - ksi ) * ( 1.0 - ksi ) * ( 2.0 + ksi );
54 answer.at(2) = 0.125 * l * ( 1.0 - ksi ) * ( 1.0 - ksi ) * ( 1.0 + ksi );
55 answer.at(3) = 0.25 * ( 1.0 + ksi ) * ( 1.0 + ksi ) * ( 2.0 - ksi );
56 answer.at(4) = -0.125 * l * ( 1.0 + ksi ) * ( 1.0 + ksi ) * ( 1.0 - ksi );
57}
58
59std::pair<double, FloatMatrixF<1,4>>
60FEI1dHermite :: evaldNdx(double ksi, const FEICellGeometry &cellgeo) const
61{
62 double l = this->giveLength(cellgeo);
63 double l_inv = 1.0 / l;
64 FloatMatrixF<1,4> ans = {
65 1.5 * ( -1.0 + ksi * ksi ) * l_inv,
66 0.25 * ( ksi - 1.0 ) * ( 1.0 + 3.0 * ksi ),
67 -1.5 * ( -1.0 + ksi * ksi ) * l_inv,
68 0.25 * ( ksi - 1.0 ) * ( 1.0 + 3.0 * ksi )
69 };
70 return {0.5 * l, ans};
71}
72
73double
74FEI1dHermite :: evaldNdx(FloatMatrix &answer, const FloatArray &lcoords, const FEICellGeometry &cellgeo) const
75{
76 double l = this->giveLength(cellgeo);
77 double l_inv = 1.0 / l;
78 double ksi = lcoords.at(1);
79
80 answer.resize(1, 4);
81 answer.zero();
82
83 answer.at(1, 1) = 1.5 * ( -1.0 + ksi * ksi ) * l_inv;
84 answer.at(1, 2) = 0.25 * ( ksi - 1.0 ) * ( 1.0 + 3.0 * ksi );
85 answer.at(1, 3) = -1.5 * ( -1.0 + ksi * ksi ) * l_inv;
86 answer.at(1, 4) = 0.25 * ( ksi - 1.0 ) * ( 1.0 + 3.0 * ksi );
87
88 return 0.5 * l;
89}
90
92FEI1dHermite :: evald2Ndx2(double ksi, const FEICellGeometry &cellgeo) const
93{
94 double l_inv = 1.0 / this->giveLength(cellgeo);
95
96 return {
97 l_inv * 6.0 * ksi * l_inv,
98 l_inv * ( 3.0 * ksi - 1.0 ),
99 -l_inv * 6.0 * ksi * l_inv,
100 l_inv * ( 3.0 * ksi + 1.0 )
101 };
102}
103
104void
105FEI1dHermite :: evald2Ndx2(FloatMatrix &answer, const FloatArray &lcoords, const FEICellGeometry &cellgeo) const
106{
107 //answer = evald2Ndx2(lcoords[0]);
108 double l_inv = 1.0 / this->giveLength(cellgeo);
109 double ksi = lcoords.at(1);
110 answer.resize(1, 4);
111 answer.zero();
112
113 answer.at(1, 1) = l_inv * 6.0 * ksi * l_inv;
114 answer.at(1, 2) = l_inv * ( 3.0 * ksi - 1.0 );
115 answer.at(1, 3) = -l_inv * 6.0 * ksi * l_inv;
116 answer.at(1, 4) = l_inv * ( 3.0 * ksi + 1.0 );
117}
118
119void
120FEI1dHermite :: local2global(FloatArray &answer, const FloatArray &lcoords, const FEICellGeometry &cellgeo) const
121{
122 FloatArray n;
123 this->evalN(n, lcoords, cellgeo);
124
125 answer.resize(1);
126 answer.at(1) = n.at(1) * cellgeo.giveVertexCoordinates(1).at(cindx) +
127 n.at(2) * cellgeo.giveVertexCoordinates(2).at(cindx) +
128 n.at(3) * cellgeo.giveVertexCoordinates(3).at(cindx);
129}
130
131int
132FEI1dHermite :: global2local(FloatArray &answer, const FloatArray &coords, const FEICellGeometry &cellgeo) const
133{
134 double x1 = cellgeo.giveVertexCoordinates(1).at(cindx);
135 double x2 = cellgeo.giveVertexCoordinates(2).at(cindx);
136
137 double ksi = ( 2.0 * coords.at(1) - ( x1 + x2 ) ) / ( x2 - x1 );
138 answer.resize(1);
139 answer.at(1) = clamp(ksi, -1., 1.);
140 return fabs(ksi) <= 1.0;
141}
142
143double
144FEI1dHermite :: giveTransformationJacobian(const FloatArray &lcoords, const FEICellGeometry &cellgeo) const
145{
146 // This isn't really relevant, interpolation of geometry will be just linear
147 double l = this->giveLength(cellgeo);
148 return 0.5 * l;
149}
150
151double
152FEI1dHermite :: giveLength(const FEICellGeometry &cellgeo) const
153{
154 return fabs( cellgeo.giveVertexCoordinates(2).at(cindx) - cellgeo.giveVertexCoordinates(1).at(cindx) );
155}
156} // end namespace oofem
double giveLength(const FEICellGeometry &cellgeo) const override
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
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
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