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 // KRATOS___
2 // // ) )
3 // // ___ ___
4 // // ____ //___) ) // ) )
5 // // / / // // / /
6 // ((____/ / ((____ ((___/ / MECHANICS
7 //
8 // License: geo_mechanics_application/license.txt
9 //
10 // Main authors: Ignasi de Pouplana,
11 // Vahid Galavi
12 //
13 
14 #if !defined(KRATOS_GEO_ELEMENT_UTILITIES )
15 #define KRATOS_GEO_ELEMENT_UTILITIES
16 
17 // System includes
18 //#include <cmath>
19 
20 // Project includes
21 #include "utilities/math_utils.h"
22 #include "includes/element.h"
23 
24 // Application includes
26 
27 namespace Kratos
28 {
29 
31 {
32 
33 typedef std::size_t IndexType;
34 
35 public:
36 
37  typedef Node NodeType;
39 
40 //----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
41  template< unsigned int TDim, unsigned int TNumNodes >
43  const Matrix& NContainer,
44  unsigned int GPoint)
45  {
46  for (unsigned int i=0; i < TDim; ++i) {
47  unsigned int index = i - TDim;
48  for (unsigned int j=0; j < TNumNodes; ++j) {
49  index += TDim;
50  rNu(i, index) = NContainer(GPoint, j);
51  }
52  }
53  }
54 
55 //----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
56  template< unsigned int TDim, unsigned int TNumNodes >
57  static inline void CalculateNuElementMatrix(BoundedMatrix<double, (TDim+1), TNumNodes*(TDim+1)>& rNut,
58  const Matrix& NContainer,
59  unsigned int GPoint)
60  {
61  const unsigned int offset = (TDim+1);
62 
63  for (unsigned int i=0; i < TDim; ++i) {
64  unsigned int index = i - offset;
65  for (unsigned int j=0; j < TNumNodes; ++j) {
66  index += offset;
67  rNut(i, index) = NContainer(GPoint, j);
68  }
69  }
70  }
71 
72 //----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
73  template< unsigned int TDim, unsigned int TNumNodes >
75  const Matrix& NContainer,
76  const array_1d<double, TDim*TNumNodes>& VariableWithComponents,
77  unsigned int GPoint)
78  {
79  noalias(rVector) = ZeroVector(TDim);
80 
81  unsigned int index = 0;
82  for (unsigned int i=0; i<TNumNodes; ++i) {
83  for (unsigned int j=0; j<TDim; ++j) {
84  rVector[j] += NContainer(GPoint,i)*VariableWithComponents[index++];
85  }
86  }
87  }
88 
89 //----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
90  template< unsigned int TDof, unsigned int TNumNodes >
91  static inline void InterpolateVariableWithComponents(Vector& rVector,
92  const Matrix& NContainer,
93  const Vector& VariableWithComponents,
94  unsigned int GPoint)
95  {
96  if ( rVector.size() != TDof ) rVector.resize( TDof, false );
97  KRATOS_ERROR_IF(VariableWithComponents.size() != TDof*TNumNodes) << "Wrong size in InterpolateVariableWithComponents" << std::endl;
98 
99  noalias(rVector) = ZeroVector(TDof);
100 
101  unsigned int index = 0;
102  for (unsigned int i=0; i<TNumNodes; ++i) {
103  for (unsigned int j=0; j<TDof; ++j) {
104  rVector[j] += NContainer(GPoint,i)*VariableWithComponents[index++];
105  }
106  }
107  }
108 
109 //----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
110  static inline void FillArray1dOutput(array_1d<double,3>& rOutputValue,
111  const array_1d<double,2>& ComputedValue)
112  {
113  rOutputValue[0] = ComputedValue[0];
114  rOutputValue[1] = ComputedValue[1];
115  rOutputValue[2] = 0.0;
116  }
117 
118 //----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
119  static inline void FillArray1dOutput(array_1d<double,3>& rOutputValue,
120  const array_1d<double,3>& ComputedValue)
121  {
122  rOutputValue[0] = ComputedValue[0];
123  rOutputValue[1] = ComputedValue[1];
124  rOutputValue[2] = ComputedValue[2];
125  }
126 
127 //----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
128  template< unsigned int TDim, unsigned int TNumNodes >
129  static inline void GetNodalVariableVector(array_1d<double,TDim*TNumNodes>& rNodalVariableVector,
130  const Element::GeometryType& Geom,
132  IndexType SolutionStepIndex = 0)
133  {
134  array_1d<double, 3> NodalVariableAux;
135  unsigned int index = 0;
136  for (unsigned int i=0; i < TNumNodes; ++i) {
137  noalias(NodalVariableAux) = Geom[i].FastGetSolutionStepValue(Variable, SolutionStepIndex);
138  for (unsigned int j=0; j < TDim; ++j) {
139  rNodalVariableVector[index++] = NodalVariableAux[j];
140  }
141  }
142  }
143 
144 //----------------------------------------------------------------------------------------
145  template< unsigned int TDim, unsigned int TNumNodes >
146  static inline void GetNodalVariableMatrix(Matrix& rNodalVariableMatrix,
147  const Element::GeometryType& rGeom,
149  IndexType SolutionStepIndex = 0)
150  {
151  rNodalVariableMatrix.resize(TNumNodes , TDim, false);
152 
153  for ( IndexType node = 0; node < TNumNodes; ++node ) {
154  const array_1d<double, 3>& NodalVariableAux = rGeom[node].FastGetSolutionStepValue(Variable, SolutionStepIndex);
155 
156  for ( IndexType iDim = 0; iDim < TDim; ++iDim )
157  rNodalVariableMatrix(node, iDim) = NodalVariableAux[iDim];
158  }
159  }
160 
161 //----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
162  static inline void FillPermeabilityMatrix(BoundedMatrix<double,2,2>& rPermeabilityMatrix,
163  const Element::PropertiesType& Prop)
164  {
165  //2D
166  rPermeabilityMatrix(0,0) = Prop[PERMEABILITY_XX];
167  rPermeabilityMatrix(1,1) = Prop[PERMEABILITY_YY];
168 
169  rPermeabilityMatrix(0,1) = Prop[PERMEABILITY_XY];
170  rPermeabilityMatrix(1,0) = rPermeabilityMatrix(0,1);
171  }
172 
173 //----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
174  static inline void FillPermeabilityMatrix(BoundedMatrix<double,3,3>& rPermeabilityMatrix,
175  const Element::PropertiesType& Prop)
176  {
177  //3D
178  rPermeabilityMatrix(0,0) = Prop[PERMEABILITY_XX];
179  rPermeabilityMatrix(1,1) = Prop[PERMEABILITY_YY];
180  rPermeabilityMatrix(2,2) = Prop[PERMEABILITY_ZZ];
181 
182  rPermeabilityMatrix(0,1) = Prop[PERMEABILITY_XY];
183  rPermeabilityMatrix(1,0) = rPermeabilityMatrix(0,1);
184 
185  rPermeabilityMatrix(1,2) = Prop[PERMEABILITY_YZ];
186  rPermeabilityMatrix(2,1) = rPermeabilityMatrix(1,2);
187 
188  rPermeabilityMatrix(2,0) = Prop[PERMEABILITY_ZX];
189  rPermeabilityMatrix(0,2) = rPermeabilityMatrix(2,0);
190  }
191 
192 
193 //----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
194  static inline void InvertMatrix2(BoundedMatrix<double,2,2>& rInvertedMatrix,
195  const BoundedMatrix<double,2,2>& InputMatrix,
196  double &InputMatrixDet)
197  {
198  KRATOS_TRY
199 
200  const double numerical_limit = std::numeric_limits<double>::epsilon();
201 
202  InputMatrixDet = InputMatrix(0,0)*InputMatrix(1,1)-InputMatrix(0,1)*InputMatrix(1,0);
203 
204  if (InputMatrixDet < numerical_limit) {
205  KRATOS_ERROR << "determinant zero or negative" << std::endl;
206  }
207 
208  rInvertedMatrix(0,0) = InputMatrix(1,1)/InputMatrixDet;
209  rInvertedMatrix(0,1) = -InputMatrix(0,1)/InputMatrixDet;
210  rInvertedMatrix(1,0) = -InputMatrix(1,0)/InputMatrixDet;
211  rInvertedMatrix(1,1) = InputMatrix(0,0)/InputMatrixDet;
212 
213  KRATOS_CATCH("")
214  }
215 
216 //----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
217  static inline void InvertMatrix2(BoundedMatrix<double,2,2>& rInvertedMatrix,
218  const BoundedMatrix<double,2,2>& InputMatrix)
219  {
220  KRATOS_TRY
221 
222  double InputMatrixDet;
223 
224  InvertMatrix2(rInvertedMatrix, InputMatrix, InputMatrixDet);
225 
226  KRATOS_CATCH("")
227  }
228 
229 //----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
230  template< unsigned int TDim>
232  double Density)
233  {
234  for (unsigned int idim = 0; idim < TDim; ++idim) {
235  for (unsigned int jdim = 0; jdim < TDim; ++jdim) {
236  DensityMatrix(idim, jdim) = Density;
237  }
238  }
239  }
240 
241 //----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
242  static inline void AssembleDensityMatrix(Matrix &DensityMatrix,
243  double Density)
244  {
245  for (unsigned int idim = 0; idim < DensityMatrix.size1(); ++idim) {
246  for (unsigned int jdim = 0; jdim < DensityMatrix.size2(); ++jdim) {
247  DensityMatrix(idim, jdim) = Density;
248  }
249  }
250  }
251 
252 
253 //----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
254  template< unsigned int TDim, unsigned int TNumNodes >
255  static inline void AssembleUBlockMatrix(Matrix &rLeftHandSideMatrix,
257  {
258  for (unsigned int i = 0; i < TNumNodes; ++i) {
259  const unsigned int Global_i = i * (TDim + 1);
260  const unsigned int Local_i = i * TDim;
261 
262  for (unsigned int j = 0; j < TNumNodes; ++j) {
263  const unsigned int Global_j = j * (TDim + 1);
264  const unsigned int Local_j = j * TDim;
265 
266  for (unsigned int idim = 0; idim < TDim; ++idim) {
267  for (unsigned int jdim = 0; jdim < TDim; ++jdim) {
268  rLeftHandSideMatrix(Global_i+idim, Global_j+jdim) += UBlockMatrix(Local_i+idim, Local_j+jdim);
269  }
270  }
271  }
272  }
273  }
274 
275 //----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
276  static inline void AssembleUBlockMatrix(Matrix &rLeftHandSideMatrix,
277  const Matrix &UBlockMatrix,
278  unsigned int TNumNodes,
279  unsigned int TDim)
280  {
281  for (unsigned int i = 0; i < TNumNodes; ++i) {
282  const unsigned int Global_i = i * (TDim + 1);
283  const unsigned int Local_i = i * TDim;
284 
285  for (unsigned int j = 0; j < TNumNodes; ++j) {
286  const unsigned int Global_j = j * (TDim + 1);
287  const unsigned int Local_j = j * TDim;
288 
289  for (unsigned int idim = 0; idim < TDim; ++idim) {
290  for (unsigned int jdim = 0; jdim < TDim; ++jdim) {
291  rLeftHandSideMatrix(Global_i+idim, Global_j+jdim) += UBlockMatrix(Local_i+idim, Local_j+jdim);
292  }
293  }
294  }
295  }
296  }
297 
298 //----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
299  template< unsigned int TDim, unsigned int TNumNodes >
300  static inline void AssembleUPBlockMatrix(Matrix& rLeftHandSideMatrix,
302  {
303  for (unsigned int i = 0; i < TNumNodes; ++i) {
304  const unsigned int Global_i = i * (TDim + 1);
305  const unsigned int Local_i = i * TDim;
306 
307  for (unsigned int j = 0; j < TNumNodes; ++j) {
308  const unsigned int Global_j = j * (TDim + 1) + TDim;
309 
310  for (unsigned int dim = 0; dim < TDim; ++dim) {
311  rLeftHandSideMatrix(Global_i + dim, Global_j) += UPBlockMatrix(Local_i + dim, j);
312  }
313  }
314  }
315  }
316 
317 //----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
318  template< unsigned int TDim, unsigned int TNumNodes >
319  static inline void AssemblePUBlockMatrix(Matrix& rLeftHandSideMatrix,
321  {
322  for (unsigned int i = 0; i < TNumNodes; ++i) {
323  const unsigned int Global_i = i * (TDim + 1) + TDim;
324 
325  for (unsigned int j = 0; j < TNumNodes; ++j) {
326  const unsigned int Global_j = j * (TDim + 1);
327  const unsigned int Local_j = j * TDim;
328 
329  for (unsigned int dim = 0; dim < TDim; ++dim) {
330  rLeftHandSideMatrix(Global_i, Global_j+dim) += PUBlockMatrix(i, Local_j+dim);
331  }
332  }
333  }
334  }
335 
336 //----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
337  template< unsigned int TDim, unsigned int TNumNodes >
338  static inline void AssemblePBlockMatrix(Matrix& rLeftHandSideMatrix,
339  const BoundedMatrix<double,TNumNodes,TNumNodes> &PBlockMatrix)
340  {
341  for (unsigned int i = 0; i < TNumNodes; ++i) {
342  const unsigned int Global_i = i * (TDim + 1) + TDim;
343 
344  for (unsigned int j = 0; j < TNumNodes; ++j) {
345  const unsigned int Global_j = j * (TDim + 1) + TDim;
346 
347  rLeftHandSideMatrix(Global_i,Global_j) += PBlockMatrix(i,j);
348  }
349  }
350  }
351 
352 //----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
353  template< unsigned int TDim, unsigned int TNumNodes >
354  static inline void AssembleUBlockVector(Vector& rRightHandSideVector,
355  const array_1d<double,TDim*TNumNodes>& UBlockVector,
356  unsigned int OffsetDof = 1)
357  {
358  for (unsigned int i = 0; i < TNumNodes; ++i) {
359  const unsigned int Global_i = i * (TDim + OffsetDof);
360  const unsigned int Local_i = i * TDim;
361 
362  for (unsigned int dim = 0; dim < TDim; ++dim) {
363  rRightHandSideVector[Global_i + dim] += UBlockVector[Local_i + dim];
364  }
365  }
366  }
367 
368 //----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
369  template< unsigned int TDim, unsigned int TNumNodes >
370  static inline void AssemblePBlockVector(Vector& rRightHandSideVector,
371  const array_1d<double, TNumNodes> &PBlockVector)
372  {
373  for (unsigned int i = 0; i < TNumNodes; ++i) {
374  const unsigned int Global_i = i * (TDim + 1) + TDim;
375 
376  rRightHandSideVector[Global_i] += PBlockVector[i];
377  }
378  }
379 
380 //----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
382  {
383  //Line 2-noded
384  // nodes:
385  // 0------------1
386  const unsigned int NumNodes = 2;
387  const std::vector<double> Xi{-1.0, 1.0};
388 
389  noalias(DN_DeContainer) = ZeroMatrix(NumNodes,NumNodes);
390 
391  for (unsigned int integrationPoint = 0; integrationPoint < NumNodes; ++integrationPoint) {
392  DN_DeContainer(integrationPoint,0) = - 0.5;
393  DN_DeContainer(integrationPoint,1) = 0.5;
394  }
395  }
396 
397 //----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
399  {
400  //Line 3-noded
401  // nodes:
402  // 0------2------1
403  const unsigned int NumNodes = 3;
404  const std::vector<double> Xi{-1.0, 0.0, 1.0};
405 
406  noalias(DN_DeContainer) = ZeroMatrix(NumNodes,NumNodes);
407 
408  for (unsigned int integrationPoint = 0; integrationPoint < NumNodes; ++integrationPoint) {
409  DN_DeContainer(integrationPoint,0) = Xi[integrationPoint] - 0.5;
410  DN_DeContainer(integrationPoint,1) = Xi[integrationPoint] + 0.5;
411  DN_DeContainer(integrationPoint,2) = -Xi[integrationPoint] * 2.0;
412  }
413  }
414 
415 //----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
417  {
418  //Line 3-noded
419  // nodes:
420  // 0------2------1
421  const unsigned int NumNodes = 3;
422 
423  for (unsigned int integrationPoint = 0; integrationPoint < NumNodes; ++integrationPoint) {
424  for (unsigned int node = 0; node < NumNodes; ++node) {
425  NContainer(integrationPoint,node) = (integrationPoint == node ? 1.0 : 0.0);
426  }
427  }
428  }
429 
430 //----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
432  {
433  //Line 3-noded
434  // nodes:
435  // 0------2------1
436  const unsigned int NumNodes = 3;
437  const std::vector<double> Xi{-1.0/3.0, 1.0/3.0};
438 
439  if ( NContainer.size1() != Xi.size() || NContainer.size2() != NumNodes)
440  NContainer.resize( Xi.size(), NumNodes, false );
441 
442  for (unsigned int integrationPoint = 0; integrationPoint < Xi.size(); ++integrationPoint) {
443  const double& X = Xi[integrationPoint];
444  NContainer(integrationPoint, 0) = -0.5 * (1.0 - X) * X;
445  NContainer(integrationPoint, 1) = 0.5 * (1.0 + X) * X;
446  NContainer(integrationPoint, 2) = (1.0 + X) * (1.0 - X);
447  }
448  }
449 
450 //----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
452  {
453  //Line 3-noded
454  // nodes:
455  // 0------2------1
456  const unsigned int NumNodes = 3;
457  const std::vector<double> Xi{-1.0/3.0, 1.0/3.0};
458 
459  if ( DN_DeContainer.size() != Xi.size())
460  DN_DeContainer.resize( Xi.size());
461 
462  for (unsigned int integrationPoint = 0; integrationPoint < Xi.size(); ++integrationPoint) {
463  if ( DN_DeContainer[integrationPoint].size1() != NumNodes || DN_DeContainer[integrationPoint].size2() != 1)
464  DN_DeContainer[integrationPoint].resize( NumNodes, 1);
465 
466  DN_DeContainer[integrationPoint](0,0) = Xi[integrationPoint] - 0.5;
467  DN_DeContainer[integrationPoint](1,0) = Xi[integrationPoint] + 0.5;
468  DN_DeContainer[integrationPoint](2,0) = -Xi[integrationPoint] * 2.0;
469  }
470  }
471 
479  static inline double CalculateRadius(const Vector& N, const GeometryType& Geom)
480  {
481  double Radius = 0.0;
482 
483  for (unsigned int iNode = 0; iNode < Geom.size(); ++iNode) {
484  // Displacement from the reference to the current configuration
485  const array_1d<double, 3 >& CurrentPosition = Geom[iNode].Coordinates();
486  Radius += CurrentPosition[0] * N[iNode];
487  }
488 
489  return Radius;
490  }
491 
492  static inline double CalculateAxisymmetricCircumference(const Vector& N, const GeometryType& Geom)
493  {
494  const double Radius = CalculateRadius(N, Geom);
495  const double Circumference = 2.0 * Globals::Pi * Radius;
496  return Circumference;
497  }
498 
499 
500  //----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
501  static inline void CalculateExtrapolationMatrixTriangle(Matrix& rExtrapolationMatrix, const GeometryData::IntegrationMethod& rIntegrationMethod)
502  {
506 
507  //Triangle_2d_3
508  //GI_GAUSS_2
509 
510  if (rIntegrationMethod == GeometryData::IntegrationMethod::GI_GAUSS_1)
511  {
512  if ((rExtrapolationMatrix.size1() != 3) || (rExtrapolationMatrix.size2() != 1))
513  {
514  rExtrapolationMatrix.resize(3, 1, false);
515  }
516 
517  rExtrapolationMatrix(0, 0) = 1;
518  rExtrapolationMatrix(1, 0) = 1;
519  rExtrapolationMatrix(2, 0) = 1;
520  }
521  else if (rIntegrationMethod == GeometryData::IntegrationMethod::GI_GAUSS_2)
522  {
523  if ((rExtrapolationMatrix.size1() != 3) || (rExtrapolationMatrix.size2() != 3))
524  {
525  rExtrapolationMatrix.resize(3, 3, false);
526  }
527  rExtrapolationMatrix(0, 0) = 1.6666666666666666666; rExtrapolationMatrix(0, 1) = -0.33333333333333333333; rExtrapolationMatrix(0, 2) = -0.33333333333333333333;
528  rExtrapolationMatrix(1, 0) = -0.33333333333333333333; rExtrapolationMatrix(1, 1) = 1.6666666666666666666; rExtrapolationMatrix(1, 2) = -0.33333333333333333333;
529  rExtrapolationMatrix(2, 0) = -0.33333333333333333333; rExtrapolationMatrix(2, 1) = -0.33333333333333333333; rExtrapolationMatrix(2, 2) = 1.6666666666666666666;
530  }
531  else
532  {
533  KRATOS_ERROR << "Extrapolation matrix for triangle is only defined for IntegrationMethod GI_GAUSS_1 and GI_GAUSS_2"<< std::endl;
534  }
535 
536  }
537 
538  //----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
539  static inline void CalculateExtrapolationMatrixQuad(Matrix& rExtrapolationMatrix, const GeometryData::IntegrationMethod& rIntegrationMethod)
540  {
541  if (rIntegrationMethod == GeometryData::IntegrationMethod::GI_GAUSS_1)
542  {
543  if ((rExtrapolationMatrix.size1() != 4) || (rExtrapolationMatrix.size2() != 1))
544  {
545  rExtrapolationMatrix.resize(4, 1, false);
546  }
547 
548  rExtrapolationMatrix(0, 0) = 1;
549  rExtrapolationMatrix(1, 0) = 1;
550  rExtrapolationMatrix(2, 0) = 1;
551  rExtrapolationMatrix(3, 0) = 1;
552  }
553  else if (rIntegrationMethod == GeometryData::IntegrationMethod::GI_GAUSS_2)
554  {
555  if ((rExtrapolationMatrix.size1() != 4) || (rExtrapolationMatrix.size2() != 4))
556  {
557  rExtrapolationMatrix.resize(4, 4, false);
558  }
559  //Quadrilateral_2d_4
560  //GI_GAUSS_2
561 
562  rExtrapolationMatrix(0, 0) = 1.8660254037844386; rExtrapolationMatrix(0, 1) = -0.5; rExtrapolationMatrix(0, 2) = 0.13397459621556132; rExtrapolationMatrix(0, 3) = -0.5;
563  rExtrapolationMatrix(1, 0) = -0.5; rExtrapolationMatrix(1, 1) = 1.8660254037844386; rExtrapolationMatrix(1, 2) = -0.5; rExtrapolationMatrix(1, 3) = 0.13397459621556132;
564  rExtrapolationMatrix(2, 0) = 0.13397459621556132; rExtrapolationMatrix(2, 1) = -0.5; rExtrapolationMatrix(2, 2) = 1.8660254037844386; rExtrapolationMatrix(2, 3) = -0.5;
565  rExtrapolationMatrix(3, 0) = -0.5; rExtrapolationMatrix(3, 1) = 0.13397459621556132; rExtrapolationMatrix(3, 2) = -0.5; rExtrapolationMatrix(3, 3) = 1.8660254037844386;
566  }
567  else
568  {
569  KRATOS_ERROR << "Extrapolation matrix for quad is only defined for IntegrationMethod GI_GAUSS_1 and GI_GAUSS_2" << std::endl;
570  }
571  }
572 
573 
574  static inline void CalculateExtrapolationMatrixTetra(Matrix& rExtrapolationMatrix, const GeometryData::IntegrationMethod& rIntegrationMethod)
575  {
576  if (rIntegrationMethod == GeometryData::IntegrationMethod::GI_GAUSS_1)
577  {
578  if ((rExtrapolationMatrix.size1() != 4) || (rExtrapolationMatrix.size2() != 1))
579  {
580  rExtrapolationMatrix.resize(4, 1, false);
581  }
582 
583  rExtrapolationMatrix(0, 0) = 1;
584  rExtrapolationMatrix(1, 0) = 1;
585  rExtrapolationMatrix(2, 0) = 1;
586  rExtrapolationMatrix(3, 0) = 1;
587  }
588 
589  else if (rIntegrationMethod == GeometryData::IntegrationMethod::GI_GAUSS_2)
590  {
591  if ((rExtrapolationMatrix.size1() != 4) || (rExtrapolationMatrix.size2() != 4))
592  {
593  rExtrapolationMatrix.resize(4, 4, false);
594  }
595  //Tetrahedra_3d_4
596  //GI_GAUSS_2
597  rExtrapolationMatrix(0, 0) = -0.309016988749894905; rExtrapolationMatrix(0, 1) = -0.3090169887498949046; rExtrapolationMatrix(0, 2) = -0.309016988749894905; rExtrapolationMatrix(0, 3) = 1.9270509662496847144;
598  rExtrapolationMatrix(1, 0) = 1.9270509662496847144; rExtrapolationMatrix(1, 1) = -0.30901698874989490481; rExtrapolationMatrix(1, 2) = -0.3090169887498949049; rExtrapolationMatrix(1, 3) = -0.30901698874989490481;
599  rExtrapolationMatrix(2, 0) = -0.30901698874989490473; rExtrapolationMatrix(2, 1) = 1.9270509662496847143; rExtrapolationMatrix(2, 2) = -0.3090169887498949049; rExtrapolationMatrix(2, 3) = -0.30901698874989490481;
600  rExtrapolationMatrix(3, 0) = -0.3090169887498949048; rExtrapolationMatrix(3, 1) = -0.30901698874989490471; rExtrapolationMatrix(3, 2) = 1.9270509662496847143; rExtrapolationMatrix(3, 3) = -0.30901698874989490481;
601  }
602  else
603  {
604  KRATOS_ERROR << "Extrapolation matrix for tetrahedral is only defined for IntegrationMethod GI_GAUSS_1 and GI_GAUSS_2" << std::endl;
605  }
606 
607  }
608 
609 
610  //----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
611  static inline void CalculateExtrapolationMatrixHexa(Matrix& rExtrapolationMatrix, const GeometryData::IntegrationMethod& rIntegrationMethod)
612  {
613  if (rIntegrationMethod == GeometryData::IntegrationMethod::GI_GAUSS_1)
614  {
615  if ((rExtrapolationMatrix.size1() != 8) || (rExtrapolationMatrix.size2() != 1))
616  {
617  rExtrapolationMatrix.resize(8, 1, false);
618  }
619  rExtrapolationMatrix(0, 0) = 1;
620  rExtrapolationMatrix(1, 0) = 1;
621  rExtrapolationMatrix(2, 0) = 1;
622  rExtrapolationMatrix(3, 0) = 1;
623  rExtrapolationMatrix(4, 0) = 1;
624  rExtrapolationMatrix(5, 0) = 1;
625  rExtrapolationMatrix(6, 0) = 1;
626  rExtrapolationMatrix(7, 0) = 1;
627  }
628 
629  else if (rIntegrationMethod == GeometryData::IntegrationMethod::GI_GAUSS_2)
630  {
631  if ((rExtrapolationMatrix.size1() != 8) || (rExtrapolationMatrix.size2() != 8))
632  {
633  rExtrapolationMatrix.resize(8, 8, false);
634  }
635  //Hexahedra_3d_8
636  //GI_GAUSS_2
637 
638  rExtrapolationMatrix(0, 0) = 2.549038105676658; rExtrapolationMatrix(0, 1) = -0.6830127018922192; rExtrapolationMatrix(0, 2) = 0.18301270189221927; rExtrapolationMatrix(0, 3) = -0.6830127018922192;
639  rExtrapolationMatrix(0, 4) = -0.6830127018922192; rExtrapolationMatrix(0, 5) = 0.18301270189221927; rExtrapolationMatrix(0, 6) = -0.04903810567665795; rExtrapolationMatrix(0, 7) = 0.18301270189221927;
640 
641  rExtrapolationMatrix(1, 0) = -0.6830127018922192; rExtrapolationMatrix(1, 1) = 2.549038105676658; rExtrapolationMatrix(1, 2) = -0.6830127018922192; rExtrapolationMatrix(1, 3) = 0.18301270189221927;
642  rExtrapolationMatrix(1, 4) = 0.18301270189221927; rExtrapolationMatrix(1, 5) = -0.6830127018922192; rExtrapolationMatrix(1, 6) = 0.18301270189221927; rExtrapolationMatrix(1, 7) = -0.04903810567665795;
643 
644  rExtrapolationMatrix(2, 0) = 0.18301270189221927; rExtrapolationMatrix(2, 1) = -0.6830127018922192; rExtrapolationMatrix(2, 2) = 2.549038105676658; rExtrapolationMatrix(2, 3) = -0.6830127018922192;
645  rExtrapolationMatrix(2, 4) = -0.04903810567665795; rExtrapolationMatrix(2, 5) = 0.18301270189221927; rExtrapolationMatrix(2, 6) = -0.6830127018922192; rExtrapolationMatrix(2, 7) = 0.18301270189221927;
646 
647  rExtrapolationMatrix(3, 0) = -0.6830127018922192; rExtrapolationMatrix(3, 1) = 0.18301270189221927; rExtrapolationMatrix(3, 2) = -0.6830127018922192; rExtrapolationMatrix(3, 3) = 2.549038105676658;
648  rExtrapolationMatrix(3, 4) = 0.18301270189221927; rExtrapolationMatrix(3, 5) = -0.04903810567665795; rExtrapolationMatrix(3, 6) = 0.18301270189221927; rExtrapolationMatrix(3, 7) = -0.6830127018922192;
649 
650  rExtrapolationMatrix(4, 0) = -0.6830127018922192; rExtrapolationMatrix(4, 1) = 0.18301270189221927; rExtrapolationMatrix(4, 2) = -0.04903810567665795; rExtrapolationMatrix(4, 3) = 0.18301270189221927;
651  rExtrapolationMatrix(4, 4) = 2.549038105676658; rExtrapolationMatrix(4, 5) = -0.6830127018922192; rExtrapolationMatrix(4, 6) = 0.18301270189221927; rExtrapolationMatrix(4, 7) = -0.6830127018922192;
652 
653  rExtrapolationMatrix(5, 0) = 0.18301270189221927; rExtrapolationMatrix(5, 1) = -0.6830127018922192; rExtrapolationMatrix(5, 2) = 0.18301270189221927; rExtrapolationMatrix(5, 3) = -0.04903810567665795;
654  rExtrapolationMatrix(5, 4) = -0.6830127018922192; rExtrapolationMatrix(5, 5) = 2.549038105676658; rExtrapolationMatrix(5, 6) = -0.6830127018922192; rExtrapolationMatrix(5, 7) = 0.18301270189221927;
655 
656  rExtrapolationMatrix(6, 0) = -0.04903810567665795; rExtrapolationMatrix(6, 1) = 0.18301270189221927; rExtrapolationMatrix(6, 2) = -0.6830127018922192; rExtrapolationMatrix(6, 3) = 0.18301270189221927;
657  rExtrapolationMatrix(6, 4) = 0.18301270189221927; rExtrapolationMatrix(6, 5) = -0.6830127018922192; rExtrapolationMatrix(6, 6) = 2.549038105676658; rExtrapolationMatrix(6, 7) = -0.6830127018922192;
658 
659  rExtrapolationMatrix(7, 0) = 0.18301270189221927; rExtrapolationMatrix(7, 1) = -0.04903810567665795; rExtrapolationMatrix(7, 2) = 0.18301270189221927; rExtrapolationMatrix(7, 3) = -0.6830127018922192;
660  rExtrapolationMatrix(7, 4) = -0.6830127018922192; rExtrapolationMatrix(7, 5) = 0.18301270189221927; rExtrapolationMatrix(7, 6) = -0.6830127018922192; rExtrapolationMatrix(7, 7) = 2.549038105676658;
661  }
662  else
663  {
664  KRATOS_ERROR << "Extrapolation matrix for hexahedral is only defined for IntegrationMethod GI_GAUSS_1 and GI_GAUSS_2" << std::endl;
665  }
666  }
667 
668 
669  //----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
670 
672  {
673  const auto NumericalLimit = std::numeric_limits<double>::epsilon();
674  //Defining necessary variables
675 
676  Vector nodal_hydraulic_heads(rGeom.PointsNumber());
677  for (unsigned int node = 0; node < rGeom.PointsNumber(); ++node) {
678  array_1d<double, 3> node_volume_acceleration;
679  noalias(node_volume_acceleration) = rGeom[node].FastGetSolutionStepValue(VOLUME_ACCELERATION, 0);
680  const double g = norm_2(node_volume_acceleration);
681  if (g > NumericalLimit) {
682  const double FluidWeight = g * rProp[DENSITY_WATER];
683 
684  array_1d<double, 3> NodeCoordinates;
685  noalias(NodeCoordinates) = rGeom[node].Coordinates();
686  array_1d<double, 3> NodeVolumeAccelerationUnitVector;
687  noalias(NodeVolumeAccelerationUnitVector) = node_volume_acceleration / g;
688 
689  const double WaterPressure = rGeom[node].FastGetSolutionStepValue(WATER_PRESSURE);
690  nodal_hydraulic_heads[node] = -inner_prod(NodeCoordinates, NodeVolumeAccelerationUnitVector)
691  - PORE_PRESSURE_SIGN_FACTOR * WaterPressure / FluidWeight;
692  }
693  else {
694  nodal_hydraulic_heads[node] = 0.0;
695  }
696  }
697  return nodal_hydraulic_heads;
698  }
699 
700 }; /* Class GeoElementUtilities*/
701 } /* namespace Kratos.*/
702 
703 #endif /* KRATOS_GEO_ELEMENT_UTILITIES defined */
Definition: element_utilities.hpp:31
static void AssemblePBlockVector(Vector &rRightHandSideVector, const array_1d< double, TNumNodes > &PBlockVector)
Definition: element_utilities.hpp:370
static void CalculateEquallyDistributedPointsLineShapeFunctions3N(Matrix &NContainer)
Definition: element_utilities.hpp:431
static void InvertMatrix2(BoundedMatrix< double, 2, 2 > &rInvertedMatrix, const BoundedMatrix< double, 2, 2 > &InputMatrix, double &InputMatrixDet)
Definition: element_utilities.hpp:194
static double CalculateAxisymmetricCircumference(const Vector &N, const GeometryType &Geom)
Definition: element_utilities.hpp:492
static void AssembleUPBlockMatrix(Matrix &rLeftHandSideMatrix, const BoundedMatrix< double, TDim *TNumNodes, TNumNodes > &UPBlockMatrix)
Definition: element_utilities.hpp:300
static void CalculateNewtonCotesLocalShapeFunctionsGradients(BoundedMatrix< double, 2, 2 > &DN_DeContainer)
Definition: element_utilities.hpp:381
static void CalculateEquallyDistributedPointsLineGradientShapeFunctions3N(GeometryData::ShapeFunctionsGradientsType &DN_DeContainer)
Definition: element_utilities.hpp:451
static Vector CalculateNodalHydraulicHeadFromWaterPressures(const GeometryType &rGeom, const Properties &rProp)
Definition: element_utilities.hpp:671
static double CalculateRadius(const Vector &N, const GeometryType &Geom)
Definition: element_utilities.hpp:479
static void CalculateExtrapolationMatrixHexa(Matrix &rExtrapolationMatrix, const GeometryData::IntegrationMethod &rIntegrationMethod)
Definition: element_utilities.hpp:611
static void FillPermeabilityMatrix(BoundedMatrix< double, 2, 2 > &rPermeabilityMatrix, const Element::PropertiesType &Prop)
Definition: element_utilities.hpp:162
Node NodeType
Definition: element_utilities.hpp:37
static void FillPermeabilityMatrix(BoundedMatrix< double, 3, 3 > &rPermeabilityMatrix, const Element::PropertiesType &Prop)
Definition: element_utilities.hpp:174
static void AssembleDensityMatrix(Matrix &DensityMatrix, double Density)
Definition: element_utilities.hpp:242
static void CalculateExtrapolationMatrixTetra(Matrix &rExtrapolationMatrix, const GeometryData::IntegrationMethod &rIntegrationMethod)
Definition: element_utilities.hpp:574
static void GetNodalVariableVector(array_1d< double, TDim *TNumNodes > &rNodalVariableVector, const Element::GeometryType &Geom, const Variable< array_1d< double, 3 >> &Variable, IndexType SolutionStepIndex=0)
Definition: element_utilities.hpp:129
static void CalculateNuElementMatrix(BoundedMatrix< double,(TDim+1), TNumNodes *(TDim+1)> &rNut, const Matrix &NContainer, unsigned int GPoint)
Definition: element_utilities.hpp:57
static void CalculateNewtonCotesShapeFunctions(BoundedMatrix< double, 3, 3 > &NContainer)
Definition: element_utilities.hpp:416
static void AssemblePBlockMatrix(Matrix &rLeftHandSideMatrix, const BoundedMatrix< double, TNumNodes, TNumNodes > &PBlockMatrix)
Definition: element_utilities.hpp:338
static void CalculateNuMatrix(BoundedMatrix< double, TDim, TDim *TNumNodes > &rNu, const Matrix &NContainer, unsigned int GPoint)
Definition: element_utilities.hpp:42
static void InvertMatrix2(BoundedMatrix< double, 2, 2 > &rInvertedMatrix, const BoundedMatrix< double, 2, 2 > &InputMatrix)
Definition: element_utilities.hpp:217
static void AssembleDensityMatrix(BoundedMatrix< double, TDim+1, TDim+1 > &DensityMatrix, double Density)
Definition: element_utilities.hpp:231
static void CalculateExtrapolationMatrixTriangle(Matrix &rExtrapolationMatrix, const GeometryData::IntegrationMethod &rIntegrationMethod)
Definition: element_utilities.hpp:501
static void AssembleUBlockMatrix(Matrix &rLeftHandSideMatrix, const BoundedMatrix< double, TDim *TNumNodes, TDim *TNumNodes > &UBlockMatrix)
Definition: element_utilities.hpp:255
static void AssembleUBlockVector(Vector &rRightHandSideVector, const array_1d< double, TDim *TNumNodes > &UBlockVector, unsigned int OffsetDof=1)
Definition: element_utilities.hpp:354
static void AssemblePUBlockMatrix(Matrix &rLeftHandSideMatrix, const BoundedMatrix< double, TNumNodes, TNumNodes *TDim > &PUBlockMatrix)
Definition: element_utilities.hpp:319
static void FillArray1dOutput(array_1d< double, 3 > &rOutputValue, const array_1d< double, 2 > &ComputedValue)
Definition: element_utilities.hpp:110
static void CalculateNewtonCotesLocalShapeFunctionsGradients(BoundedMatrix< double, 3, 3 > &DN_DeContainer)
Definition: element_utilities.hpp:398
static void GetNodalVariableMatrix(Matrix &rNodalVariableMatrix, const Element::GeometryType &rGeom, const Variable< array_1d< double, 3 >> &Variable, IndexType SolutionStepIndex=0)
Definition: element_utilities.hpp:146
static void InterpolateVariableWithComponents(array_1d< double, TDim > &rVector, const Matrix &NContainer, const array_1d< double, TDim *TNumNodes > &VariableWithComponents, unsigned int GPoint)
Definition: element_utilities.hpp:74
static void FillArray1dOutput(array_1d< double, 3 > &rOutputValue, const array_1d< double, 3 > &ComputedValue)
Definition: element_utilities.hpp:119
static void AssembleUBlockMatrix(Matrix &rLeftHandSideMatrix, const Matrix &UBlockMatrix, unsigned int TNumNodes, unsigned int TDim)
Definition: element_utilities.hpp:276
Geometry< NodeType > GeometryType
Definition: element_utilities.hpp:38
static void CalculateExtrapolationMatrixQuad(Matrix &rExtrapolationMatrix, const GeometryData::IntegrationMethod &rIntegrationMethod)
Definition: element_utilities.hpp:539
static void InterpolateVariableWithComponents(Vector &rVector, const Matrix &NContainer, const Vector &VariableWithComponents, unsigned int GPoint)
Definition: element_utilities.hpp:91
IntegrationMethod
Definition: geometry_data.h:76
Geometry base class.
Definition: geometry.h:71
SizeType PointsNumber() const
Definition: geometry.h:528
SizeType size() const
Definition: geometry.h:518
Definition: amatrix_interface.h:41
void resize(std::size_t NewSize1, std::size_t NewSize2, bool preserve=0)
Definition: amatrix_interface.h:224
This class defines the node.
Definition: node.h:65
Properties encapsulates data shared by different Elements or Conditions. It can store any type of dat...
Definition: properties.h:69
Variable class contains all information needed to store and retrive data from a data container.
Definition: variable.h:63
#define KRATOS_CATCH(MoreInfo)
Definition: define.h:110
#define KRATOS_TRY
Definition: define.h:109
#define KRATOS_ERROR
Definition: exception.h:161
#define KRATOS_ERROR_IF(conditional)
Definition: exception.h:162
constexpr double Pi
Definition: global_variables.h:25
REF: G. R. Cowper, GAUSSIAN QUADRATURE FORMULAS FOR TRIANGLES.
Definition: mesh_condition.cpp:21
KratosZeroVector< double > ZeroVector
Definition: amatrix_interface.h:561
TExpressionType::data_type norm_2(AMatrix::MatrixExpression< TExpressionType, TCategory > const &TheExpression)
Definition: amatrix_interface.h:625
KratosZeroMatrix< double > ZeroMatrix
Definition: amatrix_interface.h:559
constexpr double PORE_PRESSURE_SIGN_FACTOR
Definition: geo_mechanics_application_constants.h:34
TExpression1Type::data_type inner_prod(AMatrix::MatrixExpression< TExpression1Type, TCategory1 > const &First, AMatrix::MatrixExpression< TExpression2Type, TCategory2 > const &Second)
Definition: amatrix_interface.h:592
T & noalias(T &TheMatrix)
Definition: amatrix_interface.h:484
int j
Definition: quadrature.py:648
N
Definition: sensitivityMatrix.py:29
int dim
Definition: sensitivityMatrix.py:25
integer i
Definition: TensorModule.f:17
Definition: mesh_converter.cpp:38