OOFEM 3.0
Loading...
Searching...
No Matches
fei1dquad.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 "fei1dquad.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
45FEI1dQuad :: evalN(double ksi)
46{
47 return {ksi * ( ksi - 1. ) * 0.5, ksi * ( 1. + ksi ) * 0.5, ( 1. - ksi * ksi )};
48}
49
50void
51FEI1dQuad :: evalN(FloatArray &answer, const FloatArray &lcoords, const FEICellGeometry &cellgeo) const
52{
53#if 0
54 answer = evalN(lcoords[0]);
55#else
56 double ksi = lcoords.at(1);
57 answer.resize(3);
58 answer.zero();
59
60 answer.at(1) = ksi * ( ksi - 1. ) * 0.5;
61 answer.at(2) = ksi * ( 1. + ksi ) * 0.5;
62 answer.at(3) = ( 1. - ksi * ksi );
63#endif
64}
65
66std::pair<double, FloatMatrixF<1,3>>
67FEI1dQuad :: evaldNdx(double ksi, const FEICellGeometry &cellgeo) const
68{
69 double x1 = cellgeo.giveVertexCoordinates(1).at(cindx);
70 double x2 = cellgeo.giveVertexCoordinates(2).at(cindx);
71 double x3 = cellgeo.giveVertexCoordinates(3).at(cindx);
72
73 double J = 1. / 2. * ( 2 * ksi - 1 ) * x1 + 1. / 2. * ( 2 * ksi + 1 ) * x2 - 2. * ksi * x3;
74
75 FloatMatrixF<1, 3> ans = {
76 ( -1. / 2. + ksi ) / J,
77 ( 1. / 2. + ksi ) / J,
78 -2. * ksi / J,
79 };
80 return {J, ans};
81}
82
83
84double
85FEI1dQuad :: evaldNdx(FloatMatrix &answer, const FloatArray &lcoords, const FEICellGeometry &cellgeo) const
86{
87 double J = this->giveTransformationJacobian(lcoords, cellgeo);
88 double ksi = lcoords.at(1);
89 answer.resize(1, 3);
90 answer.zero();
91
92 answer.at(1, 1) = ( -1. / 2. + ksi ) / J;
93 answer.at(1, 2) = ( 1. / 2. + ksi ) / J;
94 answer.at(1, 3) = -2. * ksi / J;
95 return J;
96}
97
98void
99FEI1dQuad :: local2global(FloatArray &answer, const FloatArray &lcoords, const FEICellGeometry &cellgeo) const
100{
101 FloatArray n;
102 answer.resize(1);
103
104 this->evalN(n, lcoords, cellgeo);
105 answer.at(1) = n.at(1) * cellgeo.giveVertexCoordinates(1).at(cindx) +
106 n.at(2) * cellgeo.giveVertexCoordinates(2).at(cindx) +
107 n.at(3) * cellgeo.giveVertexCoordinates(3).at(cindx);
108}
109
110int
111FEI1dQuad :: global2local(FloatArray &answer, const FloatArray &coords, const FEICellGeometry &cellgeo) const
112{
113 double x1 = cellgeo.giveVertexCoordinates(1).at(cindx);
114 double x2 = cellgeo.giveVertexCoordinates(2).at(cindx);
115 double x3 = cellgeo.giveVertexCoordinates(3).at(cindx);
116
117 double a = 0.5 * ( x1 + x2 ) - x3;
118 double b = 0.5 * ( x2 - x1 );
119 double c = x3 - coords.at(1);
120
121 answer.resize(1);
122 if ( fabs(a) < 1.e-6 ) {
123 double ksi = ( 2.0 * coords.at(1) - ( x1 + x2 ) ) / ( x2 - x1 );
124 answer.at(1) = clamp(ksi, -1., 1.);
125 return fabs(ksi) <= 1.0;
126 } else {
127 double ksi1 = ( -b + sqrt(b * b - 4. * a * c) ) / ( 2. * a );
128 double ksi2 = ( -b - sqrt(b * b - 4. * a * c) ) / ( 2. * a );
129
130 if ( ( fabs(ksi1) <= 1. ) && ( fabs(ksi2) <= 1. ) ) { // Two roots, element must be bad
131 answer.at(1) = 0.;
132 return 0;
133 } else if ( fabs(ksi1) <= 1. ) {
134 answer.at(1) = ksi1;
135 return 1;
136 } else if ( fabs(ksi2) <= 1. ) {
137 answer.at(1) = ksi2;
138 return 1;
139 } else {
140 answer.at(1) = 0.;
141 return 0;
142 }
143 }
144}
145
146double
147FEI1dQuad :: giveTransformationJacobian(const FloatArray &lcoords, const FEICellGeometry &cellgeo) const
148{
149 double x1 = cellgeo.giveVertexCoordinates(1).at(cindx);
150 double x2 = cellgeo.giveVertexCoordinates(2).at(cindx);
151 double x3 = cellgeo.giveVertexCoordinates(3).at(cindx);
152 double ksi = lcoords.at(1);
153
154 double J = 1. / 2. * ( 2 * ksi - 1 ) * x1 + 1. / 2. * ( 2 * ksi + 1 ) * x2 - 2. * ksi * x3;
155 return J;
156}
157
158double
159FEI1dQuad :: giveLength(const FEICellGeometry &cellgeo) const
160{
161 return fabs( cellgeo.giveVertexCoordinates(2).at(cindx) - cellgeo.giveVertexCoordinates(1).at(cindx) );
162}
163
164
165IntArray FEI1dQuad :: boundaryEdgeGiveNodes(int boundary, Element_Geometry_Type egt, bool includeHierarchical) const
166{
167 return {1, 2, 3};
168}
169
170void FEI1dQuad :: boundaryEdgeEvalN(FloatArray &answer, int boundary, const FloatArray &lcoords, const FEICellGeometry &cellgeo) const
171{
172 this->evalN(answer, lcoords, cellgeo);
173}
174
175double FEI1dQuad :: boundaryEdgeGiveTransformationJacobian(int boundary, const FloatArray &lcoords, const FEICellGeometry &cellgeo) const
176{
177 return this->giveTransformationJacobian(lcoords, cellgeo);
178}
179
180void FEI1dQuad :: boundaryEdgeLocal2Global(FloatArray &answer, int boundary, const FloatArray &lcoords, const FEICellGeometry &cellgeo) const
181{
182 this->local2global(answer, lcoords, cellgeo);
183}
184
185
186} // end namespace oofem
double giveTransformationJacobian(const FloatArray &lcoords, const FEICellGeometry &cellgeo) const override
Definition fei1dquad.C:147
static FloatArrayF< 3 > evalN(double ksi)
Definition fei1dquad.C:45
void local2global(FloatArray &answer, const FloatArray &lcoords, const FEICellGeometry &cellgeo) const override
Definition fei1dquad.C:99
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