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.
condition_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_CONDITION_UTILITIES )
15 #define KRATOS_CONDITION_UTILITIES
16 
17 // Project includes
18 #include "includes/element.h"
20 
21 
22 namespace Kratos
23 {
24 
26 {
27 
28 public:
29 
30  //----------------------------------------------------------------------------------------
31  template< unsigned int TDim, unsigned int TNumNodes >
33  const Matrix& NContainer,
34  const unsigned int& GPoint)
35  {
36  for (unsigned int i=0; i < TDim; ++i) {
37  unsigned int index = i - TDim;
38  for (unsigned int j=0; j < TNumNodes; ++j) {
39  index += TDim;
40  rNu(i, index) = NContainer(GPoint, j);
41  }
42  }
43  }
44 
45  //----------------------------------------------------------------------------------------
46  template< unsigned int TDim, unsigned int TNumNodes >
48  const Matrix& Ncontainer,
49  const array_1d<double,TDim*TNumNodes>& VariableWithComponents,
50  const unsigned int& GPoint)
51  {
52  noalias(rVector) = ZeroVector(TDim);
53 
54  unsigned int index = 0;
55  for (unsigned int i=0; i<TNumNodes; ++i) {
56  for (unsigned int idim=0; idim<TDim; ++idim) {
57  rVector[idim] += Ncontainer(GPoint,i)*VariableWithComponents[index++];
58  }
59  }
60  }
61 
62  //----------------------------------------------------------------------------------------
63  static inline void GetDisplacementsVector(array_1d<double,4>& rDisplacementVector,
64  const Element::GeometryType& Geom)
65  {
66  //Line_2d_2
67  array_1d<double,3> DisplacementAux;
68  unsigned int index = 0;
69  for (unsigned int i=0; i<2; ++i) {
70  noalias(DisplacementAux) = Geom[i].FastGetSolutionStepValue(DISPLACEMENT);
71  rDisplacementVector[index++] = DisplacementAux[0];
72  rDisplacementVector[index++] = DisplacementAux[1];
73  }
74  }
75 
76  //----------------------------------------------------------------------------------------
77  static inline void GetDisplacementsVector(array_1d<double,12>& rDisplacementVector,
78  const Element::GeometryType& Geom)
79  {
80  //Quadrilateral_3d_4
81  array_1d<double,3> DisplacementAux;
82  unsigned int index = 0;
83  for (unsigned int i=0; i<4; ++i) {
84  noalias(DisplacementAux) = Geom[i].FastGetSolutionStepValue(DISPLACEMENT);
85  rDisplacementVector[index++] = DisplacementAux[0];
86  rDisplacementVector[index++] = DisplacementAux[1];
87  rDisplacementVector[index++] = DisplacementAux[2];
88  }
89  }
90 
91  //----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
92  template<unsigned int TNumNodes >
93  static inline void GetFaceLoadVector(array_1d<double,3*TNumNodes>& rFaceLoadVector,
94  const Element::GeometryType& Geom)
95  {
96 
97  // for 3D geometry
98  const unsigned int TDim = 3;
99  array_1d<double,3> FaceLoadAux;
100  unsigned int index = 0;
101  for (unsigned int i=0; i<TNumNodes; ++i) {
102  noalias(FaceLoadAux) = Geom[i].FastGetSolutionStepValue(SURFACE_LOAD);
103  for (unsigned int idim=0; idim<TDim; ++idim) {
104  rFaceLoadVector[index++] = FaceLoadAux[idim];
105  }
106  }
107  }
108 
109  //----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
110  template<unsigned int TNumNodes >
111  static inline void GetFaceLoadVector(array_1d<double,2*TNumNodes>& rFaceLoadVector,
112  const Element::GeometryType& Geom)
113  {
114 
115  // for 2D geometry
116  const unsigned int TDim = 2;
117  array_1d<double,3> FaceLoadAux;
118  unsigned int index = 0;
119  for (unsigned int i=0; i<TNumNodes; ++i) {
120  noalias(FaceLoadAux) = Geom[i].FastGetSolutionStepValue(LINE_LOAD);
121  for (unsigned int idim=0; idim < TDim; ++idim) {
122  rFaceLoadVector[index++] = FaceLoadAux[idim];
123  }
124  }
125  }
126 
127  //----------------------------------------------------------------------------------------
128  template< unsigned int TDim, unsigned int TNumNodes >
129  static inline void AssembleUBlockVector(Vector& rRightHandSideVector,
130  const array_1d<double, TDim*TNumNodes>& UBlockVector)
131  {
132  unsigned int Global_i, Local_i;
133 
134  for (unsigned int i = 0; i < TNumNodes; ++i) {
135  Global_i = i * (TDim + 1);
136  Local_i = i * TDim;
137  for (unsigned int idim = 0; idim < TDim; ++idim) {
138  rRightHandSideVector[Global_i + idim] += UBlockVector[Local_i + idim];
139  }
140  }
141  }
142 
143  //----------------------------------------------------------------------------------------
144  template< class TVectorType >
145  static inline void AssemblePBlockVector(Vector& rRightHandSideVector,
146  const TVectorType& PBlockVector,
147  const unsigned int& Dim,
148  const unsigned int& NumNodes)
149  {
150  unsigned int Global_i;
151 
152  for (unsigned int i = 0; i < NumNodes; ++i) {
153  Global_i = i * (Dim + 1) + Dim;
154 
155  rRightHandSideVector[Global_i] += PBlockVector[i];
156  }
157  }
158 
159  //----------------------------------------------------------------------------------------
160  template< unsigned int TDim, unsigned int TNumNodes >
161  static inline void AssembleUPMatrix(Matrix& rLeftHandSideMatrix,
163  {
164  //Quadrilateral_3d_4
165  unsigned int Global_i, Global_j, Local_i;
166 
167  for (unsigned int i = 0; i < TNumNodes; ++i) {
168  Global_i = i * (TDim + 1);
169  Local_i = i * TDim;
170 
171  for (unsigned int j = 0; j < TNumNodes; ++j) {
172  Global_j = j * (TDim + 1) + TDim;
173  for (unsigned int idim = 0; idim < TDim; ++idim) {
174  rLeftHandSideMatrix(Global_i+idim, Global_j) += UPBlockMatrix(Local_i+idim, j);
175  }
176  }
177  }
178  }
179 
180  //----------------------------------------------------------------------------------------
181  template< unsigned int TDim, unsigned int TNumNodes >
182  static inline void AssemblePUMatrix(Matrix& rLeftHandSideMatrix,
184  {
185  //Quadrilateral_3d_4
186  unsigned int Global_i, Global_j, Local_j;
187 
188  for (unsigned int i = 0; i < TNumNodes; ++i) {
189  Global_i = i * (TDim + 1) + TDim;
190 
191  for (unsigned int j = 0; j < TNumNodes; ++j) {
192  Global_j = j * (TDim + 1);
193  Local_j = j * TDim;
194  for (unsigned int idim = 0; idim < TDim; ++idim) {
195  rLeftHandSideMatrix(Global_i, Global_j+idim) += PUBlockMatrix(i, Local_j+idim);
196  }
197  }
198  }
199  }
200 
201  template <unsigned int TDim, unsigned int TNumNodes>
202  static double CalculateIntegrationCoefficient(const Matrix& rJacobian, double Weight)
203  {
204  auto normal_vector = Vector{TDim, 0.0};
205 
206  if constexpr (TDim == 2)
207  {
208  normal_vector = column(rJacobian, 0);
209  }
210  else if constexpr (TDim == 3)
211  {
212  MathUtils<>::CrossProduct(normal_vector, column(rJacobian, 0),
213  column(rJacobian, 1));
214  }
215  return Weight * MathUtils<>::Norm(normal_vector);
216  }
217 
218 }; /* Class ConditionUtilities*/
219 } /* namespace Kratos.*/
220 
221 #endif /* KRATOS_CONDITION_UTILITIES defined */
Definition: condition_utilities.hpp:26
static void AssembleUBlockVector(Vector &rRightHandSideVector, const array_1d< double, TDim *TNumNodes > &UBlockVector)
Definition: condition_utilities.hpp:129
static void AssemblePBlockVector(Vector &rRightHandSideVector, const TVectorType &PBlockVector, const unsigned int &Dim, const unsigned int &NumNodes)
Definition: condition_utilities.hpp:145
static void AssemblePUMatrix(Matrix &rLeftHandSideMatrix, const BoundedMatrix< double, TNumNodes, TDim *TNumNodes > &PUBlockMatrix)
Definition: condition_utilities.hpp:182
static void GetDisplacementsVector(array_1d< double, 4 > &rDisplacementVector, const Element::GeometryType &Geom)
Definition: condition_utilities.hpp:63
static double CalculateIntegrationCoefficient(const Matrix &rJacobian, double Weight)
Definition: condition_utilities.hpp:202
static void GetDisplacementsVector(array_1d< double, 12 > &rDisplacementVector, const Element::GeometryType &Geom)
Definition: condition_utilities.hpp:77
static void InterpolateVariableWithComponents(array_1d< double, TDim > &rVector, const Matrix &Ncontainer, const array_1d< double, TDim *TNumNodes > &VariableWithComponents, const unsigned int &GPoint)
Definition: condition_utilities.hpp:47
static void AssembleUPMatrix(Matrix &rLeftHandSideMatrix, const BoundedMatrix< double, TDim *TNumNodes, TNumNodes > &UPBlockMatrix)
Definition: condition_utilities.hpp:161
static void CalculateNuMatrix(BoundedMatrix< double, TDim, TDim *TNumNodes > &rNu, const Matrix &NContainer, const unsigned int &GPoint)
Definition: condition_utilities.hpp:32
static void GetFaceLoadVector(array_1d< double, 2 *TNumNodes > &rFaceLoadVector, const Element::GeometryType &Geom)
Definition: condition_utilities.hpp:111
static void GetFaceLoadVector(array_1d< double, 3 *TNumNodes > &rFaceLoadVector, const Element::GeometryType &Geom)
Definition: condition_utilities.hpp:93
Geometry base class.
Definition: geometry.h:71
Definition: amatrix_interface.h:41
static T CrossProduct(const T &a, const T &b)
Performs the vector product of the two input vectors a,b.
Definition: math_utils.h:762
static double Norm(const Vector &a)
Calculates the norm of vector "a".
Definition: math_utils.h:703
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
AMatrix::MatrixColumn< const TExpressionType > column(AMatrix::MatrixExpression< TExpressionType, TCategory > const &TheExpression, std::size_t ColumnIndex)
Definition: amatrix_interface.h:637
int j
Definition: quadrature.py:648
integer i
Definition: TensorModule.f:17