OOFEM  2.4
OOFEM.org - Object Oriented Finite Element Solver
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 - 2013 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 
40 namespace oofem {
41 void
42 FEI1dHermite :: evalN(FloatArray &answer, const FloatArray &lcoords, const FEICellGeometry &cellgeo)
43 {
44  double ksi = lcoords.at(1);
45  double l = this->giveLength(cellgeo);
46 
47  answer.resize(4);
48  answer.zero();
49 
50  answer.at(1) = 0.25 * ( 1.0 - ksi ) * ( 1.0 - ksi ) * ( 2.0 + ksi );
51  answer.at(2) = 0.125 * l * ( 1.0 - ksi ) * ( 1.0 - ksi ) * ( 1.0 + ksi );
52  answer.at(3) = 0.25 * ( 1.0 + ksi ) * ( 1.0 + ksi ) * ( 2.0 - ksi );
53  answer.at(4) = -0.125 * l * ( 1.0 + ksi ) * ( 1.0 + ksi ) * ( 1.0 - ksi );
54 }
55 
56 double
57 FEI1dHermite :: evaldNdx(FloatMatrix &answer, const FloatArray &lcoords, const FEICellGeometry &cellgeo)
58 {
59  double l = this->giveLength(cellgeo);
60  double l_inv = 1.0 / l;
61  double ksi = lcoords.at(1);
62 
63  answer.resize(1, 4);
64  answer.zero();
65 
66  answer.at(1, 1) = 1.5 * ( -1.0 + ksi * ksi ) * l_inv;
67  answer.at(1, 2) = 0.25 * ( ksi - 1.0 ) * ( 1.0 + 3.0 * ksi );
68  answer.at(1, 3) = -1.5 * ( -1.0 + ksi * ksi ) * l_inv;
69  answer.at(1, 4) = 0.25 * ( ksi - 1.0 ) * ( 1.0 + 3.0 * ksi );
70 
71  return 0.5 * l;
72 }
73 
74 void
75 FEI1dHermite :: evald2Ndx2(FloatMatrix &answer, const FloatArray &lcoords, const FEICellGeometry &cellgeo)
76 {
77  double l_inv = 1.0 / this->giveLength(cellgeo);
78  double ksi = lcoords.at(1);
79  answer.resize(1, 4);
80  answer.zero();
81 
82  answer.at(1, 1) = l_inv * 6.0 * ksi * l_inv;
83  answer.at(1, 2) = l_inv * ( 3.0 * ksi - 1.0 );
84  answer.at(1, 3) = -l_inv * 6.0 * ksi * l_inv;
85  answer.at(1, 4) = l_inv * ( 3.0 * ksi + 1.0 );
86 }
87 
88 void
89 FEI1dHermite :: local2global(FloatArray &answer, const FloatArray &lcoords, const FEICellGeometry &cellgeo)
90 {
91  FloatArray n;
92  answer.resize(1);
93 
94  this->evalN(n, lcoords, cellgeo);
95  answer.at(1) = ( n.at(1) * cellgeo.giveVertexCoordinates(1)->at(cindx) +
96  n.at(2) * cellgeo.giveVertexCoordinates(2)->at(cindx) + n.at(3) * cellgeo.giveVertexCoordinates(3)->at(cindx) );
97 }
98 
99 int
100 FEI1dHermite :: global2local(FloatArray &answer, const FloatArray &coords, const FEICellGeometry &cellgeo)
101 {
102  double ksi, x1, x2;
103  answer.resize(1);
104 
105  x1 = cellgeo.giveVertexCoordinates(1)->at(cindx);
106  x2 = cellgeo.giveVertexCoordinates(2)->at(cindx);
107 
108  ksi = ( 2.0 * coords.at(1) - ( x1 + x2 ) ) / ( x2 - x1 );
109  answer.at(1) = clamp(ksi, -1., 1.);
110  return fabs(ksi) <= 1.0;
111 }
112 
113 double
115 {
116  // This isn't really relevant, interpolation of geometry will be just linear
117  double l = this->giveLength(cellgeo);
118  return 0.5 * l;
119 }
120 
121 double
123 {
124  return fabs( cellgeo.giveVertexCoordinates(2)->at(cindx) - cellgeo.giveVertexCoordinates(1)->at(cindx) );
125 }
126 } // end namespace oofem
virtual void evalN(FloatArray &answer, const FloatArray &lcoords, const FEICellGeometry &cellgeo)
Evaluates the array of interpolation functions (shape functions) at given point.
Definition: fei1dhermite.C:42
double & at(int i)
Coefficient access function.
Definition: floatarray.h:131
virtual const FloatArray * giveVertexCoordinates(int i) const =0
Class representing a general abstraction for cell geometry.
Definition: feinterpol.h:62
virtual double giveLength(const FEICellGeometry &cellgeo) const
Computes the exact length.
Definition: fei1dhermite.C:122
virtual void local2global(FloatArray &answer, const FloatArray &lcoords, const FEICellGeometry &cellgeo)
Evaluates global coordinates from given local ones.
Definition: fei1dhermite.C:89
double at(int i, int j) const
Coefficient access function.
Definition: floatmatrix.h:176
virtual double evaldNdx(FloatMatrix &answer, const FloatArray &lcoords, const FEICellGeometry &cellgeo)
Evaluates the matrix of derivatives of interpolation functions (shape functions) at given point...
Definition: fei1dhermite.C:57
virtual double giveTransformationJacobian(const FloatArray &lcoords, const FEICellGeometry &cellgeo)
Evaluates the determinant of the transformation.
Definition: fei1dhermite.C:114
Class representing vector of real numbers.
Definition: floatarray.h:82
virtual void evald2Ndx2(FloatMatrix &answer, const FloatArray &lcoords, const FEICellGeometry &cellgeo)
Evaluates the matrix of second derivatives of interpolation functions (shape functions) at given poin...
Definition: fei1dhermite.C:75
Implementation of matrix containing floating point numbers.
Definition: floatmatrix.h:94
double clamp(int a, int lower, int upper)
Returns the clamped value of a between upper and lower.
Definition: mathfem.h:75
void resize(int rows, int cols)
Checks size of receiver towards requested bounds.
Definition: floatmatrix.C:1358
void zero()
Zeroes all coefficients of receiver.
Definition: floatarray.C:658
void zero()
Zeroes all coefficient of receiver.
Definition: floatmatrix.C:1326
virtual int global2local(FloatArray &answer, const FloatArray &lcoords, const FEICellGeometry &cellgeo)
Evaluates local coordinates from given global ones.
Definition: fei1dhermite.C:100
the oofem namespace is to define a context or scope in which all oofem names are defined.
void resize(int s)
Resizes receiver towards requested size.
Definition: floatarray.C:631

This page is part of the OOFEM documentation. Copyright (c) 2011 Borek Patzak
Project e-mail: info@oofem.org
Generated at Tue Jan 2 2018 20:07:28 for OOFEM by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2011