OOFEM  2.4
OOFEM.org - Object Oriented Finite Element Solver
fei2dtrconst.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 "fei2dtrconst.h"
36 #include "mathfem.h"
37 #include "floatmatrix.h"
38 #include "floatarray.h"
39 
40 namespace oofem {
41 void
42 FEI2dTrConst :: evalN(FloatArray &answer, const FloatArray &lcoords, const FEICellGeometry &cellgeo)
43 {
44  answer = FloatArray{1.};
45 }
46 
47 double
48 FEI2dTrConst :: evaldNdx(FloatMatrix &answer, const FloatArray &lcoords, const FEICellGeometry &cellgeo)
49 {
50  answer.resize(1, 2);
51  answer.zero();
52 
53  return 0.0;
54 }
55 
56 void
57 FEI2dTrConst :: local2global(FloatArray &answer, const FloatArray &lcoords, const FEICellGeometry &cellgeo)
58 {
59  double l1, l2, l3;
60 
61  l1 = lcoords.at(1);
62  l2 = lcoords.at(2);
63  l3 = 1.0 - l1 - l2;
64 
65  answer.resize(2);
66  answer.at(1) = ( l1 * cellgeo.giveVertexCoordinates(1)->at(xind) +
67  l2 * cellgeo.giveVertexCoordinates(2)->at(xind) +
68  l3 * cellgeo.giveVertexCoordinates(3)->at(xind) );
69  answer.at(2) = ( l1 * cellgeo.giveVertexCoordinates(1)->at(yind) +
70  l2 * cellgeo.giveVertexCoordinates(2)->at(yind) +
71  l3 * cellgeo.giveVertexCoordinates(3)->at(yind) );
72 }
73 
74 #define POINT_TOL 1.e-3
75 
76 int
77 FEI2dTrConst :: global2local(FloatArray &answer, const FloatArray &coords, const FEICellGeometry &cellgeo)
78 {
79  double detJ, x1, x2, x3, y1, y2, y3;
80 
81  x1 = cellgeo.giveVertexCoordinates(1)->at(xind);
82  x2 = cellgeo.giveVertexCoordinates(2)->at(xind);
83  x3 = cellgeo.giveVertexCoordinates(3)->at(xind);
84 
85  y1 = cellgeo.giveVertexCoordinates(1)->at(yind);
86  y2 = cellgeo.giveVertexCoordinates(2)->at(yind);
87  y3 = cellgeo.giveVertexCoordinates(3)->at(yind);
88 
89  detJ = ( x2 * y3 + x1 * y2 + y1 * x3 - x2 * y1 - x3 * y2 - x1 * y3 );
90 
91  answer.resize(3);
92  answer.at(1) = ( ( x2 * y3 - x3 * y2 ) + ( y2 - y3 ) * coords.at(xind) + ( x3 - x2 ) * coords.at(yind) ) / detJ;
93  answer.at(2) = ( ( x3 * y1 - x1 * y3 ) + ( y3 - y1 ) * coords.at(xind) + ( x1 - x3 ) * coords.at(yind) ) / detJ;
94  //answer.at(3) = ( ( x1 * y2 - x2 * y1 ) + ( y1 - y2 ) * coords.at(xind) + ( x2 - x1 ) * coords.at(yind) ) / detJ;
95 
96  // check if point is inside
97  bool inside = true;
98  for ( int i = 1; i <= 2; i++ ) {
99  if ( answer.at(i) < ( 0. - POINT_TOL ) ) {
100  answer.at(i) = 0.;
101  inside = false;
102  } else if ( answer.at(i) > ( 1. + POINT_TOL ) ) {
103  answer.at(i) = 1.;
104  inside = false;
105  }
106  }
107  answer.at(3) = 1. - answer.at(1) - answer.at(2);
108 
109  return inside;
110 }
111 
112 
113 double
115 {
116  double x1, x2, x3, y1, y2, y3;
117 
118  x1 = cellgeo.giveVertexCoordinates(1)->at(xind);
119  x2 = cellgeo.giveVertexCoordinates(2)->at(xind);
120  x3 = cellgeo.giveVertexCoordinates(3)->at(xind);
121 
122  y1 = cellgeo.giveVertexCoordinates(1)->at(yind);
123  y2 = cellgeo.giveVertexCoordinates(2)->at(yind);
124  y3 = cellgeo.giveVertexCoordinates(3)->at(yind);
125 
126  return x1 * ( y2 - y3 ) + x2 * ( -y1 + y3 ) + x3 * ( y1 - y2 );
127 }
128 
129 
130 void
131 FEI2dTrConst :: edgeEvalN(FloatArray &answer, int iedge, const FloatArray &lcoords, const FEICellGeometry &cellgeo)
132 {
133  answer.resize(1);
134  answer.at(1) = 1.;
135 }
136 
137 double
138 FEI2dTrConst :: edgeEvalNormal(FloatArray &answer, int iedge, const FloatArray &lcoords, const FEICellGeometry &cellgeo)
139 {
140  OOFEM_ERROR("Not applicable to constant interpolation");
141  return 0.;
142 }
143 
144 void
146  const FloatArray &lcoords, const FEICellGeometry &cellgeo)
147 {
148  answer = { 0., 0. };
149 }
150 
151 void
153  const FloatArray &lcoords, const FEICellGeometry &cellgeo)
154 {
155  IntArray edgeNodes;
156  FloatArray n = { ( 1 - lcoords(0) ) * 0.5, ( 1 + lcoords(0) ) * 0.5 };
157  this->computeLocalEdgeMapping(edgeNodes, iedge);
158 
159  answer.resize(2);
160  answer.at(1) = ( n.at(1) * cellgeo.giveVertexCoordinates( edgeNodes.at(1) )->at(xind) +
161  n.at(2) * cellgeo.giveVertexCoordinates( edgeNodes.at(2) )->at(xind) );
162  answer.at(2) = ( n.at(1) * cellgeo.giveVertexCoordinates( edgeNodes.at(1) )->at(yind) +
163  n.at(2) * cellgeo.giveVertexCoordinates( edgeNodes.at(2) )->at(yind) );
164 }
165 
166 void
168 {
169  int aNode = 0, bNode = 0;
170  edgeNodes.resize(2);
171 
172  if ( iedge == 1 ) { // edge between nodes 1 2
173  aNode = 1;
174  bNode = 2;
175  } else if ( iedge == 2 ) { // edge between nodes 2 3
176  aNode = 2;
177  bNode = 3;
178  } else if ( iedge == 3 ) { // edge between nodes 2 3
179  aNode = 3;
180  bNode = 1;
181  } else {
182  OOFEM_ERROR("wrong egde number (%d)", iedge);
183  }
184 
185  edgeNodes.at(1) = aNode;
186  edgeNodes.at(2) = bNode;
187 }
188 
189 double
191 {
192  double dx, dy;
193  int nodeA, nodeB;
194 
195  nodeA = edgeNodes.at(1);
196  nodeB = edgeNodes.at(2);
197 
198  dx = cellgeo.giveVertexCoordinates(nodeB)->at(xind) - cellgeo.giveVertexCoordinates(nodeA)->at(xind);
199  dy = cellgeo.giveVertexCoordinates(nodeB)->at(yind) - cellgeo.giveVertexCoordinates(nodeA)->at(yind);
200  return sqrt(dx * dx + dy * dy);
201 }
202 
205 {
206  IntegrationRule *iRule = new GaussIntegrationRule(1, NULL);
207  int points = iRule->getRequiredNumberOfIntegrationPoints(_Triangle, order + 0);
208  iRule->SetUpPointsOnTriangle(points, _Unknown);
209  return iRule;
210 }
211 } // end namespace oofem
virtual void local2global(FloatArray &answer, const FloatArray &lcoords, const FEICellGeometry &cellgeo)
Evaluates global coordinates from given local ones.
Definition: fei2dtrconst.C:57
double & at(int i)
Coefficient access function.
Definition: floatarray.h:131
virtual const FloatArray * giveVertexCoordinates(int i) const =0
virtual double edgeEvalNormal(FloatArray &answer, int iedge, const FloatArray &lcoords, const FEICellGeometry &cellgeo)
Evaluates the normal on the given edge.
Definition: fei2dtrconst.C:138
Class representing a general abstraction for cell geometry.
Definition: feinterpol.h:62
Class implementing an array of integers.
Definition: intarray.h:61
int & at(int i)
Coefficient access function.
Definition: intarray.h:103
Abstract base class representing integration rule.
virtual void edgeLocal2global(FloatArray &answer, int iedge, const FloatArray &lcoords, const FEICellGeometry &cellgeo)
Evaluates edge global coordinates from given local ones.
Definition: fei2dtrconst.C:152
virtual void edgeEvalN(FloatArray &answer, int iedge, const FloatArray &lcoords, const FEICellGeometry &cellgeo)
Evaluates the array of edge interpolation functions (shape functions) at given point.
Definition: fei2dtrconst.C:131
virtual int global2local(FloatArray &answer, const FloatArray &lcoords, const FEICellGeometry &cellgeo)
Default implementation using Newton&#39;s method to find the local coordinates.
Definition: fei2dtrconst.C:77
#define OOFEM_ERROR(...)
Definition: error.h:61
virtual void computeLocalEdgeMapping(IntArray &edgeNodes, int iedge)
Definition: fei2dtrconst.C:167
double edgeComputeLength(IntArray &edgeNodes, const FEICellGeometry &cellgeo)
Definition: fei2dtrconst.C:190
void resize(int n)
Checks size of receiver towards requested bounds.
Definition: intarray.C:124
Class representing vector of real numbers.
Definition: floatarray.h:82
Implementation of matrix containing floating point numbers.
Definition: floatmatrix.h:94
virtual void evalN(FloatArray &answer, const FloatArray &lcoords, const FEICellGeometry &cellgeo)
Evaluates the array of interpolation functions (shape functions) at given point.
Definition: fei2dtrconst.C:42
void resize(int rows, int cols)
Checks size of receiver towards requested bounds.
Definition: floatmatrix.C:1358
virtual int getRequiredNumberOfIntegrationPoints(integrationDomain dType, int approxOrder)
Abstract service.
#define POINT_TOL
Definition: fei2dtrconst.C:74
virtual bool inside(const FloatArray &lcoords) const
Definition: feinterpol2d.C:134
virtual int SetUpPointsOnTriangle(int, MaterialMode mode)
Sets up receiver&#39;s integration points on triangular (area coords) integration domain.
void zero()
Zeroes all coefficient of receiver.
Definition: floatmatrix.C:1326
virtual IntegrationRule * giveIntegrationRule(int order)
Sets up a suitable integration rule for numerical integrating over volume.
Definition: fei2dtrconst.C:204
the oofem namespace is to define a context or scope in which all oofem names are defined.
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: fei2dtrconst.C:48
virtual double giveTransformationJacobian(const FloatArray &lcoords, const FEICellGeometry &cellgeo)
Evaluates the determinant of the transformation.
Definition: fei2dtrconst.C:114
Class representing Gaussian-quadrature integration rule.
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...
Definition: fei2dtrconst.C:145
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