OOFEM  2.4
OOFEM.org - Object Oriented Finite Element Solver
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 - 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 "fei2dlinehermite.h"
36 #include "mathfem.h"
37 #include "floatmatrix.h"
38 #include "floatarray.h"
39 
40 namespace oofem {
41 double FEI2dLineHermite :: giveLength(const FEICellGeometry &cellgeo) const
42 {
43  double x2_x1, y2_y1;
44  x2_x1 = cellgeo.giveVertexCoordinates(2)->at(xind) - cellgeo.giveVertexCoordinates(1)->at(xind);
45  y2_y1 = cellgeo.giveVertexCoordinates(2)->at(yind) - cellgeo.giveVertexCoordinates(1)->at(yind);
46  return sqrt(x2_x1 * x2_x1 + y2_y1 * y2_y1);
47 }
48 
49 void FEI2dLineHermite :: evalN(FloatArray &answer, const FloatArray &lcoords, const FEICellGeometry &cellgeo)
50 {
51  double ksi = lcoords.at(1);
52  double l = this->giveLength(cellgeo);
53 
54  answer.resize(4);
55  answer.zero();
56 
57  answer.at(1) = 0.25 * ( 1.0 - ksi ) * ( 1.0 - ksi ) * ( 2.0 + ksi );
58  answer.at(2) = 0.125 * l * ( 1.0 - ksi ) * ( 1.0 - ksi ) * ( 1.0 + ksi );
59  answer.at(3) = 0.25 * ( 1.0 + ksi ) * ( 1.0 + ksi ) * ( 2.0 - ksi );
60  answer.at(4) = -0.125 * l * ( 1.0 + ksi ) * ( 1.0 + ksi ) * ( 1.0 - ksi );
61 }
62 
63 double FEI2dLineHermite :: evaldNdx(FloatMatrix &answer, const FloatArray &lcoords, const FEICellGeometry &cellgeo)
64 {
65  // 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.
66  FloatArray dNds;
67  this->edgeEvaldNds(dNds, 1, lcoords, cellgeo);
68  // Tangent line to project on
69  FloatArray vec(2);
70  vec.at(1) = cellgeo.giveVertexCoordinates(2)->at(xind) - cellgeo.giveVertexCoordinates(1)->at(xind);
71  vec.at(2) = cellgeo.giveVertexCoordinates(2)->at(yind) - cellgeo.giveVertexCoordinates(1)->at(yind);
72  double detJ = vec.normalize() * 0.5;
73 
74  answer.beDyadicProductOf(dNds, vec);
75  return detJ;
76 }
77 
78 void FEI2dLineHermite :: local2global(FloatArray &answer, const FloatArray &lcoords, const FEICellGeometry &cellgeo)
79 {
80  FloatArray n;
81  this->evalN(n, lcoords, cellgeo);
82  answer.resize( max(xind, yind) );
83  answer.zero();
84  answer.at(xind) = ( n.at(1) * cellgeo.giveVertexCoordinates(1)->at(xind) +
85  n.at(2) * cellgeo.giveVertexCoordinates(2)->at(xind) );
86  answer.at(yind) = ( n.at(1) * cellgeo.giveVertexCoordinates(1)->at(yind) +
87  n.at(2) * cellgeo.giveVertexCoordinates(2)->at(yind) );
88 }
89 
90 int FEI2dLineHermite :: global2local(FloatArray &answer, const FloatArray &gcoords, const FEICellGeometry &cellgeo)
91 {
92  double xi;
93  double x2_x1, y2_y1;
94 
95  x2_x1 = cellgeo.giveVertexCoordinates(2)->at(xind) - cellgeo.giveVertexCoordinates(1)->at(xind);
96  y2_y1 = cellgeo.giveVertexCoordinates(2)->at(yind) - cellgeo.giveVertexCoordinates(1)->at(yind);
97 
98  // Projection of the global coordinate gives the value interpolated in [0,1].
99  xi = ( x2_x1 * gcoords(0) + y2_y1 * gcoords(1) ) / ( sqrt(x2_x1 * x2_x1 + y2_y1 * y2_y1) );
100  // Map to [-1,1] domain.
101  xi = xi * 2.0 - 1.0;
102 
103  answer.resize(1);
104  answer(0) = clamp(xi, -1., 1.);
105  return false;
106 }
107 
108 void FEI2dLineHermite :: edgeEvaldNds(FloatArray &answer, int iedge, const FloatArray &lcoords, const FEICellGeometry &cellgeo)
109 {
110  double l_inv = this->giveLength(cellgeo);
111  double ksi = lcoords.at(1);
112 
113  answer.resize(4);
114  answer.zero();
115 
116  answer.at(1) = 1.5 * ( ksi * ksi - 1.0 ) * l_inv;
117  answer.at(2) = 0.25 * ( ksi - 1.0 ) * ( 3.0 * ksi + 1.0 );
118  answer.at(3) = -1.5 * ( ksi * ksi - 1.0 ) * l_inv;
119  answer.at(4) = 0.25 * ( ksi + 1.0 ) * ( 3.0 * ksi - 1.0 );
120 }
121 
122 void FEI2dLineHermite :: edgeEvald2Nds2(FloatArray &answer, int iedge, const FloatArray &lcoords, const FEICellGeometry &cellgeo)
123 {
124  double l_inv = this->giveLength(cellgeo);
125  double ksi = lcoords.at(1);
126 
127  answer.resize(4);
128  answer.zero();
129 
130  answer.at(1) = l_inv * 6.0 * ksi * l_inv;
131  answer.at(2) = l_inv * ( 3.0 * ksi - 1.0 );
132  answer.at(3) = -l_inv * 6.0 * ksi * l_inv;
133  answer.at(4) = l_inv * ( 3.0 * ksi + 1.0 );
134 }
135 
136 double FEI2dLineHermite :: edgeEvalNormal(FloatArray &normal, int iedge, const FloatArray &lcoords, const FEICellGeometry &cellgeo)
137 {
138  normal.resize(2);
139  normal.at(1) = cellgeo.giveVertexCoordinates(2)->at(xind) - cellgeo.giveVertexCoordinates(1)->at(xind);
140  normal.at(2) = -( cellgeo.giveVertexCoordinates(2)->at(yind) - cellgeo.giveVertexCoordinates(1)->at(yind) );
141 
142  return normal.normalize() * 0.5;
143 }
144 
146 {
147  double x2_x1, y2_y1;
148  x2_x1 = cellgeo.giveVertexCoordinates(2)->at(xind) - cellgeo.giveVertexCoordinates(1)->at(xind);
149  y2_y1 = cellgeo.giveVertexCoordinates(2)->at(yind) - cellgeo.giveVertexCoordinates(1)->at(yind);
150  return sqrt(x2_x1 * x2_x1 + y2_y1 * y2_y1) * 0.5;
151 }
152 
154 {
155  OOFEM_ERROR("Not supported.");
156  return NULL;
157 }
158 } // end namespace oofem
virtual double evaldNdx(FloatMatrix &answer, const FloatArray &lcoords, const FEICellGeometry &cellgeo)
Evaluates the matrix of derivatives of interpolation functions (shape functions) at given point...
virtual void edgeEvaldNds(FloatArray &answer, int iedge, const FloatArray &lcoords, const FEICellGeometry &cellgeo)
Evaluates the matrix of derivatives of edge interpolation functions (shape functions) at given point...
double & at(int i)
Coefficient access function.
Definition: floatarray.h:131
int max(int i, int j)
Returns bigger value form two given decimals.
Definition: mathfem.h:71
virtual const FloatArray * giveVertexCoordinates(int i) const =0
Class representing a general abstraction for cell geometry.
Definition: feinterpol.h:62
virtual void edgeEvald2Nds2(FloatArray &answer, int iedge, const FloatArray &lcoords, const FEICellGeometry &cellgeo)
virtual void local2global(FloatArray &answer, const FloatArray &lcoords, const FEICellGeometry &cellgeo)
Evaluates global coordinates from given local ones.
virtual int global2local(FloatArray &answer, const FloatArray &gcoords, const FEICellGeometry &cellgeo)
Default implementation using Newton's method to find the local coordinates.
Abstract base class representing integration rule.
#define OOFEM_ERROR(...)
Definition: error.h:61
virtual double giveTransformationJacobian(const FloatArray &lcoords, const FEICellGeometry &cellgeo)
Evaluates the determinant of the transformation.
Class representing vector of real numbers.
Definition: floatarray.h:82
virtual double giveLength(const FEICellGeometry &cellgeo) const
virtual double edgeEvalNormal(FloatArray &normal, int iedge, const FloatArray &lcoords, const FEICellGeometry &cellgeo)
Evaluates the normal on the given edge.
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 zero()
Zeroes all coefficients of receiver.
Definition: floatarray.C:658
void beDyadicProductOf(const FloatArray &vec1, const FloatArray &vec2)
Assigns to the receiver the dyadic product .
Definition: floatmatrix.C:492
the oofem namespace is to define a context or scope in which all oofem names are defined.
double normalize()
Normalizes receiver.
Definition: floatarray.C:828
virtual IntegrationRule * giveIntegrationRule(int order)
Sets up a suitable integration rule for numerical integrating over volume.
virtual void evalN(FloatArray &answer, const FloatArray &lcoords, const FEICellGeometry &cellgeo)
Evaluates the array of interpolation functions (shape functions) at given point.
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