-
Notifications
You must be signed in to change notification settings - Fork 247
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Kratos Rotating Frame Process #11158
base: master
Are you sure you want to change the base?
Conversation
Why Fluid app?, is quite generic, isn`t? |
@@ -0,0 +1,120 @@ | |||
// | / | |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fluid app has a different header?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, I don't see any other utility with a different header.
velocity_vector = MathUtils<double>::CrossProduct(angular_velocity_vector, position_vector); | ||
|
||
// Setting the node's velocity | ||
rNode.FastGetSolutionStepValue(VELOCITY_X) = velocity_vector[0]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think is more efficient if you assign values using the whole vector (or potentially can be if using SIMD), also is shorter and simpler
|
||
// Shifting the point back and updating the node coordinates | ||
rotated_point += rCenterOfRotation; | ||
rNode.FastGetSolutionStepValue(MESH_DISPLACEMENT_X) = rotated_point[0] - rNode.X0(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Idem, assign vector is better
rNode.Fix(MESH_DISPLACEMENT_X); | ||
rNode.Fix(MESH_DISPLACEMENT_Y); | ||
rNode.Fix(MESH_DISPLACEMENT_Z); | ||
rNode.X() = rotated_point[0]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Idem, vector assign
#if !defined(KRATOS_ROTATING_FRAME_UTILITY_H) | ||
#define KRATOS_ROTATING_FRAME_UTILITY_H |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
#pragma once
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some comments
Agree. I think that the best place for this is the |
"rotating_frame_model_part_name": "", | ||
"rotating_object_model_part_name": "", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Which is the difference between these two? Aren't you doing the rotation in the entire model part?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The rotating_frame_model_part_name
refers to the computational domain treated as being in a rotational state, typically employed in the sliding mesh approach to capture the effects of the rotating zone. On the other hand, the rotating_object_model_part_name
denotes the specific entity or component, like a turbine blade or a rotor, that necessitates the assignment of the rotational velocity. Essentially, while the rotating frame captures the overall moving region in the computational sense, the rotating object represents the actual physical component causing this rotation.
Given the utility's primary role in assigning velocities, I feel it's more intuitive to place it within the FluidDynamicsApplication. Both velocity and mesh displacements are intrinsic variables in fluid dynamics' arbitrary lagrangian eulerian (ALE) formulation, especially for its application in sliding mesh scenarios. Incorporating it here ensures that developers and users have direct access in the most pertinent contexts. It just seems like a natural and strategic alignment with our current and prospective projects (*TO ME). Do you think it truly has a better home in the mesh moving? @loumalouomega @rubenzorrilla |
I've implemented all the suggestions. The only point left for discussion is whether to move it to the MeshMoving or to retain it here in the FluidDynamicsApplication. |
@loumalouomega could you please take a quick view to this? I did all suggestions and the only discussion left is whether to move it to the MeshMoving or to retain it here in the FluidDynamicsApplication. Thanks! |
@loumalouomega and @rubenzorrilla I would like to close this PR. Can you help me? 😄 |
Merge or close?, because close is easy... |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove block
Now it depends on @rubenzorrilla |
😆 merge! Okay, I'll wait for Ruben's response. |
// System includes | ||
#include <string> | ||
#include <iostream> | ||
|
||
// External includes | ||
#include "includes/mesh_moving_variables.h" | ||
|
||
// Include kratos definitions | ||
#include "includes/define.h" | ||
|
||
// Application includes | ||
#include "utilities/variable_utils.h" | ||
|
||
// Project includes | ||
#include "utilities/builtin_timer.h" | ||
#include "utilities/math_utils.h" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// System includes | |
#include <string> | |
#include <iostream> | |
// External includes | |
#include "includes/mesh_moving_variables.h" | |
// Include kratos definitions | |
#include "includes/define.h" | |
// Application includes | |
#include "utilities/variable_utils.h" | |
// Project includes | |
#include "utilities/builtin_timer.h" | |
#include "utilities/math_utils.h" | |
// System includes | |
#include <string> | |
#include <iostream> | |
// External includes | |
// Project includes | |
#include "includes/define.h" | |
#include "includes/mesh_moving_variables.h" | |
#include "utilities/builtin_timer.h" | |
#include "utilities/math_utils.h" | |
#include "utilities/variable_utils.h" | |
// Application includes | |
To follow our standard include lists.
// External includes | ||
|
||
// Application includes |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// External includes | |
// Application includes | |
// External includes | |
// Project includes | |
// Application includes |
array_1d<double, 3> position_vector = r_point - rCenterOfRotation; | ||
|
||
// Computing the velocity due to rotation (v = omega cross r) | ||
array_1d<double, 3> velocity_vector = MathUtils<double>::CrossProduct(angular_velocity_vector, position_vector); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd pass velocity_vector
as a TLS (so you avoid allocating and deallocating each time).
// Fix the velocity components | ||
rNode.Fix(VELOCITY_X); | ||
rNode.Fix(VELOCITY_Y); | ||
rNode.Fix(VELOCITY_Z); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure if the fixity must be done in here. What if I want to apply this to a problem in which the VELOCITY
is not a DOF (e.g. convection).
auto& r_point = rNode.GetInitialPosition().Coordinates(); | ||
|
||
// Shifting the rotation center to the origin | ||
auto centered_point = r_point - rCenterOfRotation; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same comment. Pass it as a TLS.
auto centered_point = r_point - rCenterOfRotation; | ||
|
||
// Applying the rotation | ||
array_1d<double, 3> rotated_point = prod(centered_point, rot_matrix); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same comment. Pass it as a TLS.
# Alternative: | ||
# settings.RecursivelyValidateAndAssignDefaults(default_settings) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
# Alternative: | |
# settings.RecursivelyValidateAndAssignDefaults(default_settings) |
If not used remove.
@@ -0,0 +1,805 @@ | |||
{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please use snake_case
for the subfolder name.
@@ -0,0 +1,214 @@ | |||
Begin ModelPartData |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please use snake_case
for the subfolder name.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't we put this in the MeshMovingApplication
(there's nothing related to fluids in here).
…Kratos_RotatingFrameProcess"
…"origin/Kratos_RotatingFrameProcess"" This reverts commit 5be37fe.
Turning to draft. |
Overview
This Pull Request introduces a new process in the FluidDynamicsApplication, called the
RotatingFrameProcess
. This process applies a rotation transformation and imparts a constant or accelerated angular velocity to a given model part in a rotating frame of reference. This process leverages the functions provided by the new utilityRotatingFrameUtility
to carry out these tasks.Changes Made
applications/FluidDynamicsApplication/CMakeLists.txt
: Therotating_frame_utility.cpp
file has been added to the list of source files to be compiled.applications/FluidDynamicsApplication/custom_python/add_custom_utilities_to_python.cpp
: TheRotatingFrameUtility
is now exposed to Python.applications/FluidDynamicsApplication/custom_utilities/rotating_frame_utility.cpp
androtating_frame_utility.h
: These files contain the C++ implementation of theRotatingFrameUtility
. This utility facilitates the application of a rotation and mesh displacement to a given model part and imparts an angular velocity to it, which can be either constant or time-varying.applications/FluidDynamicsApplication/python_scripts/rotating_frame_process.py
: This Python process utilizes theRotatingFrameUtility
. It calls the utility's functions in the appropriate sequence to implement the rotating frame transformation and the associated velocity application.applications/FluidDynamicsApplication/tests/test_rotating_frame_process.py
: This Python test validates the functionality of both theRotatingFrameUtility
and the associated Python process.applications/FluidDynamicsApplication/tests/RotatingFrameProcessTest/RotatingFrameProcessTest.mdpa
andRotatingFrameProcessTestResults.json
: These files contain the model part and the expected test results for the Python test respectively.Please review and let me know if any changes are required.
Here is a visual representation: