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.
poro_condition_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: Ignasi de Pouplana
11 //
12 
13 
14 #if !defined(KRATOS_PORO_CONDITION_UTILITIES )
15 #define KRATOS_PORO_CONDITION_UTILITIES
16 
17 // Project includes
18 #include "includes/element.h"
19 
20 namespace Kratos
21 {
22 
24 {
25 
26 public:
27 
28 //----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
29 
30  static inline void CalculateNuMatrix(BoundedMatrix<double,2,4>& rNu, const Matrix& Ncontainer, const unsigned int& GPoint)
31  {
32  //Line_2d_2
33  rNu(0,0) = Ncontainer(GPoint,0); rNu(0,2) = Ncontainer(GPoint,1);
34  rNu(1,1) = Ncontainer(GPoint,0); rNu(1,3) = Ncontainer(GPoint,1);
35  }
36 
37  //----------------------------------------------------------------------------------------
38 
39  static inline void CalculateNuMatrix(BoundedMatrix<double,3,9>& rNu, const Matrix& Ncontainer, const unsigned int& GPoint)
40  {
41  //Triangle_3d_3
42  rNu(0,0) = Ncontainer(GPoint,0); rNu(0,3) = Ncontainer(GPoint,1); rNu(0,6) = Ncontainer(GPoint,2);
43  rNu(1,1) = Ncontainer(GPoint,0); rNu(1,4) = Ncontainer(GPoint,1); rNu(1,7) = Ncontainer(GPoint,2);
44  rNu(2,2) = Ncontainer(GPoint,0); rNu(2,5) = Ncontainer(GPoint,1); rNu(2,8) = Ncontainer(GPoint,2);
45  }
46 
47  //----------------------------------------------------------------------------------------
48 
49  static inline void CalculateNuMatrix(BoundedMatrix<double,3,12>& rNu, const Matrix& Ncontainer, const unsigned int& GPoint)
50  {
51  //Quadrilateral_3d_4
52  rNu(0,0) = Ncontainer(GPoint,0); rNu(0,3) = Ncontainer(GPoint,1); rNu(0,6) = Ncontainer(GPoint,2); rNu(0,9) = Ncontainer(GPoint,3);
53  rNu(1,1) = Ncontainer(GPoint,0); rNu(1,4) = Ncontainer(GPoint,1); rNu(1,7) = Ncontainer(GPoint,2); rNu(1,10) = Ncontainer(GPoint,3);
54  rNu(2,2) = Ncontainer(GPoint,0); rNu(2,5) = Ncontainer(GPoint,1); rNu(2,8) = Ncontainer(GPoint,2); rNu(2,11) = Ncontainer(GPoint,3);
55  }
56 
57 //----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
58 
59  static inline void InterpolateVariableWithComponents(array_1d<double,2>& rVector,const Matrix& Ncontainer,
60  const array_1d<double,4>& VariableWithComponents,const unsigned int& GPoint)
61  {
62  //Line_2d_2
63  noalias(rVector) = ZeroVector(2);
64 
65  unsigned int index = 0;
66  for(unsigned int i=0; i<2; i++)
67  {
68  rVector[0] += Ncontainer(GPoint,i)*VariableWithComponents[index++];
69  rVector[1] += Ncontainer(GPoint,i)*VariableWithComponents[index++];
70  }
71  }
72 
73  //----------------------------------------------------------------------------------------
74 
75  static inline void InterpolateVariableWithComponents(array_1d<double,3>& rVector,const Matrix& Ncontainer,
76  const array_1d<double,9>& VariableWithComponents,const unsigned int& GPoint)
77  {
78  //Triangle_3d_3
79  noalias(rVector) = ZeroVector(3);
80 
81  unsigned int index = 0;
82  for(unsigned int i=0; i<3; i++)
83  {
84  rVector[0] += Ncontainer(GPoint,i)*VariableWithComponents[index++];
85  rVector[1] += Ncontainer(GPoint,i)*VariableWithComponents[index++];
86  rVector[2] += Ncontainer(GPoint,i)*VariableWithComponents[index++];
87  }
88  }
89 
90  //----------------------------------------------------------------------------------------
91 
92  static inline void InterpolateVariableWithComponents(array_1d<double,3>& rVector,const Matrix& Ncontainer,
93  const array_1d<double,12>& VariableWithComponents,const unsigned int& GPoint)
94  {
95  //Quadrilateral_3d_4
96  noalias(rVector) = ZeroVector(3);
97 
98  unsigned int index = 0;
99  for(unsigned int i=0; i<4; i++)
100  {
101  rVector[0] += Ncontainer(GPoint,i)*VariableWithComponents[index++];
102  rVector[1] += Ncontainer(GPoint,i)*VariableWithComponents[index++];
103  rVector[2] += Ncontainer(GPoint,i)*VariableWithComponents[index++];
104  }
105  }
106 
107 //----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
108 
109  static inline void GetNodalVariableVector(array_1d<double,4>& rNodalVariableVector, const Element::GeometryType& Geom,
111  {
112  //Line_2d_2
113  array_1d<double,3> NodalVariableAux;
114  unsigned int index = 0;
115  for(unsigned int i=0; i<2; i++)
116  {
117  noalias(NodalVariableAux) = Geom[i].FastGetSolutionStepValue(Variable);
118  rNodalVariableVector[index++] = NodalVariableAux[0];
119  rNodalVariableVector[index++] = NodalVariableAux[1];
120  }
121  }
122 
123  //----------------------------------------------------------------------------------------
124 
125  static inline void GetNodalVariableVector(array_1d<double,9>& rNodalVariableVector, const Element::GeometryType& Geom,
127  {
128  //Triangle_3d_3
129  array_1d<double,3> NodalVariableAux;
130  unsigned int index = 0;
131  for(unsigned int i=0; i<3; i++)
132  {
133  noalias(NodalVariableAux) = Geom[i].FastGetSolutionStepValue(Variable);
134  rNodalVariableVector[index++] = NodalVariableAux[0];
135  rNodalVariableVector[index++] = NodalVariableAux[1];
136  rNodalVariableVector[index++] = NodalVariableAux[2];
137  }
138  }
139 
140  //----------------------------------------------------------------------------------------
141 
142  static inline void GetNodalVariableVector(array_1d<double,12>& rNodalVariableVector, const Element::GeometryType& Geom,
144  {
145  //Quadrilateral_3d_4
146  array_1d<double,3> NodalVariableAux;
147  unsigned int index = 0;
148  for(unsigned int i=0; i<4; i++)
149  {
150  noalias(NodalVariableAux) = Geom[i].FastGetSolutionStepValue(Variable);
151  rNodalVariableVector[index++] = NodalVariableAux[0];
152  rNodalVariableVector[index++] = NodalVariableAux[1];
153  rNodalVariableVector[index++] = NodalVariableAux[2];
154  }
155  }
156 
157 //----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
158 
159  static inline void AssembleUBlockVector(Vector& rRightHandSideVector, const array_1d<double,4>& UBlockVector)
160  {
161  //Line_2d_2
162  unsigned int Global_i, Local_i;
163 
164  for(unsigned int i = 0; i < 2; i++)
165  {
166  Global_i = i * (2 + 1);
167  Local_i = i * 2;
168 
169  rRightHandSideVector[Global_i] += UBlockVector[Local_i];
170  rRightHandSideVector[Global_i+1] += UBlockVector[Local_i+1];
171  }
172  }
173 
174  //----------------------------------------------------------------------------------------
175 
176  static inline void AssembleUBlockVector(Vector& rRightHandSideVector, const array_1d<double,9>& UBlockVector)
177  {
178  //Triangle_3d_3
179  unsigned int Global_i, Local_i;
180 
181  for(unsigned int i = 0; i < 3; i++)
182  {
183  Global_i = i * (3 + 1);
184  Local_i = i * 3;
185 
186  rRightHandSideVector[Global_i] += UBlockVector[Local_i];
187  rRightHandSideVector[Global_i+1] += UBlockVector[Local_i+1];
188  rRightHandSideVector[Global_i+2] += UBlockVector[Local_i+2];
189  }
190  }
191 
192  //----------------------------------------------------------------------------------------
193 
194  static inline void AssembleUBlockVector(Vector& rRightHandSideVector, const array_1d<double,12>& UBlockVector)
195  {
196  //Quadrilateral_3d_4
197  unsigned int Global_i, Local_i;
198 
199  for(unsigned int i = 0; i < 4; i++)
200  {
201  Global_i = i * (3 + 1);
202  Local_i = i * 3;
203 
204  rRightHandSideVector[Global_i] += UBlockVector[Local_i];
205  rRightHandSideVector[Global_i+1] += UBlockVector[Local_i+1];
206  rRightHandSideVector[Global_i+2] += UBlockVector[Local_i+2];
207  }
208  }
209 
210 //----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
211 
212  template< class TVectorType >
213  static inline void AssemblePBlockVector(Vector& rRightHandSideVector,const TVectorType& PBlockVector, const unsigned int& Dim, const unsigned int& NumNodes)
214  {
215  unsigned int Global_i;
216 
217  for(unsigned int i = 0; i < NumNodes; i++)
218  {
219  Global_i = i * (Dim + 1) + Dim;
220 
221  rRightHandSideVector[Global_i] += PBlockVector[i];
222  }
223  }
224 
225 //----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
226 
227  static inline void AssembleUPMatrix(Matrix& rLeftHandSideMatrix, const BoundedMatrix<double,4,2>& UPBlockMatrix)
228  {
229  //Line_2d_2
230  unsigned int Global_i, Global_j, Local_i;
231 
232  for(unsigned int i = 0; i < 2; i++)
233  {
234  Global_i = i * (2 + 1);
235  Local_i = i * 2;
236 
237  for(unsigned int j = 0; j < 2; j++)
238  {
239  Global_j = j * (2 + 1) + 2;
240 
241  rLeftHandSideMatrix(Global_i,Global_j) += UPBlockMatrix(Local_i,j);
242  rLeftHandSideMatrix(Global_i+1,Global_j) += UPBlockMatrix(Local_i+1,j);
243  }
244  }
245  }
246 
247 //----------------------------------------------------------------------------------------
248 
249  static inline void AssembleUPMatrix(Matrix& rLeftHandSideMatrix, const BoundedMatrix<double,9,3>& UPBlockMatrix)
250  {
251  //Triangle_3d_3
252  unsigned int Global_i, Global_j, Local_i;
253 
254  for(unsigned int i = 0; i < 3; i++)
255  {
256  Global_i = i * (3 + 1);
257  Local_i = i * 3;
258 
259  for(unsigned int j = 0; j < 3; j++)
260  {
261  Global_j = j * (3 + 1) + 3;
262 
263  rLeftHandSideMatrix(Global_i,Global_j) += UPBlockMatrix(Local_i,j);
264  rLeftHandSideMatrix(Global_i+1,Global_j) += UPBlockMatrix(Local_i+1,j);
265  rLeftHandSideMatrix(Global_i+2,Global_j) += UPBlockMatrix(Local_i+2,j);
266  }
267  }
268  }
269 
270 //----------------------------------------------------------------------------------------
271 
272  static inline void AssembleUPMatrix(Matrix& rLeftHandSideMatrix, const BoundedMatrix<double,12,4>& UPBlockMatrix)
273  {
274  //Quadrilateral_3d_4
275  unsigned int Global_i, Global_j, Local_i;
276 
277  for(unsigned int i = 0; i < 4; i++)
278  {
279  Global_i = i * (3 + 1);
280  Local_i = i * 3;
281 
282  for(unsigned int j = 0; j < 4; j++)
283  {
284  Global_j = j * (3 + 1) + 3;
285 
286  rLeftHandSideMatrix(Global_i,Global_j) += UPBlockMatrix(Local_i,j);
287  rLeftHandSideMatrix(Global_i+1,Global_j) += UPBlockMatrix(Local_i+1,j);
288  rLeftHandSideMatrix(Global_i+2,Global_j) += UPBlockMatrix(Local_i+2,j);
289  }
290  }
291  }
292 
293 //----------------------------------------------------------------------------------------
294 
295  static inline void AssemblePUMatrix(Matrix& rLeftHandSideMatrix, const BoundedMatrix<double,2,4>& PUBlockMatrix)
296  {
297  //Line_2d_2
298  unsigned int Global_i, Global_j, Local_j;
299 
300  for(unsigned int i = 0; i < 2; i++)
301  {
302  Global_i = i * (2 + 1) + 2;
303 
304  for(unsigned int j = 0; j < 2; j++)
305  {
306  Global_j = j * (2 + 1);
307  Local_j = j * 2;
308 
309  rLeftHandSideMatrix(Global_i,Global_j) += PUBlockMatrix(i,Local_j);
310  rLeftHandSideMatrix(Global_i,Global_j+1) += PUBlockMatrix(i,Local_j+1);
311  }
312  }
313  }
314 
315 //----------------------------------------------------------------------------------------
316 
317  static inline void AssemblePUMatrix(Matrix& rLeftHandSideMatrix, const BoundedMatrix<double,3,9>& PUBlockMatrix)
318  {
319  //Triangle_3d_3
320  unsigned int Global_i, Global_j, Local_j;
321 
322  for(unsigned int i = 0; i < 3; i++)
323  {
324  Global_i = i * (3 + 1) + 3;
325 
326  for(unsigned int j = 0; j < 3; j++)
327  {
328  Global_j = j * (3 + 1);
329  Local_j = j * 3;
330 
331  rLeftHandSideMatrix(Global_i,Global_j) += PUBlockMatrix(i,Local_j);
332  rLeftHandSideMatrix(Global_i,Global_j+1) += PUBlockMatrix(i,Local_j+1);
333  rLeftHandSideMatrix(Global_i,Global_j+2) += PUBlockMatrix(i,Local_j+2);
334  }
335  }
336  }
337 
338 //----------------------------------------------------------------------------------------
339 
340  static inline void AssemblePUMatrix(Matrix& rLeftHandSideMatrix, const BoundedMatrix<double,4,12>& PUBlockMatrix)
341  {
342  //Quadrilateral_3d_4
343  unsigned int Global_i, Global_j, Local_j;
344 
345  for(unsigned int i = 0; i < 4; i++)
346  {
347  Global_i = i * (3 + 1) + 3;
348 
349  for(unsigned int j = 0; j < 4; j++)
350  {
351  Global_j = j * (3 + 1);
352  Local_j = j * 3;
353 
354  rLeftHandSideMatrix(Global_i,Global_j) += PUBlockMatrix(i,Local_j);
355  rLeftHandSideMatrix(Global_i,Global_j+1) += PUBlockMatrix(i,Local_j+1);
356  rLeftHandSideMatrix(Global_i,Global_j+2) += PUBlockMatrix(i,Local_j+2);
357  }
358  }
359  }
360 
361 }; /* Class PoroConditionUtilities*/
362 } /* namespace Kratos.*/
363 
364 #endif /* KRATOS_PORO_CONDITION_UTILITIES defined */
Geometry base class.
Definition: geometry.h:71
Definition: amatrix_interface.h:41
Definition: poro_condition_utilities.hpp:24
static void AssemblePUMatrix(Matrix &rLeftHandSideMatrix, const BoundedMatrix< double, 4, 12 > &PUBlockMatrix)
Definition: poro_condition_utilities.hpp:340
static void GetNodalVariableVector(array_1d< double, 9 > &rNodalVariableVector, const Element::GeometryType &Geom, const Variable< array_1d< double, 3 >> &Variable)
Definition: poro_condition_utilities.hpp:125
static void AssemblePUMatrix(Matrix &rLeftHandSideMatrix, const BoundedMatrix< double, 3, 9 > &PUBlockMatrix)
Definition: poro_condition_utilities.hpp:317
static void AssembleUPMatrix(Matrix &rLeftHandSideMatrix, const BoundedMatrix< double, 9, 3 > &UPBlockMatrix)
Definition: poro_condition_utilities.hpp:249
static void AssemblePUMatrix(Matrix &rLeftHandSideMatrix, const BoundedMatrix< double, 2, 4 > &PUBlockMatrix)
Definition: poro_condition_utilities.hpp:295
static void AssemblePBlockVector(Vector &rRightHandSideVector, const TVectorType &PBlockVector, const unsigned int &Dim, const unsigned int &NumNodes)
Definition: poro_condition_utilities.hpp:213
static void AssembleUPMatrix(Matrix &rLeftHandSideMatrix, const BoundedMatrix< double, 12, 4 > &UPBlockMatrix)
Definition: poro_condition_utilities.hpp:272
static void CalculateNuMatrix(BoundedMatrix< double, 3, 9 > &rNu, const Matrix &Ncontainer, const unsigned int &GPoint)
Definition: poro_condition_utilities.hpp:39
static void InterpolateVariableWithComponents(array_1d< double, 3 > &rVector, const Matrix &Ncontainer, const array_1d< double, 9 > &VariableWithComponents, const unsigned int &GPoint)
Definition: poro_condition_utilities.hpp:75
static void AssembleUBlockVector(Vector &rRightHandSideVector, const array_1d< double, 9 > &UBlockVector)
Definition: poro_condition_utilities.hpp:176
static void InterpolateVariableWithComponents(array_1d< double, 2 > &rVector, const Matrix &Ncontainer, const array_1d< double, 4 > &VariableWithComponents, const unsigned int &GPoint)
Definition: poro_condition_utilities.hpp:59
static void AssembleUPMatrix(Matrix &rLeftHandSideMatrix, const BoundedMatrix< double, 4, 2 > &UPBlockMatrix)
Definition: poro_condition_utilities.hpp:227
static void InterpolateVariableWithComponents(array_1d< double, 3 > &rVector, const Matrix &Ncontainer, const array_1d< double, 12 > &VariableWithComponents, const unsigned int &GPoint)
Definition: poro_condition_utilities.hpp:92
static void CalculateNuMatrix(BoundedMatrix< double, 2, 4 > &rNu, const Matrix &Ncontainer, const unsigned int &GPoint)
Definition: poro_condition_utilities.hpp:30
static void GetNodalVariableVector(array_1d< double, 12 > &rNodalVariableVector, const Element::GeometryType &Geom, const Variable< array_1d< double, 3 >> &Variable)
Definition: poro_condition_utilities.hpp:142
static void AssembleUBlockVector(Vector &rRightHandSideVector, const array_1d< double, 12 > &UBlockVector)
Definition: poro_condition_utilities.hpp:194
static void CalculateNuMatrix(BoundedMatrix< double, 3, 12 > &rNu, const Matrix &Ncontainer, const unsigned int &GPoint)
Definition: poro_condition_utilities.hpp:49
static void GetNodalVariableVector(array_1d< double, 4 > &rNodalVariableVector, const Element::GeometryType &Geom, const Variable< array_1d< double, 3 >> &Variable)
Definition: poro_condition_utilities.hpp:109
static void AssembleUBlockVector(Vector &rRightHandSideVector, const array_1d< double, 4 > &UBlockVector)
Definition: poro_condition_utilities.hpp:159
Variable class contains all information needed to store and retrive data from a data container.
Definition: variable.h:63
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
int j
Definition: quadrature.py:648
integer i
Definition: TensorModule.f:17