KratosMultiphysics
KRATOS Multiphysics (Kratos) is a framework for building parallel, multi-disciplinary simulation software, aiming at modularity, extensibility, and high performance. Kratos is written in C++, and counts with an extensive Python interface.
element_utilities.hpp
Go to the documentation of this file.
1 // | / |
2 // ' / __| _` | __| _ \ __|
3 // . \ | ( | | ( |\__ `
4 // _|\_\_| \__,_|\__|\___/ ____/
5 // Multi-Physics
6 //
7 // License: BSD License
8 // Kratos default license: kratos/license.txt
9 //
10 // Main authors: Albert Puigferrat Perez
11 // Ignasi de Pouplana
12 //
13 
14 #if !defined(KRATOS_ELEMENT_UTILITIES )
15 #define KRATOS_ELEMENT_UTILITIES
16 
17 // Project includes
18 #include "includes/define.h"
19 
20 // System includes
21 //#include <cmath>
22 
23 // Project includes
24 //#include "utilities/math_utils.h"
25 #include "includes/element.h"
26 
27 // Application includes
28 
29 namespace Kratos
30 {
31 
33 {
34 
35 
36 public:
37 
38 //----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
39 
40 
41 //----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
42  static inline void InterpolateVariableWithComponents(array_1d<double,2>& rVector,const Matrix& Ncontainer,
43  const array_1d<array_1d<double,3>, 3>& VariableWithComponents,const unsigned int& GPoint)
44  {
46 
47  noalias(rVector) = ZeroVector(2);
48 
49  for(unsigned int i=0; i<3; i++)
50  {
51  rVector[0] += Ncontainer(GPoint,i)*VariableWithComponents[i][0];
52  rVector[1] += Ncontainer(GPoint,i)*VariableWithComponents[i][1];
53  }
54 
55  KRATOS_CATCH( "" )
56  }
57 
58 //----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
59  static inline void InterpolateVariableWithComponents(array_1d<double,2>& rVector,const Matrix& Ncontainer,
60  const array_1d<array_1d<double,3>, 4>& VariableWithComponents,const unsigned int& GPoint)
61  {
63 
64  noalias(rVector) = ZeroVector(2);
65 
66  for(unsigned int i=0; i<4; i++)
67  {
68  rVector[0] += Ncontainer(GPoint,i)*VariableWithComponents[i][0];
69  rVector[1] += Ncontainer(GPoint,i)*VariableWithComponents[i][1];
70  }
71 
72  KRATOS_CATCH( "" )
73  }
74 
75 //----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
76  static inline void InterpolateVariableWithComponents(array_1d<double,3>& rVector,const Matrix& Ncontainer,
77  const array_1d<array_1d<double,3>, 4>& VariableWithComponents,const unsigned int& GPoint)
78  {
79  noalias(rVector) = ZeroVector(3);
80 
81  for(unsigned int i=0; i<4; i++)
82  {
83  rVector[0] += Ncontainer(GPoint,i)*VariableWithComponents[i][0];
84  rVector[1] += Ncontainer(GPoint,i)*VariableWithComponents[i][1];
85  rVector[2] += Ncontainer(GPoint,i)*VariableWithComponents[i][2];
86  }
87  }
88 
89 //----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
90 
91  static inline void InterpolateVariableWithComponents(array_1d<double,3>& rVector,const Matrix& Ncontainer,
92  const array_1d<array_1d<double,3>, 8>& VariableWithComponents,const unsigned int& GPoint)
93  {
94  noalias(rVector) = ZeroVector(3);
95 
96  for(unsigned int i=0; i<8; i++)
97  {
98  rVector[0] += Ncontainer(GPoint,i)*VariableWithComponents[i][0];
99  rVector[1] += Ncontainer(GPoint,i)*VariableWithComponents[i][1];
100  rVector[2] += Ncontainer(GPoint,i)*VariableWithComponents[i][2];
101  }
102  }
103 
104 //----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
105 
106  static inline void FillArray1dOutput(array_1d<double,3>& rOutputValue, const array_1d<double,2>& ComputedValue)
107  {
108  rOutputValue[0] = ComputedValue[0];
109  rOutputValue[1] = ComputedValue[1];
110  rOutputValue[2] = 0.0;
111  }
112 
113  //----------------------------------------------------------------------------------------
114 
115  static inline void FillArray1dOutput(array_1d<double,3>& rOutputValue, const array_1d<double,3>& ComputedValue)
116  {
117  rOutputValue[0] = ComputedValue[0];
118  rOutputValue[1] = ComputedValue[1];
119  rOutputValue[2] = ComputedValue[2];
120  }
121 
122 //----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
123 
124 //----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
125 
130 
131  static inline void Calculate2DExtrapolationMatrix(BoundedMatrix<double,3,3>& rExtrapolationMatrix)
132  {
133  //Triangle_2d_3
134  //GI_GAUSS_2
135 
136  rExtrapolationMatrix(0,0) = 1.6666666666666666666; rExtrapolationMatrix(0,1) = -0.33333333333333333333; rExtrapolationMatrix(0,2) = -0.33333333333333333333;
137  rExtrapolationMatrix(1,0) = -0.33333333333333333333; rExtrapolationMatrix(1,1) = 1.6666666666666666666; rExtrapolationMatrix(1,2) = -0.33333333333333333333;
138  rExtrapolationMatrix(2,0) = -0.33333333333333333333; rExtrapolationMatrix(2,1) = -0.33333333333333333333; rExtrapolationMatrix(2,2) = 1.6666666666666666666;
139  }
140 
141  //----------------------------------------------------------------------------------------
142 
143  static inline void Calculate2DExtrapolationMatrix(BoundedMatrix<double,4,4>& rExtrapolationMatrix)
144  {
145  //Quadrilateral_2d_4
146  //GI_GAUSS_2
147 
148  rExtrapolationMatrix(0,0) = 1.8660254037844386; rExtrapolationMatrix(0,1) = -0.5; rExtrapolationMatrix(0,2) = 0.13397459621556132; rExtrapolationMatrix(0,3) = -0.5;
149  rExtrapolationMatrix(1,0) = -0.5; rExtrapolationMatrix(1,1) = 1.8660254037844386; rExtrapolationMatrix(1,2) = -0.5; rExtrapolationMatrix(1,3) = 0.13397459621556132;
150  rExtrapolationMatrix(2,0) = 0.13397459621556132; rExtrapolationMatrix(2,1) = -0.5; rExtrapolationMatrix(2,2) = 1.8660254037844386; rExtrapolationMatrix(2,3) = -0.5;
151  rExtrapolationMatrix(3,0) = -0.5; rExtrapolationMatrix(3,1) = 0.13397459621556132; rExtrapolationMatrix(3,2) = -0.5; rExtrapolationMatrix(3,3) = 1.8660254037844386;
152  }
153 
154  //----------------------------------------------------------------------------------------
155 
156  static inline void Calculate3DExtrapolationMatrix(BoundedMatrix<double,4,4>& rExtrapolationMatrix)
157  {
158  //Tetrahedra_3d_4
159  //GI_GAUSS_2
160 
161  rExtrapolationMatrix(0,0) = -0.309016988749894905; rExtrapolationMatrix(0,1) = -0.3090169887498949046; rExtrapolationMatrix(0,2) = -0.309016988749894905; rExtrapolationMatrix(0,3) = 1.9270509662496847144;
162  rExtrapolationMatrix(1,0) = 1.9270509662496847144; rExtrapolationMatrix(1,1) = -0.30901698874989490481; rExtrapolationMatrix(1,2) = -0.3090169887498949049; rExtrapolationMatrix(1,3) = -0.30901698874989490481;
163  rExtrapolationMatrix(2,0) = -0.30901698874989490473; rExtrapolationMatrix(2,1) = 1.9270509662496847143; rExtrapolationMatrix(2,2) = -0.3090169887498949049; rExtrapolationMatrix(2,3) = -0.30901698874989490481;
164  rExtrapolationMatrix(3,0) = -0.3090169887498949048; rExtrapolationMatrix(3,1) = -0.30901698874989490471; rExtrapolationMatrix(3,2) = 1.9270509662496847143; rExtrapolationMatrix(3,3) = -0.30901698874989490481;
165  }
166 
167  //----------------------------------------------------------------------------------------
168 
169  static inline void Calculate3DExtrapolationMatrix(BoundedMatrix<double,8,8>& rExtrapolationMatrix)
170  {
171  //Hexahedra_3d_8
172  //GI_GAUSS_2
173 
174  rExtrapolationMatrix(0,0) = 2.549038105676658; rExtrapolationMatrix(0,1) = -0.6830127018922192; rExtrapolationMatrix(0,2) = 0.18301270189221927; rExtrapolationMatrix(0,3) = -0.6830127018922192;
175  rExtrapolationMatrix(0,4) = -0.6830127018922192; rExtrapolationMatrix(0,5) = 0.18301270189221927; rExtrapolationMatrix(0,6) = -0.04903810567665795; rExtrapolationMatrix(0,7) = 0.18301270189221927;
176 
177  rExtrapolationMatrix(1,0) = -0.6830127018922192; rExtrapolationMatrix(1,1) = 2.549038105676658; rExtrapolationMatrix(1,2) = -0.6830127018922192; rExtrapolationMatrix(1,3) = 0.18301270189221927;
178  rExtrapolationMatrix(1,4) = 0.18301270189221927; rExtrapolationMatrix(1,5) = -0.6830127018922192; rExtrapolationMatrix(1,6) = 0.18301270189221927; rExtrapolationMatrix(1,7) = -0.04903810567665795;
179 
180  rExtrapolationMatrix(2,0) = 0.18301270189221927; rExtrapolationMatrix(2,1) = -0.6830127018922192; rExtrapolationMatrix(2,2) = 2.549038105676658; rExtrapolationMatrix(2,3) = -0.6830127018922192;
181  rExtrapolationMatrix(2,4) = -0.04903810567665795; rExtrapolationMatrix(2,5) = 0.18301270189221927; rExtrapolationMatrix(2,6) = -0.6830127018922192; rExtrapolationMatrix(2,7) = 0.18301270189221927;
182 
183  rExtrapolationMatrix(3,0) = -0.6830127018922192; rExtrapolationMatrix(3,1) = 0.18301270189221927; rExtrapolationMatrix(3,2) = -0.6830127018922192; rExtrapolationMatrix(3,3) = 2.549038105676658;
184  rExtrapolationMatrix(3,4) = 0.18301270189221927; rExtrapolationMatrix(3,5) = -0.04903810567665795; rExtrapolationMatrix(3,6) = 0.18301270189221927; rExtrapolationMatrix(3,7) = -0.6830127018922192;
185 
186  rExtrapolationMatrix(4,0) = -0.6830127018922192; rExtrapolationMatrix(4,1) = 0.18301270189221927; rExtrapolationMatrix(4,2) = -0.04903810567665795; rExtrapolationMatrix(4,3) = 0.18301270189221927;
187  rExtrapolationMatrix(4,4) = 2.549038105676658; rExtrapolationMatrix(4,5) = -0.6830127018922192; rExtrapolationMatrix(4,6) = 0.18301270189221927; rExtrapolationMatrix(4,7) = -0.6830127018922192;
188 
189  rExtrapolationMatrix(5,0) = 0.18301270189221927; rExtrapolationMatrix(5,1) = -0.6830127018922192; rExtrapolationMatrix(5,2) = 0.18301270189221927; rExtrapolationMatrix(5,3) = -0.04903810567665795;
190  rExtrapolationMatrix(5,4) = -0.6830127018922192; rExtrapolationMatrix(5,5) = 2.549038105676658; rExtrapolationMatrix(5,6) = -0.6830127018922192; rExtrapolationMatrix(5,7) = 0.18301270189221927;
191 
192  rExtrapolationMatrix(6,0) = -0.04903810567665795; rExtrapolationMatrix(6,1) = 0.18301270189221927; rExtrapolationMatrix(6,2) = -0.6830127018922192; rExtrapolationMatrix(6,3) = 0.18301270189221927;
193  rExtrapolationMatrix(6,4) = 0.18301270189221927; rExtrapolationMatrix(6,5) = -0.6830127018922192; rExtrapolationMatrix(6,6) = 2.549038105676658; rExtrapolationMatrix(6,7) = -0.6830127018922192;
194 
195  rExtrapolationMatrix(7,0) = 0.18301270189221927; rExtrapolationMatrix(7,1) = -0.04903810567665795; rExtrapolationMatrix(7,2) = 0.18301270189221927; rExtrapolationMatrix(7,3) = -0.6830127018922192;
196  rExtrapolationMatrix(7,4) = -0.6830127018922192; rExtrapolationMatrix(7,5) = 0.18301270189221927; rExtrapolationMatrix(7,6) = -0.6830127018922192; rExtrapolationMatrix(7,7) = 2.549038105676658;
197 }
198 
199 }; /* Class ElementUtilities*/
200 } /* namespace Kratos.*/
201 
202 #endif /* KRATOS_ELEMENT_UTILITIES defined */
static void InterpolateVariableWithComponents(array_1d< double, 3 > &rVector, const Matrix &Ncontainer, const array_1d< array_1d< double, 3 >, 8 > &VariableWithComponents, const unsigned int &GPoint)
Definition: element_utilities.hpp:91
static void FillArray1dOutput(array_1d< double, 3 > &rOutputValue, const array_1d< double, 2 > &ComputedValue)
Definition: element_utilities.hpp:106
static void Calculate3DExtrapolationMatrix(BoundedMatrix< double, 8, 8 > &rExtrapolationMatrix)
Definition: element_utilities.hpp:169
static void FillArray1dOutput(array_1d< double, 3 > &rOutputValue, const array_1d< double, 3 > &ComputedValue)
Definition: element_utilities.hpp:115
static void Calculate2DExtrapolationMatrix(BoundedMatrix< double, 4, 4 > &rExtrapolationMatrix)
Definition: element_utilities.hpp:143
static void InterpolateVariableWithComponents(array_1d< double, 2 > &rVector, const Matrix &Ncontainer, const array_1d< array_1d< double, 3 >, 3 > &VariableWithComponents, const unsigned int &GPoint)
Definition: element_utilities.hpp:42
static void Calculate2DExtrapolationMatrix(BoundedMatrix< double, 3, 3 > &rExtrapolationMatrix)
Definition: element_utilities.hpp:131
static void InterpolateVariableWithComponents(array_1d< double, 3 > &rVector, const Matrix &Ncontainer, const array_1d< array_1d< double, 3 >, 4 > &VariableWithComponents, const unsigned int &GPoint)
Definition: element_utilities.hpp:76
static void Calculate3DExtrapolationMatrix(BoundedMatrix< double, 4, 4 > &rExtrapolationMatrix)
Definition: element_utilities.hpp:156
static void InterpolateVariableWithComponents(array_1d< double, 2 > &rVector, const Matrix &Ncontainer, const array_1d< array_1d< double, 3 >, 4 > &VariableWithComponents, const unsigned int &GPoint)
Definition: element_utilities.hpp:59
#define KRATOS_CATCH(MoreInfo)
Definition: define.h:110
#define KRATOS_TRY
Definition: define.h:109
This class includes several utilities necessaries for the computation of the different elements.
REF: G. R. Cowper, GAUSSIAN QUADRATURE FORMULAS FOR TRIANGLES.
Definition: mesh_condition.cpp:21
KratosZeroVector< double > ZeroVector
Definition: amatrix_interface.h:561
T & noalias(T &TheMatrix)
Definition: amatrix_interface.h:484
integer i
Definition: TensorModule.f:17