Skip to content
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

Draft
wants to merge 22 commits into
base: master
Choose a base branch
from
Draft

Kratos Rotating Frame Process #11158

wants to merge 22 commits into from

Conversation

SADPR
Copy link
Contributor

@SADPR SADPR commented May 19, 2023

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 utility RotatingFrameUtility to carry out these tasks.

Changes Made

  1. applications/FluidDynamicsApplication/CMakeLists.txt: The rotating_frame_utility.cpp file has been added to the list of source files to be compiled.
  2. applications/FluidDynamicsApplication/custom_python/add_custom_utilities_to_python.cpp: The RotatingFrameUtility is now exposed to Python.
  3. applications/FluidDynamicsApplication/custom_utilities/rotating_frame_utility.cpp and rotating_frame_utility.h: These files contain the C++ implementation of the RotatingFrameUtility. 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.
  4. applications/FluidDynamicsApplication/python_scripts/rotating_frame_process.py: This Python process utilizes the RotatingFrameUtility. It calls the utility's functions in the appropriate sequence to implement the rotating frame transformation and the associated velocity application.
  5. applications/FluidDynamicsApplication/tests/test_rotating_frame_process.py: This Python test validates the functionality of both the RotatingFrameUtility and the associated Python process.
  6. applications/FluidDynamicsApplication/tests/RotatingFrameProcessTest/RotatingFrameProcessTest.mdpa and RotatingFrameProcessTestResults.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:

Example

@loumalouomega
Copy link
Member

Why Fluid app?, is quite generic, isn`t?

@@ -0,0 +1,120 @@
// | / |
Copy link
Member

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?

Copy link
Contributor Author

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];
Copy link
Member

@loumalouomega loumalouomega May 19, 2023

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();
Copy link
Member

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];
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Idem, vector assign

Comment on lines 13 to 14
#if !defined(KRATOS_ROTATING_FRAME_UTILITY_H)
#define KRATOS_ROTATING_FRAME_UTILITY_H
Copy link
Member

@loumalouomega loumalouomega May 19, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

#pragma once

Copy link
Member

@loumalouomega loumalouomega left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some comments

@rubenzorrilla
Copy link
Member

Why Fluid app?, is quite generic, isn`t?

Agree. I think that the best place for this is the MeshMovingApplication. Alternatively, we could directly implement it in the core.

Comment on lines +37 to +38
"rotating_frame_model_part_name": "",
"rotating_object_model_part_name": "",
Copy link
Member

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?

Copy link
Contributor Author

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.

@SADPR
Copy link
Contributor Author

SADPR commented Aug 22, 2023

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

@SADPR
Copy link
Contributor Author

SADPR commented Aug 22, 2023

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.

@SADPR
Copy link
Contributor Author

SADPR commented Sep 10, 2023

@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!

@SADPR
Copy link
Contributor Author

SADPR commented Oct 19, 2023

@loumalouomega and @rubenzorrilla I would like to close this PR. Can you help me? 😄

@loumalouomega
Copy link
Member

@loumalouomega and @rubenzorrilla I would like to close this PR. Can you help me? 😄

Merge or close?, because close is easy...

loumalouomega
loumalouomega previously approved these changes Oct 19, 2023
Copy link
Member

@loumalouomega loumalouomega left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove block

@loumalouomega
Copy link
Member

Now it depends on @rubenzorrilla

@SADPR
Copy link
Contributor Author

SADPR commented Oct 19, 2023

@loumalouomega and @rubenzorrilla I would like to close this PR. Can you help me? 😄

Merge or close?, because close is easy...

😆 merge! Okay, I'll wait for Ruben's response.

Comment on lines +15 to +30
// 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"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// 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.

Comment on lines +17 to +19
// External includes

// Application includes
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// 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);
Copy link
Member

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).

Comment on lines +50 to +53
// Fix the velocity components
rNode.Fix(VELOCITY_X);
rNode.Fix(VELOCITY_Y);
rNode.Fix(VELOCITY_Z);
Copy link
Member

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;
Copy link
Member

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);
Copy link
Member

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.

Comment on lines +48 to +49
# Alternative:
# settings.RecursivelyValidateAndAssignDefaults(default_settings)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
# Alternative:
# settings.RecursivelyValidateAndAssignDefaults(default_settings)

If not used remove.

@@ -0,0 +1,805 @@
{
Copy link
Member

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
Copy link
Member

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.

Copy link
Member

@rubenzorrilla rubenzorrilla left a 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).

@SADPR SADPR requested a review from a team as a code owner December 5, 2023 14:46
@SADPR
Copy link
Contributor Author

SADPR commented Dec 20, 2023

Turning to draft.

@SADPR SADPR marked this pull request as draft December 20, 2023 11:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants