OOFEM  2.4
OOFEM.org - Object Oriented Finite Element Solver
fei2dlinelin.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 "fei2dlinelin.h"
36 #include "mathfem.h"
37 #include "floatmatrix.h"
38 #include "floatarray.h"
39 #include "gaussintegrationrule.h"
40 
41 namespace oofem {
42 void FEI2dLineLin :: evalN(FloatArray &answer, const FloatArray &lcoords, const FEICellGeometry &cellgeo)
43 {
44  double xi = lcoords(0);
45  answer.resize(2);
46  answer.at(1) = ( 1. - xi ) * 0.5;
47  answer.at(2) = ( 1. + xi ) * 0.5;
48 }
49 
50 double FEI2dLineLin :: evaldNdx(FloatMatrix &answer, const FloatArray &lcoords, const FEICellGeometry &cellgeo)
51 {
52  // Not meaningful to return anything.
53  answer.clear();
54  return 0.;
55 }
56 
57 void FEI2dLineLin :: evaldNdxi(FloatMatrix &answer, const FloatArray &lcoords, const FEICellGeometry &cellgeo)
58 {
59  answer.resize(2, 1);
60  answer(0, 0) = -0.5;
61  answer(1, 0) = 0.5;
62 }
63 
64 void FEI2dLineLin :: local2global(FloatArray &answer, const FloatArray &lcoords, const FEICellGeometry &cellgeo)
65 {
66  FloatArray n;
67  this->evalN(n, lcoords, cellgeo);
68  answer.resize( max(xind, yind) );
69  answer.zero();
70  answer.at(xind) = ( n(0) * cellgeo.giveVertexCoordinates(1)->at(xind) +
71  n(1) * cellgeo.giveVertexCoordinates(2)->at(xind) );
72  answer.at(yind) = ( n(0) * cellgeo.giveVertexCoordinates(1)->at(yind) +
73  n(1) * cellgeo.giveVertexCoordinates(2)->at(yind) );
74 }
75 
76 int FEI2dLineLin :: global2local(FloatArray &answer, const FloatArray &gcoords, const FEICellGeometry &cellgeo)
77 {
78  double xi;
79  double x2_x1, y2_y1;
80 
81  x2_x1 = cellgeo.giveVertexCoordinates(2)->at(xind) - cellgeo.giveVertexCoordinates(1)->at(xind);
82  y2_y1 = cellgeo.giveVertexCoordinates(2)->at(yind) - cellgeo.giveVertexCoordinates(1)->at(yind);
83 
84  // Projection of the global coordinate gives the value interpolated in [0,1].
85  xi = ( x2_x1 * gcoords(0) + y2_y1 * gcoords(1) ) / ( sqrt(x2_x1 * x2_x1 + y2_y1 * y2_y1) );
86  // Map to [-1,1] domain.
87  xi = xi * 2 - 1;
88 
89  answer.resize(1);
90  answer(0) = clamp(xi, -1., 1.);
91  return false;
92 }
93 
94 void FEI2dLineLin :: edgeEvaldNds(FloatArray &answer, int iedge,
95  const FloatArray &lcoords, const FEICellGeometry &cellgeo)
96 {
97  double xi = lcoords(0);
98  answer.resize(2);
99  answer(0) = -0.5 * xi;
100  answer(1) = 0.5 * xi;
101 
102  double es1 = answer(0) * cellgeo.giveVertexCoordinates(1)->at(xind) +
103  answer(1) * cellgeo.giveVertexCoordinates(2)->at(xind);
104  double es2 = answer(0) * cellgeo.giveVertexCoordinates(1)->at(yind) +
105  answer(1) * cellgeo.giveVertexCoordinates(2)->at(yind);
106 
107  double J = sqrt(es1 * es1 + es2 * es2);
108  answer.times(1 / J);
109  //return J;
110 }
111 
112 double FEI2dLineLin :: edgeEvalNormal(FloatArray &normal, int iedge, const FloatArray &lcoords, const FEICellGeometry &cellgeo)
113 {
114  normal.resize(2);
115  normal.at(1) = cellgeo.giveVertexCoordinates(2)->at(xind) - cellgeo.giveVertexCoordinates(1)->at(xind);
116  normal.at(2) = -( cellgeo.giveVertexCoordinates(2)->at(yind) - cellgeo.giveVertexCoordinates(1)->at(yind) );
117  return normal.normalize() * 0.5;
118 }
119 
121 {
122  double x2_x1, y2_y1;
123  x2_x1 = cellgeo.giveVertexCoordinates(2)->at(xind) - cellgeo.giveVertexCoordinates(1)->at(xind);
124  y2_y1 = cellgeo.giveVertexCoordinates(2)->at(yind) - cellgeo.giveVertexCoordinates(1)->at(yind);
125  return sqrt(x2_x1 * x2_x1 + y2_y1 * y2_y1) / 2.0;
126 }
127 
129 {
130  answer = {1, 2};
131 }
132 
134 {
135  if ( iedge != 1 ) {
136  OOFEM_ERROR("wrong egde number (%d)", iedge);
137  }
138 
139  edgeNodes = {1, 2};
140 }
141 
142 void FEI2dLineLin :: edgeEvalN(FloatArray &answer, int iedge, const FloatArray &lcoords, const FEICellGeometry &cellgeo)
143 {
144  this->evalN(answer, lcoords, cellgeo);
145 }
146 
148 {
149  double x2_x1, y2_y1;
150  x2_x1 = cellgeo.giveVertexCoordinates(2)->at(xind) - cellgeo.giveVertexCoordinates(1)->at(xind);
151  y2_y1 = cellgeo.giveVertexCoordinates(2)->at(yind) - cellgeo.giveVertexCoordinates(1)->at(yind);
152  return sqrt(x2_x1 * x2_x1 + y2_y1 * y2_y1);
153 }
154 
155 double FEI2dLineLin :: evalNXIntegral(int iEdge, const FEICellGeometry &cellgeo)
156 {
157  const FloatArray *node;
158  double x1, x2, y1, y2;
159 
160  node = cellgeo.giveVertexCoordinates(1);
161  x1 = node->at(xind);
162  y1 = node->at(yind);
163 
164  node = cellgeo.giveVertexCoordinates(2);
165  x2 = node->at(xind);
166  y2 = node->at(yind);
167 
168  return x2 * y1 - x1 * y2;
169 }
170 
172 {
173  IntegrationRule *iRule = new GaussIntegrationRule(1, NULL);
174  int points = iRule->getRequiredNumberOfIntegrationPoints(_Line, order + 0);
175  iRule->SetUpPointsOnLine(points, _Unknown);
176  return iRule;
177 }
178 } // end namespace oofem
virtual double giveTransformationJacobian(const FloatArray &lcoords, const FEICellGeometry &cellgeo)
Evaluates the determinant of the transformation.
Definition: fei2dlinelin.C:120
virtual void computeLocalEdgeMapping(IntArray &edgeNodes, int iedge)
Definition: fei2dlinelin.C:133
virtual double edgeEvalNormal(FloatArray &normal, int iedge, const FloatArray &lcoords, const FEICellGeometry &cellgeo)
Evaluates the normal on the given edge.
Definition: fei2dlinelin.C:112
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 evalN(FloatArray &answer, const FloatArray &lcoords, const FEICellGeometry &cellgeo)
Evaluates the array of interpolation functions (shape functions) at given point.
Definition: fei2dlinelin.C:42
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: fei2dlinelin.C:57
virtual int global2local(FloatArray &answer, const FloatArray &gcoords, const FEICellGeometry &cellgeo)
Default implementation using Newton's method to find the local coordinates.
Definition: fei2dlinelin.C:76
Class implementing an array of integers.
Definition: intarray.h:61
Abstract base class representing integration rule.
#define OOFEM_ERROR(...)
Definition: error.h:61
virtual double evalNXIntegral(int iEdge, const FEICellGeometry &cellgeo)
Computes the integral .
Definition: fei2dlinelin.C:155
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: fei2dlinelin.C:94
virtual void boundaryEdgeGiveNodes(IntArray &answer, int boundary)
Gives the boundary nodes for requested boundary number.
Definition: fei2dlinelin.C:128
double edgeComputeLength(IntArray &edgeNodes, const FEICellGeometry &cellgeo)
Definition: fei2dlinelin.C:147
virtual IntegrationRule * giveIntegrationRule(int order)
Sets up a suitable integration rule for numerical integrating over volume.
Definition: fei2dlinelin.C:171
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: fei2dlinelin.C:142
Class representing vector of real numbers.
Definition: floatarray.h:82
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
virtual int getRequiredNumberOfIntegrationPoints(integrationDomain dType, int approxOrder)
Abstract service.
void zero()
Zeroes all coefficients of receiver.
Definition: floatarray.C:658
virtual int SetUpPointsOnLine(int, MaterialMode mode)
Sets up receiver's integration points on unit line integration domain.
void times(double s)
Multiplies receiver with scalar.
Definition: floatarray.C:818
the oofem namespace is to define a context or scope in which all oofem names are defined.
void clear()
Sets size of receiver to be an empty matrix. It will have zero rows and zero columns size...
Definition: floatmatrix.h:516
double normalize()
Normalizes receiver.
Definition: floatarray.C:828
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: fei2dlinelin.C:50
virtual void local2global(FloatArray &answer, const FloatArray &lcoords, const FEICellGeometry &cellgeo)
Evaluates global coordinates from given local ones.
Definition: fei2dlinelin.C:64
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