OOFEM  2.4
OOFEM.org - Object Oriented Finite Element Solver
fei3dtrquad.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 "fei3dtrquad.h"
36 #include "mathfem.h"
37 #include "floatmatrix.h"
38 #include "floatarray.h"
39 #include "gaussintegrationrule.h"
40 
41 namespace oofem {
42 void
43 FEI3dTrQuad :: evalN(FloatArray &answer, const FloatArray &lcoords, const FEICellGeometry &cellgeo)
44 {
45  this->surfaceEvalN(answer, 1, lcoords, cellgeo);
46 }
47 
48 double
49 FEI3dTrQuad :: evaldNdx(FloatMatrix &answer, const FloatArray &lcoords, const FEICellGeometry &cellgeo)
50 {
51  OOFEM_ERROR("FEI3dTrQuad :: evaldNdx - Not supported");
52  return 0.;
53 }
54 
55 
56 void
57 FEI3dTrQuad :: evaldNdxi(FloatMatrix &answer, const FloatArray &lcoords, const FEICellGeometry &cellgeo)
58 {
59  this->surfaceEvaldNdxi(answer, lcoords);
60 }
61 
62 
63 void
65 {
66  double l1, l2, l3;
67 
68  l1 = lc.at(1);
69  l2 = lc.at(2);
70  l3 = 1.0 - l1 - l2;
71 
72  n.resize(6);
73 
74  n.at(1) = 4.0 * l1 - 1.0;
75  n.at(2) = 0.0;
76  n.at(3) = -1.0 * ( 4.0 * l3 - 1.0 );
77  n.at(4) = 4.0 * l2;
78  n.at(5) = -4.0 * l2;
79  n.at(6) = 4.0 * l3 - 4.0 * l1;
80 }
81 
82 void
84 {
85  double l1, l2, l3;
86 
87  l1 = lc.at(1);
88  l2 = lc.at(2);
89  l3 = 1.0 - l1 - l2;
90 
91  n.resize(6);
92 
93  n.at(1) = 0.0;
94  n.at(2) = 4.0 * l2 - 1.0;
95  n.at(3) = -1.0 * ( 4.0 * l3 - 1.0 );
96  n.at(4) = 4.0 * l1;
97  n.at(5) = 4.0 * l3 - 4.0 * l2;
98  n.at(6) = -4.0 * l1;
99 }
100 
101 
102 void
104 {
105 
106  answer.resize(3,6);
107  answer.zero();
108  answer.at(1,1) = 1.0;
109  answer.at(1,2) = 0.0;
110  answer.at(1,3) = 0.0;
111  answer.at(1,4) = 0.5;
112  answer.at(1,5) = 0.0;
113  answer.at(1,6) = 0.5;
114 
115  answer.at(2,1) = 0.0;
116  answer.at(2,2) = 1.0;
117  answer.at(2,3) = 0.0;
118  answer.at(2,4) = 0.5;
119  answer.at(2,5) = 0.5;
120  answer.at(2,6) = 0.0;
121 
122 }
123 
124 
125 void
126 FEI3dTrQuad :: local2global(FloatArray &answer, const FloatArray &lcoords, const FEICellGeometry &cellgeo)
127 {
128  FloatArray n;
129  this->evalN(n, lcoords, cellgeo);
130  answer.clear();
131  for ( int i = 1; i <= 6; ++i ) {
132  answer.add( n.at(i), * cellgeo.giveVertexCoordinates(i) );
133  }
134 }
135 
136 #define POINT_TOL 1.e-3
137 int
138 FEI3dTrQuad :: global2local(FloatArray &answer, const FloatArray &gcoords, const FEICellGeometry &cellgeo)
139 {
140  //OOFEM_ERROR("FEI3dTrQuad :: global2local - Not supported");
141  //return -1;
142 
144  int xind = 1;
145  int yind = 2;
146 
147 
148  double detJ, x1, x2, x3, y1, y2, y3;
149  answer.resize(3);
150 
151  x1 = cellgeo.giveVertexCoordinates(1)->at(xind);
152  x2 = cellgeo.giveVertexCoordinates(2)->at(xind);
153  x3 = cellgeo.giveVertexCoordinates(3)->at(xind);
154 
155  y1 = cellgeo.giveVertexCoordinates(1)->at(yind);
156  y2 = cellgeo.giveVertexCoordinates(2)->at(yind);
157  y3 = cellgeo.giveVertexCoordinates(3)->at(yind);
158 
159  detJ = x1*(y2 - y3) + x2*(-y1 + y3) + x3*(y1 - y2);
160 
161  answer.at(1) = ( ( x2 * y3 - x3 * y2 ) + ( y2 - y3 ) * gcoords.at(xind) + ( x3 - x2 ) * gcoords.at(yind) ) / detJ;
162  answer.at(2) = ( ( x3 * y1 - x1 * y3 ) + ( y3 - y1 ) * gcoords.at(xind) + ( x1 - x3 ) * gcoords.at(yind) ) / detJ;
163  answer.at(3) = 1. - answer.at(1) - answer.at(2);
164 
165  // check if point is inside
166  bool inside = true;
167  for ( int i = 1; i <= 3; i++ ) {
168  if ( answer.at(i) < ( 0. - POINT_TOL ) ) {
169  answer.at(i) = 0.;
170  inside = false;
171  } else if ( answer.at(i) > ( 1. + POINT_TOL ) ) {
172  answer.at(i) = 1.;
173  inside = false;
174  }
175  }
176 
177  return inside;
178 
179 }
180 
181 
182 void
183 FEI3dTrQuad :: giveJacobianMatrixAt(FloatMatrix &jacobianMatrix, const FloatArray &lcoords, const FEICellGeometry &cellgeo)
184 {
185  OOFEM_ERROR("Not supported");
186 }
187 
188 
189 void
190 FEI3dTrQuad :: edgeEvalN(FloatArray &answer, int iedge, const FloatArray &lcoords, const FEICellGeometry &cellgeo)
191 {
192  double xi = lcoords.at(1);
193  answer.resize(3);
194  answer(0) = 0.5 * ( xi - 1.0 ) * xi;
195  answer(1) = 0.5 * ( xi + 1.0 ) * xi;
196  answer(2) = 1.0 - xi * xi;
197 }
198 
199 
200 
201 void
203  const FloatArray &lcoords, const FEICellGeometry &cellgeo)
204 {
205  OOFEM_ERROR("Not supported");
206 }
207 
208 void
209 FEI3dTrQuad :: edgeEvaldNdxi(FloatArray &answer, int iedge, const FloatArray &lcoords, const FEICellGeometry &cellgeo)
210 {
211  double xi = lcoords.at(1);
212  answer.resize(3);
213  answer(0) = xi - 0.5;
214  answer(1) = xi + 0.5;
215  answer(2) = -2 * xi;
216 }
217 
218 void
220  const FloatArray &lcoords, const FEICellGeometry &cellgeo)
221 {
222  IntArray edgeNodes;
223  FloatArray N;
224  this->computeLocalEdgeMapping(edgeNodes, iedge);
225  this->edgeEvalN(N, iedge, lcoords, cellgeo);
226 
227  answer.clear();
228  for ( int i = 0; i < N.giveSize(); ++i ) {
229  answer.add( N(i), * cellgeo.giveVertexCoordinates( edgeNodes(i) ) );
230  }
231 }
232 
233 
234 double
236 {
237  IntArray eNodes;
238  FloatArray dNdu;
239  double u = lcoords.at(1);
240  this->computeLocalEdgeMapping(eNodes, iedge);
241  dNdu.add( u - 0.5, * cellgeo.giveVertexCoordinates( eNodes.at(1) ) );
242  dNdu.add( u + 0.5, * cellgeo.giveVertexCoordinates( eNodes.at(2) ) );
243  dNdu.add( -2. * u, * cellgeo.giveVertexCoordinates( eNodes.at(3) ) );
244  return dNdu.computeNorm();
245 }
246 
247 
248 void
250 {
251  int aNode = 0, bNode = 0, cNode = 0;
252  edgeNodes.resize(3);
253 
254  if ( iedge == 1 ) { // edge between nodes 1 2
255  aNode = 1;
256  bNode = 2;
257  cNode = 4;
258  } else if ( iedge == 2 ) { // edge between nodes 2 3
259  aNode = 2;
260  bNode = 3;
261  cNode = 5;
262  } else if ( iedge == 3 ) { // edge between nodes 2 3
263  aNode = 3;
264  bNode = 1;
265  cNode = 6;
266  } else {
267  OOFEM_ERROR("Wrong edge number (%d)", iedge);
268  }
269 
270  edgeNodes.at(1) = aNode;
271  edgeNodes.at(2) = bNode;
272  edgeNodes.at(3) = cNode;
273 }
274 
275 double
277 {
279  OOFEM_ERROR("Not supported");
280  return -1;
281 }
282 
283 void
284 FEI3dTrQuad :: surfaceEvalN(FloatArray &answer, int isurf, const FloatArray &lcoords, const FEICellGeometry &cellgeo)
285 {
286  double l1 = lcoords.at(1);
287  double l2 = lcoords.at(2);
288  double l3 = 1. - l1 - l2;
289 
290  answer.resize(6);
291 
292  answer.at(1) = ( 2. * l1 - 1. ) * l1;
293  answer.at(2) = ( 2. * l2 - 1. ) * l2;
294  answer.at(3) = ( 2. * l3 - 1. ) * l3;
295  answer.at(4) = 4. * l1 * l2;
296  answer.at(5) = 4. * l2 * l3;
297  answer.at(6) = 4. * l3 * l1;
298 }
299 
300 void
302 {
303  // Returns matrix with derivatives wrt local coordinates
304  answer.resize(6, 2);
305  FloatArray dndxi(6), dndeta(6);
306 
307  this->giveDerivativeXi(dndxi, lcoords);
308  this->giveDerivativeEta(dndeta, lcoords);
309  for ( int i = 1; i <= 6; ++i ) {
310  answer.at(i, 1) = dndxi.at(i);
311  answer.at(i, 2) = dndeta.at(i);
312  }
313 }
314 
315 
316 
317 void
319  const FloatArray &lcoords, const FEICellGeometry &cellgeo)
320 {
321  //Note: This gives the coordinate in the reference system
322  FloatArray N;
323  this->surfaceEvalN(N, isurf, lcoords, cellgeo);
324 
325  answer.clear();
326  for ( int i = 0; i < N.giveSize(); ++i ) {
327  answer.add( N(i), * cellgeo.giveVertexCoordinates(i) );
328  }
329 }
330 
331 void
332 FEI3dTrQuad :: surfaceEvaldNdx(FloatMatrix &answer, int isurf, const FloatArray &lcoords, const FEICellGeometry &cellgeo)
333 {
335  OOFEM_ERROR("Not supported");
336 }
337 
338 void
340 {
341  // Note: These are not normalized. Returns the two tangent vectors to the surface.
342  FloatMatrix dNdxi;
343  this->surfaceEvaldNdxi(dNdxi, lcoords);
344 
345  G1.clear();
346  G2.clear();
347  for ( int i = 0; i < 6; ++i ) {
348  G1.add( dNdxi(i, 1), * cellgeo.giveVertexCoordinates(i) );
349  G2.add( dNdxi(i, 2), * cellgeo.giveVertexCoordinates(i) );
350  }
351 }
352 
353 double
354 FEI3dTrQuad :: surfaceEvalNormal(FloatArray &answer, int isurf, const FloatArray &lcoords, const FEICellGeometry &cellgeo)
355 {
356  FloatArray G1, G2; // local curvilinear base vectors
357  this->surfaceEvalBaseVectorsAt(G1, G2, lcoords, cellgeo);
358  answer.beVectorProductOf(G1, G2);
359  double J = answer.computeNorm();
360  answer.times(1 / J);
361  return J;
362 }
363 
364 void
366 {
367  // Jacobian matrix consists of the three curvilinear base vectors. The third is taken as the normal to the surface.
368  // Note! The base vectors are not normalized except the third (normal)
369  FloatArray G1, G2, G3;
370  this->surfaceEvalBaseVectorsAt(G1, G2, lcoords, cellgeo);
371  G3.beVectorProductOf(G1, G2);
372 
373  jacobianMatrix.resize(3, 3);
374  jacobianMatrix.at(1, 1) = G1.at(1);
375  jacobianMatrix.at(1, 2) = G2.at(1);
376  jacobianMatrix.at(1, 3) = G3.at(1);
377  jacobianMatrix.at(2, 1) = G1.at(2);
378  jacobianMatrix.at(2, 2) = G2.at(2);
379  jacobianMatrix.at(2, 3) = G3.at(2);
380  jacobianMatrix.at(3, 1) = G1.at(3);
381  jacobianMatrix.at(3, 2) = G2.at(3);
382  jacobianMatrix.at(3, 3) = G3.at(3);
383 }
384 
385 double
387 {
388  OOFEM_ERROR("Not supported yet");
389  return 0;
390 }
391 
392 void
394 {
395  //surfNodes.setValues(6, 1, 2, 3, 4, 5, 6);
396  //surfNodes = {1, 2, 3, 4, 5, 6};
398  computeLocalEdgeMapping(surfNodes, isurf);
399 
400 }
401 
404 {
405  IntegrationRule *iRule = new GaussIntegrationRule(1, NULL);
406  int points = iRule->getRequiredNumberOfIntegrationPoints(_Triangle, order);
407  iRule->SetUpPointsOnTriangle(points, _Unknown);
408  return iRule;
409 }
410 
413 {
415  OOFEM_ERROR("FEI3dTrQuad :: giveBoundaryIntegrationRule - Not supported");
416  return NULL;
417 }
418 
419 
420 double
422 {
424  const FloatArray *p;
425  double x1, x2, x3, x4, x5, x6, y1, y2, y3, y4, y5, y6;
426 
427  p = cellgeo.giveVertexCoordinates(1);
428  x1 = p->at(1);
429  y1 = p->at(2);
430  p = cellgeo.giveVertexCoordinates(2);
431  x2 = p->at(1);
432  y2 = p->at(2);
433  p = cellgeo.giveVertexCoordinates(3);
434  x3 = p->at(1);
435  y3 = p->at(2);
436  p = cellgeo.giveVertexCoordinates(4);
437  x4 = p->at(1);
438  y4 = p->at(2);
439  p = cellgeo.giveVertexCoordinates(5);
440  x5 = p->at(1);
441  y5 = p->at(2);
442  p = cellgeo.giveVertexCoordinates(6);
443  x6 = p->at(1);
444  y6 = p->at(2);
445 
446  return (4*(-(x4*y1) + x6*y1 + x4*y2 - x5*y2 + x5*y3 - x6*y3) + x2*(y1 - y3 - 4*y4 + 4*y5) +
447  x1*(-y2 + y3 + 4*y4 - 4*y6) + x3*(-y1 + y2 - 4*y5 + 4*y6))/6;
448 }
449 } // 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: fei3dtrquad.C:43
void beVectorProductOf(const FloatArray &v1, const FloatArray &v2)
Computes vector product (or cross product) of vectors given as parameters, , and stores the result in...
Definition: floatarray.C:415
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: fei3dtrquad.C:49
virtual void edgeLocal2global(FloatArray &answer, int iedge, const FloatArray &lcoords, const FEICellGeometry &cellgeo)
Evaluates edge global coordinates from given local ones.
Definition: fei3dtrquad.C:219
double & at(int i)
Coefficient access function.
Definition: floatarray.h:131
virtual const FloatArray * giveVertexCoordinates(int i) const =0
virtual IntegrationRule * giveIntegrationRule(int order)
Sets up a suitable integration rule for numerical integrating over volume.
Definition: fei3dtrquad.C:403
Class representing a general abstraction for cell geometry.
Definition: feinterpol.h:62
void clear()
Clears receiver (zero size).
Definition: floatarray.h:206
virtual void evaldNdxi(FloatMatrix &answer, const FloatArray &lcoords, const FEICellGeometry &cellgeo)
Evaluates the matrix of derivatives of interpolation functions (shape functions) at given point...
Definition: fei3dtrquad.C:57
void surfaceEvalBaseVectorsAt(FloatArray &G1, FloatArray &G2, const FloatArray &lcoords, const FEICellGeometry &cellgeo)
Definition: fei3dtrquad.C:339
virtual void giveLocalNodeCoords(FloatMatrix &answer)
Returns a matrix containing the local coordinates for each node corresponding to the interpolation...
Definition: fei3dtrquad.C:103
void giveDerivativeEta(FloatArray &n, const FloatArray &lcoords)
Definition: fei3dtrquad.C:83
double edgeComputeLength(IntArray &edgeNodes, const FEICellGeometry &cellgeo)
Definition: fei3dtrquad.C:276
virtual void giveJacobianMatrixAt(FloatMatrix &jacobianMatrix, const FloatArray &lcoords, const FEICellGeometry &cellgeo)
Gives the jacobian matrix at the local coordinates.
Definition: fei3dtrquad.C:183
Class implementing an array of integers.
Definition: intarray.h:61
int & at(int i)
Coefficient access function.
Definition: intarray.h:103
virtual void surfaceLocal2global(FloatArray &answer, int isurf, const FloatArray &lcoords, const FEICellGeometry &cellgeo)
Evaluates edge global coordinates from given local ones.
Definition: fei3dtrquad.C:318
virtual void surfaceGiveJacobianMatrixAt(FloatMatrix &jacobianMatrix, const FloatArray &lcoords, const FEICellGeometry &cellgeo)
Definition: fei3dtrquad.C:365
Abstract base class representing integration rule.
virtual double surfaceGiveTransformationJacobian(int isurf, const FloatArray &lcoords, const FEICellGeometry &cellgeo)
Evaluates the edge jacobian of transformation between local and global coordinates.
Definition: fei3dtrquad.C:386
virtual void computeLocalEdgeMapping(IntArray &edgeNodes, int iedge)
Definition: fei3dtrquad.C:249
#define POINT_TOL
Definition: fei3dtrquad.C:136
#define OOFEM_ERROR(...)
Definition: error.h:61
virtual int global2local(FloatArray &answer, const FloatArray &lcoords, const FEICellGeometry &cellgeo)
Evaluates local coordinates from given global ones.
Definition: fei3dtrquad.C:138
void edgeEvaldNdxi(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: fei3dtrquad.C:209
#define N(p, q)
Definition: mdm.C:367
virtual void local2global(FloatArray &answer, const FloatArray &lcoords, const FEICellGeometry &cellgeo)
Evaluates global coordinates from given local ones.
Definition: fei3dtrquad.C:126
double at(int i, int j) const
Coefficient access function.
Definition: floatmatrix.h:176
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
virtual IntegrationRule * giveBoundaryIntegrationRule(int order, int boundary)
Sets up a suitable integration rule for integrating over the requested boundary.
Definition: fei3dtrquad.C:412
Implementation of matrix containing floating point numbers.
Definition: floatmatrix.h:94
double giveArea(const FEICellGeometry &cellgeo) const
Definition: fei3dtrquad.C:421
virtual void surfaceEvaldNdx(FloatMatrix &answer, int isurf, const FloatArray &lcoords, const FEICellGeometry &cellgeo)
Evaluates the matrix of derivatives of edge interpolation functions (shape functions) at given point...
Definition: fei3dtrquad.C:332
double computeNorm() const
Computes the norm (or length) of the vector.
Definition: floatarray.C:840
void resize(int rows, int cols)
Checks size of receiver towards requested bounds.
Definition: floatmatrix.C:1358
virtual void edgeEvaldNdx(FloatMatrix &answer, int iedge, const FloatArray &lcoords, const FEICellGeometry &cellgeo)
Evaluates the matrix of derivatives of edge interpolation functions (shape functions) at given point...
Definition: fei3dtrquad.C:202
virtual int getRequiredNumberOfIntegrationPoints(integrationDomain dType, int approxOrder)
Abstract service.
virtual double surfaceEvalNormal(FloatArray &answer, int isurf, const FloatArray &lcoords, const FEICellGeometry &cellgeo)
Evaluates the normal out of the surface at given point.
Definition: fei3dtrquad.C:354
void times(double s)
Multiplies receiver with scalar.
Definition: floatarray.C:818
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 void surfaceEvalN(FloatArray &answer, int isurf, const FloatArray &lcoords, const FEICellGeometry &cellgeo)
Evaluates the array of edge interpolation functions (shape functions) at given point.
Definition: fei3dtrquad.C:284
void giveDerivativeXi(FloatArray &n, const FloatArray &lcoords)
Definition: fei3dtrquad.C:64
void surfaceEvaldNdxi(FloatMatrix &answer, const FloatArray &lcoords)
Definition: fei3dtrquad.C:301
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: fei3dtrquad.C:190
int giveSize() const
Returns the size of receiver.
Definition: floatarray.h:218
the oofem namespace is to define a context or scope in which all oofem names are defined.
virtual double edgeGiveTransformationJacobian(int iedge, const FloatArray &lcoords, const FEICellGeometry &cellgeo)
Evaluates the edge jacobian of transformation between local and global coordinates.
Definition: fei3dtrquad.C:235
void add(const FloatArray &src)
Adds array src to receiver.
Definition: floatarray.C:156
virtual void computeLocalSurfaceMapping(IntArray &edgeNodes, int iedge)
Definition: fei3dtrquad.C:393
Class representing Gaussian-quadrature integration rule.
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