1 #if !defined(KRATOS_MESH_ROTATION_UTILITY)
2 #define KRATOS_MESH_ROTATION_UTILITY
25 mOmega = r_parameters[
"frame_of_reference"][
"angular_velocity_magnitude"].
GetDouble();
26 mAInit = r_parameters[
"frame_of_reference"][
"frame_rotation_axis_initial_point"].
GetVector();
27 mAFinal = r_parameters[
"frame_of_reference"][
"frame_rotation_axis_final_point"].
GetVector();
28 mAxisVersor = CalculateNormalized(mAFinal - mAInit);
31 mI = identity_matrix<double>(3);
33 for (
int i = 0;
i < 3; ++
i){
34 for (
int j = 0;
j < 3; ++
j){
35 mUU(
i,
j) = mAxisVersor[
i] * mAxisVersor[
j];
40 mUx(0, 1) = - mAxisVersor[2];
41 mUx(0, 2) = mAxisVersor[1];
42 mUx(1, 0) = mAxisVersor[2];
43 mUx(1, 2) = - mAxisVersor[0];
44 mUx(2, 0) = - mAxisVersor[1];
45 mUx(2, 1) = mAxisVersor[0];
52 CalculateRodriguesMatrices(
time);
61 #pragma omp parallel for private(P0, P)
63 auto it = it_begin +
i;
64 RotateNode(*(it.base()), P0, P);
75 CalculateRodriguesMatrices(
time);
82 #pragma omp parallel for private(P0, P)
84 auto it = it_begin +
i;
85 RotateNode(*(it.base()), P0, P);
88 it->Fix(DISPLACEMENT_X);
89 it->Fix(DISPLACEMENT_Y);
90 it->Fix(DISPLACEMENT_Z);
102 mpStationaryModelPart = &r_model_part;
103 mStationaryTime =
time;
105 mStationaryVelocities.resize(
nnodes);
110 #pragma omp parallel for
112 auto it = it_begin +
i;
113 noalias(mStationaryVelocities[
i]) = it->FastGetSolutionStepValue(VELOCITY);
120 CalculateRodriguesMatrices(
time, mStationaryTime);
122 const int nnodes = mpStationaryModelPart->
Nodes().size();
125 auto it_begin = mpStationaryModelPart->
NodesBegin();
127 #pragma omp parallel for
129 auto it = it_begin +
i;
131 RotateVector(mStationaryVelocities[
i],
velocity);
138 void CalculateRodriguesMatrices(
const double time,
const double initial_time=0.0)
141 double sin_theta = std::sin(
delta_time * mOmega);
142 double cos_theta = std::cos(
delta_time * mOmega);
145 noalias(mR) = cos_theta * mI + sin_theta * mUx + (1.0 - cos_theta) * mUU;
148 noalias(mRp) = - mOmega * sin_theta * mI + mOmega * cos_theta * mUx + mOmega * sin_theta * mUU;
151 void RotateNode(Kratos::Node::Pointer p_node, array_1d<double, 3>& P0, array_1d<double, 3>& P)
153 P0[0] = p_node->X0();
154 P0[1] = p_node->Y0();
155 P0[2] = p_node->Z0();
162 void RotateVector(
const array_1d<double, 3>& initial_vector, array_1d<double, 3>& vector)
164 noalias(vector) = mAInit +
prod(mR, initial_vector - mAInit);
167 array_1d<double, 3> CalculateNormalized(array_1d<double, 3>&& vector)
169 const double norm =
norm_2(vector);
172 vector *= 1.0 / norm;
179 double mStationaryTime;
180 array_1d<double, 3> mAInit;
181 array_1d<double, 3> mAFinal;
182 array_1d<double, 3> mAxisVersor;
183 BoundedMatrix<double, 3, 3> mI;
184 BoundedMatrix<double, 3, 3> mUU;
185 BoundedMatrix<double, 3, 3> mUx;
186 BoundedMatrix<double, 3, 3> mR;
187 BoundedMatrix<double, 3, 3> mRp;
188 std::vector<array_1d<double, 3> > mStationaryVelocities;
Definition: mesh_rotation_utility.h:17
void RotateMesh(ModelPart &r_model_part, double time)
Definition: mesh_rotation_utility.h:50
virtual ~MeshRotationUtility()
Definition: mesh_rotation_utility.h:48
MeshRotationUtility(Parameters &r_parameters)
Definition: mesh_rotation_utility.h:23
void SetStationaryField(ModelPart &r_model_part, const double time)
Definition: mesh_rotation_utility.h:100
KRATOS_CLASS_POINTER_DEFINITION(MeshRotationUtility)
void RotateFluidVelocities(const double time)
Definition: mesh_rotation_utility.h:118
void RotateDEMMesh(ModelPart &r_model_part, double time)
Definition: mesh_rotation_utility.h:73
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
NodesContainerType & Nodes(IndexType ThisIndex=0)
Definition: model_part.h:507
This class provides to Kratos a data structure for I/O based on the standard of JSON.
Definition: kratos_parameters.h:59
double GetDouble() const
This method returns the double contained in the current Parameter.
Definition: kratos_parameters.cpp:657
Vector GetVector() const
This method returns the vector contained in the current Parameter.
Definition: kratos_parameters.cpp:707
Kratos::ModelPart ModelPart
Definition: kratos_wrapper.h:31
REF: G. R. Cowper, GAUSSIAN QUADRATURE FORMULAS FOR TRIANGLES.
Definition: mesh_condition.cpp:21
TExpressionType::data_type norm_2(AMatrix::MatrixExpression< TExpressionType, TCategory > const &TheExpression)
Definition: amatrix_interface.h:625
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
T & noalias(T &TheMatrix)
Definition: amatrix_interface.h:484
float velocity
Definition: PecletTest.py:54
initial_time
Definition: dam_analysis.py:4
time
Definition: face_heat.py:85
delta_time
Definition: generate_frictional_mortar_condition.py:130
int j
Definition: quadrature.py:648
int nnodes
Definition: sensitivityMatrix.py:24
integer i
Definition: TensorModule.f:17