10 #if !defined(KRATOS_ASSIGN_ROTATION_FIELD_ABOUT_AN_AXIS_TO_NODES_PROCESS_H_INCLUDED)
11 #define KRATOS_ASSIGN_ROTATION_FIELD_ABOUT_AN_AXIS_TO_NODES_PROCESS_H_INCLUDED
44 pybind11::object& rPyObject,
45 const std::string& rPyMethodName,
46 const bool SpatialFieldFunction,
54 "model_part_name":"MODEL_PART_NAME",
55 "variable_name": "VARIABLE_NAME",
66 mPyObject = rPyObject;
67 mPyMethodName = rPyMethodName;
69 mIsSpatialField = SpatialFieldFunction;
71 for(
unsigned int i=0;
i<3;
i++)
112 if( ! mIsSpatialField ){
115 const double& rCurrentTime = rCurrentProcessInfo[TIME];
117 const double& rPreviousTime = rPreviousProcessInfo[TIME];
120 this->CallTimeFunction(rCurrentTime,
mvalue);
127 AssignRotationAboutAnAxis();
192 std::string
Info()
const override
194 return "AssignRotationFieldAboutAnAxisToNodesProcess";
200 rOStream <<
"AssignRotationFieldAboutAnAxisToNodesProcess";
250 pybind11::object mPyObject;
251 std::string mPyMethodName;
253 bool mIsSpatialField;
259 void CallFunction(
const Node::Pointer& pNode,
const double&
time,
double& rValue)
263 if( mIsSpatialField ){
265 double x = pNode->X(),
y = pNode->Y(),
z = pNode->Z();
266 rValue = mPyObject.attr(mPyMethodName.c_str())(
x,
y,
z,
time).cast<double>();
271 rValue = mPyObject.attr(mPyMethodName.c_str())(0.0,0.0,0.0,
time).cast<
double>();
279 void CallTimeFunction(
const double&
time,
double& rValue)
284 rValue = mPyObject.attr(mPyMethodName.c_str())(0.0,0.0,0.0,
time).cast<double>();
291 void AssignRotationAboutAnAxis()
302 Quaternion<double> total_quaternion;
303 array_1d<double,3>
radius;
304 array_1d<double,3> distance;
305 array_1d<double,3> rotation;
306 array_1d<double,3> delta_rotation;
311 bool dynamic_angular_velocity =
false;
312 bool dynamic_angular_acceleration =
false;
315 const double& rDeltaTime = rCurrentProcessInfo[DELTA_TIME];
316 const double& rCurrentTime = rCurrentProcessInfo[TIME];
317 const ProcessInfo& rPreviousProcessInfo = rCurrentProcessInfo.GetPreviousTimeStepInfo();
318 const double& rPreviousTime = rPreviousProcessInfo[TIME];
320 array_1d<double,3> angular_velocity;
321 angular_velocity.clear();
322 array_1d<double,3> angular_acceleration;
323 angular_acceleration.clear();
325 double time_factor = 0.0;
333 dynamic_angular_velocity =
true;
334 time_factor = rDeltaTime;
339 dynamic_angular_velocity =
true;
340 dynamic_angular_acceleration =
true;
341 time_factor = rDeltaTime * rDeltaTime;
347 ModelPart::NodesContainerType::iterator it = it_begin +
i;
349 this->CallFunction(*(it.base()), rCurrentTime, value);
353 rotation *= time_factor;
355 if( dynamic_angular_velocity ){
357 this->CallFunction(*(it.base()), rPreviousTime, value);
358 delta_rotation = rotation - time_factor * value *
mdirection;
360 angular_velocity = delta_rotation / rDeltaTime;
361 if( dynamic_angular_acceleration ){
362 angular_acceleration = angular_velocity / rDeltaTime;
369 distance = it->GetInitialPosition() -
mcenter;
371 total_quaternion.ToRotationMatrix(rotation_matrix);
375 array_1d<double,3>& displacement = it->FastGetSolutionStepValue(DISPLACEMENT);
376 displacement =
radius - distance;
378 if( dynamic_angular_velocity ){
384 array_1d<double,3>&
velocity = it->FastGetSolutionStepValue(VELOCITY);
387 if( dynamic_angular_acceleration ){
389 array_1d<double,3>&
acceleration = it->FastGetSolutionStepValue(ACCELERATION);
449 rOStream << std::endl;
The base class for assigning a value to scalar variables or array_1d components processes in Kratos.
Definition: assign_rotation_about_an_axis_to_nodes_process.hpp:35
std::string mvariable_name
Definition: assign_rotation_about_an_axis_to_nodes_process.hpp:222
double mprevious_value
Definition: assign_rotation_about_an_axis_to_nodes_process.hpp:224
void Execute() override
Execute method is used to execute the AssignRotationAboutAnAxisToNodesProcess algorithms.
Definition: assign_rotation_about_an_axis_to_nodes_process.hpp:121
ModelPart & mrModelPart
Definition: assign_rotation_about_an_axis_to_nodes_process.hpp:221
double mvalue
Definition: assign_rotation_about_an_axis_to_nodes_process.hpp:223
array_1d< double, 3 > mdirection
Definition: assign_rotation_about_an_axis_to_nodes_process.hpp:225
array_1d< double, 3 > mcenter
Definition: assign_rotation_about_an_axis_to_nodes_process.hpp:226
The base class for assigning a value to scalar variables or array_1d components processes in Kratos.
Definition: assign_rotation_field_about_an_axis_to_nodes_process.hpp:32
void ExecuteInitializeSolutionStep() override
this function will be executed at every time step BEFORE performing the solve phase
Definition: assign_rotation_field_about_an_axis_to_nodes_process.hpp:148
void ExecuteFinalizeSolutionStep() override
this function will be executed at every time step AFTER performing the solve phase
Definition: assign_rotation_field_about_an_axis_to_nodes_process.hpp:153
void Execute() override
Execute method is used to execute the AssignRotationFieldAboutAnAxisToNodesProcess algorithms.
Definition: assign_rotation_field_about_an_axis_to_nodes_process.hpp:107
KRATOS_CLASS_POINTER_DEFINITION(AssignRotationFieldAboutAnAxisToNodesProcess)
Pointer definition of AssignRotationFieldAboutAnAxisToNodesProcess.
void ExecuteInitialize() override
Definition: assign_rotation_field_about_an_axis_to_nodes_process.hpp:136
AssignRotationFieldAboutAnAxisToNodesProcess(AssignRotationFieldAboutAnAxisToNodesProcess const &rOther)
Copy constructor.
~AssignRotationFieldAboutAnAxisToNodesProcess() override
Destructor.
Definition: assign_rotation_field_about_an_axis_to_nodes_process.hpp:87
void operator()()
This operator is provided to call the process as a function and simply calls the Execute method.
Definition: assign_rotation_field_about_an_axis_to_nodes_process.hpp:95
void PrintInfo(std::ostream &rOStream) const override
Print information about this object.
Definition: assign_rotation_field_about_an_axis_to_nodes_process.hpp:198
void ExecuteFinalize() override
Definition: assign_rotation_field_about_an_axis_to_nodes_process.hpp:172
void ExecuteBeforeOutputStep() override
this function will be executed at every time step BEFORE writing the output
Definition: assign_rotation_field_about_an_axis_to_nodes_process.hpp:159
void ExecuteAfterOutputStep() override
this function will be executed at every time step AFTER writing the output
Definition: assign_rotation_field_about_an_axis_to_nodes_process.hpp:165
AssignRotationFieldAboutAnAxisToNodesProcess(ModelPart &model_part, pybind11::object &rPyObject, const std::string &rPyMethodName, const bool SpatialFieldFunction, Parameters rParameters)
Definition: assign_rotation_field_about_an_axis_to_nodes_process.hpp:43
void ExecuteBeforeSolutionLoop() override
Definition: assign_rotation_field_about_an_axis_to_nodes_process.hpp:142
std::string Info() const override
Turn back information as a string.
Definition: assign_rotation_field_about_an_axis_to_nodes_process.hpp:192
void PrintData(std::ostream &rOStream) const override
Print object's data.
Definition: assign_rotation_field_about_an_axis_to_nodes_process.hpp:204
static void VectorToSkewSymmetricTensor(const TVector3 &rVector, TMatrix3 &rSkewSymmetricTensor)
Definition: beam_math_utilities.hpp:231
NodesContainerType & Nodes()
Definition: mesh.h:346
NodeIterator NodesBegin()
Definition: mesh.h:326
This class aims to manage meshes for multi-physics simulations.
Definition: model_part.h:77
ProcessInfo & GetProcessInfo()
Definition: model_part.h:1746
MeshType & GetMesh(IndexType ThisIndex=0)
Definition: model_part.h:1791
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
void ValidateAndAssignDefaults(const Parameters &rDefaultParameters)
This function is designed to verify that the parameters under testing match the form prescribed by th...
Definition: kratos_parameters.cpp:1306
std::string GetString() const
This method returns the string contained in the current Parameter.
Definition: kratos_parameters.cpp:684
size_type size() const
Returns the number of elements in the container.
Definition: pointer_vector_set.h:502
ProcessInfo holds the current value of different solution parameters.
Definition: process_info.h:59
ProcessInfo & GetPreviousTimeStepInfo(IndexType StepsBefore=1)
Definition: process_info.h:187
static Quaternion FromRotationVector(double rx, double ry, double rz)
Definition: quaternion.h:427
#define KRATOS_CATCH(MoreInfo)
Definition: define.h:110
#define KRATOS_TRY
Definition: define.h:109
z
Definition: GenerateWind.py:163
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
Internals::Matrix< double, AMatrix::dynamic, AMatrix::dynamic > Matrix
Definition: amatrix_interface.h:470
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
std::ostream & operator<<(std::ostream &rOStream, const LinearMasterSlaveConstraint &rThis)
output stream function
Definition: linear_master_slave_constraint.h:432
float velocity
Definition: PecletTest.py:54
ProcessInfo
Definition: edgebased_PureConvection.py:116
time
Definition: face_heat.py:85
model_part
Definition: face_heat.py:14
y
Other simbols definition.
Definition: generate_axisymmetric_navier_stokes_element.py:54
tuple acceleration
Definition: generate_droplet_dynamics.py:117
float radius
Definition: mesh_to_mdpa_converter.py:18
x
Definition: sensitivityMatrix.py:49
int nnodes
Definition: sensitivityMatrix.py:24
integer i
Definition: TensorModule.f:17