OOFEM  2.4
OOFEM.org - Object Oriented Finite Element Solver
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 - 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 "fei1dquad.h"
36 #include "mathfem.h"
37 #include "floatmatrix.h"
38 #include "floatarray.h"
39 
40 namespace oofem {
41 void
42 FEI1dQuad :: evalN(FloatArray &answer, const FloatArray &lcoords, const FEICellGeometry &cellgeo)
43 {
44  double ksi = lcoords.at(1);
45  answer.resize(3);
46  answer.zero();
47 
48  answer.at(1) = ksi * ( ksi - 1. ) * 0.5;
49  answer.at(2) = ksi * ( 1. + ksi ) * 0.5;
50  answer.at(3) = ( 1. - ksi * ksi );
51 }
52 
53 double
54 FEI1dQuad :: evaldNdx(FloatMatrix &answer, const FloatArray &lcoords, const FEICellGeometry &cellgeo)
55 {
56  double J = this->giveTransformationJacobian(lcoords, cellgeo);
57  double ksi = lcoords.at(1);
58  answer.resize(1, 3);
59  answer.zero();
60 
61  answer.at(1, 1) = ( -1. / 2. + ksi ) / J;
62  answer.at(1, 2) = ( 1. / 2. + ksi ) / J;
63  answer.at(1, 3) = -2. * ksi / J;
64  return J;
65 }
66 
67 void
68 FEI1dQuad :: local2global(FloatArray &answer, const FloatArray &lcoords, const FEICellGeometry &cellgeo)
69 {
70  FloatArray n;
71  answer.resize(1);
72 
73  this->evalN(n, lcoords, cellgeo);
74  answer.at(1) = ( n.at(1) * cellgeo.giveVertexCoordinates(1)->at(cindx) +
75  n.at(2) * cellgeo.giveVertexCoordinates(2)->at(cindx) + n.at(3) * cellgeo.giveVertexCoordinates(3)->at(cindx) );
76 }
77 
78 int
79 FEI1dQuad :: global2local(FloatArray &answer, const FloatArray &coords, const FEICellGeometry &cellgeo)
80 {
81  double x1, x2, x3;
82  double a, b, c;
83 
84  x1 = cellgeo.giveVertexCoordinates(1)->at(cindx);
85  x2 = cellgeo.giveVertexCoordinates(2)->at(cindx);
86  x3 = cellgeo.giveVertexCoordinates(3)->at(cindx);
87 
88  a = 0.5 * ( x1 + x2 ) - x3;
89  b = 0.5 * ( x2 - x1 );
90  c = x3 - coords.at(1);
91 
92  answer.resize(1);
93  if ( fabs(a) < 1.e-6 ) {
94  double ksi = ( 2.0 * coords.at(1) - ( x1 + x2 ) ) / ( x2 - x1 );
95  answer.at(1) = clamp(ksi, -1., 1.);
96  return fabs(ksi) <= 1.0;
97  } else {
98  double ksi1 = ( -b + sqrt(b * b - 4. * a * c) ) / ( 2. * a );
99  double ksi2 = ( -b - sqrt(b * b - 4. * a * c) ) / ( 2. * a );
100 
101  if ( ( fabs(ksi1) <= 1. ) && ( fabs(ksi2) <= 1. ) ) { // Two roots, element must be bad
102  answer.at(1) = 0.;
103  return 0;
104  } else if ( fabs(ksi1) <= 1. ) {
105  answer.at(1) = ksi1;
106  return 1;
107  } else if ( fabs(ksi2) <= 1. ) {
108  answer.at(1) = ksi2;
109  return 1;
110  } else {
111  answer.at(1) = 0.;
112  return 0;
113  }
114  }
115 }
116 
117 double
119 {
120  double x1, x2, x3, J, ksi;
121 
122  x1 = cellgeo.giveVertexCoordinates(1)->at(cindx);
123  x2 = cellgeo.giveVertexCoordinates(2)->at(cindx);
124  x3 = cellgeo.giveVertexCoordinates(3)->at(cindx);
125  ksi = lcoords.at(1);
126 
127  J = 1. / 2. * ( 2 * ksi - 1 ) * x1 + 1. / 2. * ( 2 * ksi + 1 ) * x2 - 2. * ksi * x3;
128  return J;
129 }
130 
131 double
133 {
134  return fabs( cellgeo.giveVertexCoordinates(2)->at(cindx) - cellgeo.giveVertexCoordinates(1)->at(cindx) );
135 }
136 
137 
138 void FEI1dQuad :: boundaryEdgeGiveNodes(IntArray &answer, int boundary)
139 {
140  answer={1, 2, 3};
141 }
142 
143 void FEI1dQuad :: boundaryEdgeEvalN(FloatArray &answer, int boundary, const FloatArray &lcoords, const FEICellGeometry &cellgeo)
144 {
145  this->evalN(answer, lcoords, cellgeo);
146 }
147 
148 double FEI1dQuad :: boundaryEdgeGiveTransformationJacobian(int boundary, const FloatArray &lcoords, const FEICellGeometry &cellgeo)
149 {
150  return this->giveTransformationJacobian(lcoords, cellgeo);
151 }
152 
153 void FEI1dQuad :: boundaryEdgeLocal2Global(FloatArray &answer, int boundary, const FloatArray &lcoords, const FEICellGeometry &cellgeo)
154 {
155  this->local2global(answer, lcoords, cellgeo);
156 }
157 
158 
159 } // end namespace oofem
virtual double giveTransformationJacobian(const FloatArray &lcoords, const FEICellGeometry &cellgeo)
Evaluates the determinant of the transformation.
Definition: fei1dquad.C:118
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
Class implementing an array of integers.
Definition: intarray.h:61
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: fei1dquad.C:54
virtual void boundaryEdgeEvalN(FloatArray &answer, int boundary, const FloatArray &lcoords, const FEICellGeometry &cellgeo)
Evaluates the basis functions on the requested boundary.
Definition: fei1dquad.C:143
virtual void evalN(FloatArray &answer, const FloatArray &lcoords, const FEICellGeometry &cellgeo)
Evaluates the array of interpolation functions (shape functions) at given point.
Definition: fei1dquad.C:42
double at(int i, int j) const
Coefficient access function.
Definition: floatmatrix.h:176
virtual int global2local(FloatArray &answer, const FloatArray &lcoords, const FEICellGeometry &cellgeo)
Evaluates local coordinates from given global ones.
Definition: fei1dquad.C:79
virtual double boundaryEdgeGiveTransformationJacobian(int boundary, const FloatArray &lcoords, const FEICellGeometry &cellgeo)
Evaluates the determinant of the transformation Jacobian on the requested boundary.
Definition: fei1dquad.C:148
Class representing vector of real numbers.
Definition: floatarray.h:82
virtual double giveLength(const FEICellGeometry &cellgeo) const
Computes the exact length.
Definition: fei1dquad.C:132
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
virtual void local2global(FloatArray &answer, const FloatArray &lcoords, const FEICellGeometry &cellgeo)
Evaluates global coordinates from given local ones.
Definition: fei1dquad.C:68
virtual void boundaryEdgeLocal2Global(FloatArray &answer, int boundary, const FloatArray &lcoords, const FEICellGeometry &cellgeo)
Maps the local boundary coordinates to global.
Definition: fei1dquad.C:153
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 void boundaryEdgeGiveNodes(IntArray &answer, int boundary)
Gives the boundary nodes for requested boundary number.
Definition: fei1dquad.C:138
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