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.
compressible_element_rotation_utility.h
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: Jordi Cotela
11 //
12 
13 
14 #ifndef KRATOS_COMPRESSIBLE_ELEMENT_ROTATION_UTILITY
15 #define KRATOS_COMPRESSIBLE_ELEMENT_ROTATION_UTILITY
16 
17 // system includes
18 
19 // external includes
20 
21 // kratos includes
22 #include "includes/define.h"
23 #include "includes/node.h"
24 #include "containers/variable.h"
25 #include "geometries/geometry.h"
27 
28 namespace Kratos {
29 
32 
35 
39 
43 
47 
51 
53 template<class TLocalMatrixType, class TLocalVectorType>
54 class CompressibleElementRotationUtility: public CoordinateTransformationUtils<TLocalMatrixType,TLocalVectorType,double> {
55 public:
58 
61 
62  typedef Node NodeType;
63 
65 
69 
71 
77  const unsigned int DomainSize,
78  const Kratos::Flags& rFlag = SLIP):
79  CoordinateTransformationUtils<TLocalMatrixType,TLocalVectorType,double>(DomainSize,DomainSize+2,rFlag)
80  {}
81 
84 
88 
92 
94 
99  void Rotate(
100  TLocalMatrixType& rLocalMatrix,
101  TLocalVectorType& rLocalVector,
102  GeometryType& rGeometry) const override
103  {
104  if (this->GetDomainSize() == 2) this->template RotateAux<2,4,1>(rLocalMatrix,rLocalVector,rGeometry);
105  else if (this->GetDomainSize() == 3) this->template RotateAux<3,5,1>(rLocalMatrix,rLocalVector,rGeometry);
106  }
107 
109  void Rotate(
110  TLocalVectorType& rLocalVector,
111  GeometryType& rGeometry) const override
112  {
113  TLocalMatrixType dummy = ZeroMatrix(rLocalVector.size(),rLocalVector.size());
114  if (this->GetDomainSize() == 2) this->template RotateAux<2,4,1>(dummy,rLocalVector,rGeometry);
115  else if (this->GetDomainSize() == 3) this->template RotateAux<3,5,1>(dummy,rLocalVector,rGeometry);
116  }
117 
119 
124  void ApplySlipCondition(TLocalMatrixType& rLocalMatrix,
125  TLocalVectorType& rLocalVector,
126  GeometryType& rGeometry) const override
127  {
128  const unsigned int LocalSize = rLocalVector.size(); // We expect this to work both with elements (4 nodes) and conditions (3 nodes)
129 
130  if (LocalSize > 0)
131  {
132  for(unsigned int itNode = 0; itNode < rGeometry.PointsNumber(); ++itNode)
133  {
134  if(this->IsSlip(rGeometry[itNode]) )
135  {
136  // We fix the first momentum dof (normal component) for each rotated block
137  unsigned int j = itNode * this->GetBlockSize() + 1; // +1 assumes DOF ordering as density-momentum-energy
138 
139  for( unsigned int i = 0; i < j; ++i)// Skip term (i,i)
140  {
141  rLocalMatrix(i,j) = 0.0;
142  rLocalMatrix(j,i) = 0.0;
143  }
144  for( unsigned int i = j+1; i < LocalSize; ++i)
145  {
146  rLocalMatrix(i,j) = 0.0;
147  rLocalMatrix(j,i) = 0.0;
148  }
149 
150  rLocalVector(j) = 0.0;
151  rLocalMatrix(j,j) = 1.0;
152  }
153  }
154  }
155  }
156 
158  void ApplySlipCondition(TLocalVectorType& rLocalVector,
159  GeometryType& rGeometry) const override
160  {
161  if (rLocalVector.size() > 0)
162  {
163  for(unsigned int itNode = 0; itNode < rGeometry.PointsNumber(); ++itNode)
164  {
165  if( this->IsSlip(rGeometry[itNode]) )
166  {
167  // We fix the first momentum dof (normal component) for each rotated block
168  unsigned int j = itNode * this->GetBlockSize() + 1; // +1 assumes DOF ordering as density-momentum-energy
169  rLocalVector[j] = 0.0;
170  }
171  }
172  }
173  }
174 
176  void RotateVelocities(ModelPart& rModelPart) const override
177  {
178  TLocalVectorType momentum(this->GetDomainSize());
179  TLocalVectorType Tmp(this->GetDomainSize());
180 
181  ModelPart::NodeIterator it_begin = rModelPart.NodesBegin();
182 #pragma omp parallel for firstprivate(momentum,Tmp)
183  for(int iii=0; iii<static_cast<int>(rModelPart.Nodes().size()); iii++)
184  {
185  ModelPart::NodeIterator itNode = it_begin+iii;
186  if( this->IsSlip(*itNode) )
187  {
188  //this->RotationOperator<TLocalMatrixType>(Rotation,);
189  if(this->GetDomainSize() == 3)
190  {
192  this->LocalRotationOperatorPure(rRot,*itNode);
193 
194  array_1d<double,3>& rMomentum = itNode->FastGetSolutionStepValue(MOMENTUM);
195  for(unsigned int i = 0; i < 3; i++) momentum[i] = rMomentum[i];
196  noalias(Tmp) = prod(rRot,momentum);
197  for(unsigned int i = 0; i < 3; i++) rMomentum[i] = Tmp[i];
198  }
199  else
200  {
202  this->LocalRotationOperatorPure(rRot,*itNode);
203 
204  array_1d<double,3>& rMomentum = itNode->FastGetSolutionStepValue(MOMENTUM);
205  for(unsigned int i = 0; i < 2; i++) momentum[i] = rMomentum[i];
206  noalias(Tmp) = prod(rRot,momentum);
207  for(unsigned int i = 0; i < 2; i++) rMomentum[i] = Tmp[i];
208  }
209  }
210  }
211  }
212 
214  void RecoverVelocities(ModelPart& rModelPart) const override
215  {
216  TLocalVectorType momentum(this->GetDomainSize());
217  TLocalVectorType Tmp(this->GetDomainSize());
218 
219  ModelPart::NodeIterator it_begin = rModelPart.NodesBegin();
220 #pragma omp parallel for firstprivate(momentum,Tmp)
221  for(int iii=0; iii<static_cast<int>(rModelPart.Nodes().size()); iii++)
222  {
223  ModelPart::NodeIterator itNode = it_begin+iii;
224  if( this->IsSlip(*itNode) )
225  {
226  if(this->GetDomainSize() == 3)
227  {
229  this->LocalRotationOperatorPure(rRot,*itNode);
230 
231  array_1d<double,3>& rMomentum = itNode->FastGetSolutionStepValue(MOMENTUM);
232  for(unsigned int i = 0; i < 3; i++) momentum[i] = rMomentum[i];
233  noalias(Tmp) = prod(trans(rRot),momentum);
234  for(unsigned int i = 0; i < 3; i++) rMomentum[i] = Tmp[i];
235  }
236  else
237  {
239  this->LocalRotationOperatorPure(rRot,*itNode);
240 
241  array_1d<double,3>& rMomentum = itNode->FastGetSolutionStepValue(MOMENTUM);
242  for(unsigned int i = 0; i < 2; i++) momentum[i] = rMomentum[i];
243  noalias(Tmp) = prod(trans(rRot),momentum);
244  for(unsigned int i = 0; i < 2; i++) rMomentum[i] = Tmp[i];
245  }
246  }
247  }
248  }
249 
253 
257 
261 
263  std::string Info() const override
264  {
265  std::stringstream buffer;
266  buffer << "CompressibleElementRotationUtility";
267  return buffer.str();
268  }
269 
271  void PrintInfo(std::ostream& rOStream) const override
272  {
273  rOStream << "CompressibleElementRotationUtility";
274  }
275 
277  void PrintData(std::ostream& rOStream) const override {}
278 
282 
284 
285 protected:
288 
292 
296 
300 
304 
308 
312 
314 
315 private:
318 
322 
326 
330 
334 
338 
342 
345 
348 
350 };
351 
353 
356 
360 
362 template<class TLocalMatrixType, class TLocalVectorType>
363 inline std::istream& operator >>(std::istream& rIStream,
365  return rIStream;
366 }
367 
369 template<class TLocalMatrixType, class TLocalVectorType>
370 inline std::ostream& operator <<(std::ostream& rOStream,
372  rThis.PrintInfo(rOStream);
373  rOStream << std::endl;
374  rThis.PrintData(rOStream);
375 
376  return rOStream;
377 }
378 
380 
382 
383 }
384 
385 #endif // KRATOS_COMPRESSIBLE_ELEMENT_ROTATION_UTILITY
A utility to rotate the local contributions of certain nodes to the system matrix,...
Definition: compressible_element_rotation_utility.h:54
~CompressibleElementRotationUtility() override
Destructor.
Definition: compressible_element_rotation_utility.h:83
void ApplySlipCondition(TLocalVectorType &rLocalVector, GeometryType &rGeometry) const override
RHS only version of ApplySlipCondition.
Definition: compressible_element_rotation_utility.h:158
Node NodeType
Definition: compressible_element_rotation_utility.h:62
Geometry< Node > GeometryType
Definition: compressible_element_rotation_utility.h:64
CompressibleElementRotationUtility(const unsigned int DomainSize, const Kratos::Flags &rFlag=SLIP)
Constructor.
Definition: compressible_element_rotation_utility.h:76
void RecoverVelocities(ModelPart &rModelPart) const override
Transform nodal velocities from the rotated system to the original one.
Definition: compressible_element_rotation_utility.h:214
std::string Info() const override
Turn back information as a string.
Definition: compressible_element_rotation_utility.h:263
void Rotate(TLocalMatrixType &rLocalMatrix, TLocalVectorType &rLocalVector, GeometryType &rGeometry) const override
Rotate the local system contributions so that they are oriented with each node's normal.
Definition: compressible_element_rotation_utility.h:99
void RotateVelocities(ModelPart &rModelPart) const override
Transform nodal velocities to the rotated coordinates (aligned with each node's normal)
Definition: compressible_element_rotation_utility.h:176
void Rotate(TLocalVectorType &rLocalVector, GeometryType &rGeometry) const override
RHS only version of Rotate.
Definition: compressible_element_rotation_utility.h:109
void ApplySlipCondition(TLocalMatrixType &rLocalMatrix, TLocalVectorType &rLocalVector, GeometryType &rGeometry) const override
Apply slip boundary conditions to the rotated local contributions.
Definition: compressible_element_rotation_utility.h:124
KRATOS_CLASS_POINTER_DEFINITION(CompressibleElementRotationUtility)
Pointer definition of CompressibleElementRotationUtility.
void PrintData(std::ostream &rOStream) const override
Print object's data.
Definition: compressible_element_rotation_utility.h:277
void PrintInfo(std::ostream &rOStream) const override
Print information about this object.
Definition: compressible_element_rotation_utility.h:271
Definition: coordinate_transformation_utilities.h:57
bool IsSlip(const Node &rNode) const
Definition: coordinate_transformation_utilities.h:983
unsigned int GetBlockSize() const
Definition: coordinate_transformation_utilities.h:1014
void LocalRotationOperatorPure(BoundedMatrix< double, 3, 3 > &rRot, const GeometryType::PointType &rThisPoint) const
Definition: coordinate_transformation_utilities.h:138
unsigned int GetDomainSize() const
Definition: coordinate_transformation_utilities.h:1009
Definition: flags.h:58
Geometry base class.
Definition: geometry.h:71
SizeType PointsNumber() const
Definition: geometry.h:528
Definition: amatrix_interface.h:41
This class aims to manage meshes for multi-physics simulations.
Definition: model_part.h:77
NodeIterator NodesBegin(IndexType ThisIndex=0)
Definition: model_part.h:487
MeshType::NodeIterator NodeIterator
Definition: model_part.h:134
NodesContainerType & Nodes(IndexType ThisIndex=0)
Definition: model_part.h:507
This class defines the node.
Definition: node.h:65
REF: G. R. Cowper, GAUSSIAN QUADRATURE FORMULAS FOR TRIANGLES.
Definition: mesh_condition.cpp:21
KratosZeroMatrix< double > ZeroMatrix
Definition: amatrix_interface.h:559
AMatrix::MatrixProductExpression< TExpression1Type, TExpression2Type > prod(AMatrix::MatrixExpression< TExpression1Type, TCategory1 > const &First, AMatrix::MatrixExpression< TExpression2Type, TCategory2 > const &Second)
Definition: amatrix_interface.h:568
std::istream & operator>>(std::istream &rIStream, LinearMasterSlaveConstraint &rThis)
input stream function
T & noalias(T &TheMatrix)
Definition: amatrix_interface.h:484
AMatrix::TransposeMatrix< const T > trans(const T &TheMatrix)
Definition: amatrix_interface.h:486
TABLE_NUMBER_ANGULAR_VELOCITY TABLE_NUMBER_MOMENT I33 BEAM_INERTIA_ROT_UNIT_LENGHT_Y KRATOS_DEFINE_APPLICATION_VARIABLE(DEM_APPLICATION, double, BEAM_INERTIA_ROT_UNIT_LENGHT_Z) typedef std double
Definition: DEM_application_variables.h:182
std::ostream & operator<<(std::ostream &rOStream, const LinearMasterSlaveConstraint &rThis)
output stream function
Definition: linear_master_slave_constraint.h:432
int j
Definition: quadrature.py:648
dummy
Definition: script.py:194
integer i
Definition: TensorModule.f:17