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

[WIP] Change for sliding plane when relative frame is used #2311

Open
wants to merge 23 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 14 commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
d9b04db
adapt the interpolation method NearestNeighbor to turbo applications …
Nov 21, 2023
4461aa4
Merge branch 'develop' into turbo_features_fabian
bigfooted Nov 21, 2023
76510d8
For interface data broadcasting, we rotate the velocity vector from r…
Feb 18, 2024
4477eff
Update transfer coefficient every time step for when rotating frame i…
Feb 18, 2024
5727ae6
For interface data broadcasting, we rotate the velocity vector from r…
Feb 18, 2024
f798a6b
For interface data broadcasting, we rotate the velocity vector from r…
Feb 18, 2024
d040cc4
For interface data broadcasting, we rotate the velocity vector from r…
Feb 19, 2024
c3fe7d2
Update transfer coefficient every time step for when rotating frame i…
Feb 19, 2024
81ed71e
New testcase proposed for this feature.
Feb 19, 2024
4d32555
Merge branch 'su2code:master' into turbo_features_fabian
FabianYan2010 May 13, 2024
5f2f6ef
update Merge branch 'master' of https://github.com/FabianYan2010/SU2
May 15, 2024
1fbc798
Master branch was accidentally changed.
May 15, 2024
a00878b
clear tabs
Jun 24, 2024
2a1dd3b
Merge branch 'develop' into Feature_SlidingPlane_RelFrame
FabianYan2010 Jun 25, 2024
1bb6796
change authorship
Jul 29, 2024
4fc50db
update test case
Jul 31, 2024
90a8859
change authorship
Jul 31, 2024
3f5d63d
upload the grids and initial solution of the new test case
Jul 31, 2024
be20596
Merge branch 'Feature_SlidingPlane_RelFrame' of https://github.com/Fa…
Jul 31, 2024
9d889bf
remove solution and grid files from code repo
Oct 8, 2024
cbbf1bf
add a cofig option for this feature
Oct 8, 2024
d53ae94
remove unused variable
Oct 8, 2024
059cc0c
add new option in test case config
Oct 9, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 49 additions & 1 deletion Common/src/interface_interpolation/CNearestNeighbor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,55 @@ void CNearestNeighbor::SetTransferCoeff(const CConfig* const* config) {
const auto idx = iProcessor * MaxLocalVertex_Donor + jVertex;
const auto pGlobalPoint = Buffer_Receive_GlobalPoint[idx];
const su2double* Coord_j = Buffer_Receive_Coord[idx];
const auto dist2 = GeometryToolbox::SquaredDistance(nDim, Coord_i, Coord_j);

su2double Theta, Phi, Psi;
su2double rotCoord_i[3] = {0.0, 0.0, 0.0}, rotCoord_j[3] = {0.0, 0.0, 0.0};
su2double rotMatrix[3][3] = {{1.0, 0.0, 0.0}, {0.0, 1.0, 0.0}, {0.0, 0.0, 1.0}};
const su2double zeros[3] = {0.0};
for (unsigned short iDim = 0; iDim < 3; iDim++) {
rotCoord_i[iDim] = Coord_i[iDim];
rotCoord_j[iDim] = Coord_j[iDim];
}

if (config[targetZone]->GetRotating_Frame() == YES) {
su2double Omega_i[3] = {0.0, 0.0, 0.0};
su2double dt = config[targetZone]->GetDelta_UnstTimeND();
unsigned long TimeIter = config[targetZone]->GetTimeIter();
for (unsigned short iDim = 0; iDim < 3; iDim++) {
Omega_i[iDim] = config[targetZone]->GetRotation_Rate(iDim) / config[targetZone]->GetOmega_Ref();
}

/*--- Compute the rotation matrix. Note that the implicit
ordering is rotation about the x-axis, y-axis, then z-axis. ---*/
Theta = Omega_i[0] * dt * TimeIter;
Phi = Omega_i[1] * dt * TimeIter;
Psi = Omega_i[2] * dt * TimeIter;
GeometryToolbox::RotationMatrix(Theta, Phi, Psi, rotMatrix);

/*--- Compute transformed point coordinates. ---*/
GeometryToolbox::Rotate(rotMatrix, zeros, Coord_i, rotCoord_i);
}

if (config[donorZone]->GetRotating_Frame() == YES) {
su2double Omega_j[3] = {0.0, 0.0, 0.0};
su2double dt = config[donorZone]->GetDelta_UnstTimeND();
unsigned long TimeIter = config[donorZone]->GetTimeIter();
for (unsigned short iDim = 0; iDim < 3; iDim++) {
Omega_j[iDim] = config[donorZone]->GetRotation_Rate(iDim) / config[donorZone]->GetOmega_Ref();
}

/*--- Compute the rotation matrix. Note that the implicit
ordering is rotation about the x-axis, y-axis, then z-axis. ---*/
Theta = Omega_j[0] * dt * TimeIter;
Phi = Omega_j[1] * dt * TimeIter;
Psi = Omega_j[2] * dt * TimeIter;
GeometryToolbox::RotationMatrix(Theta, Phi, Psi, rotMatrix);

/*--- Compute transformed point coordinates. ---*/
GeometryToolbox::Rotate(rotMatrix, zeros, Coord_j, rotCoord_j);
}

const auto dist2 = GeometryToolbox::SquaredDistance(nDim, rotCoord_i, rotCoord_j);

donorInfo[iDonor++] = DonorInfo(dist2, pGlobalPoint, iProcessor);
}
Expand Down
10 changes: 10 additions & 0 deletions SU2_CFD/include/interfaces/CInterface.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,16 @@ class CInterface {
const CConfig *donor_config, unsigned long Marker_Donor,
unsigned long Vertex_Donor, unsigned long Point_Donor) = 0;

/*!
* \brief A virtual member.
* \param[in] donor_config - Definition of the problem at the donor mesh.
* \param[in] donor_geometry - Geometry of the donor mesh.
* \param[in] target_config - Definition of the problem at the donor mesh.
* \param[in] target_geometry - Geometry of the donor mesh.
*/
inline virtual void GetDonor_Velocity_RotatingFrame(const CConfig *donor_config, CGeometry *donor_geometry,
const CConfig *target_config, CGeometry *target_geometry) {}

/*!
* \brief Initializes the target variable.
* \param[in] target_solution - Solution from the target mesh.
Expand Down
11 changes: 11 additions & 0 deletions SU2_CFD/include/interfaces/cfd/CSlidingInterface.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,17 @@ class CSlidingInterface : public CInterface {
unsigned long Marker_Donor, unsigned long Vertex_Donor, unsigned long Point_Donor) override;

/*!
* \brief Rotate the velocity if rotating frame is applied.
* \param[in] donor_config - Definition of the problem at the donor mesh.
* \param[in] donor_geometry - Geometry of the donor mesh.
* \param[in] target_config - Definition of the problem at the donor mesh.
* \param[in] target_geometry - Geometry of the donor mesh.
*/
void GetDonor_Velocity_RotatingFrame(const CConfig *donor_config, CGeometry *donor_geometry,
const CConfig *target_config, CGeometry *target_geometry) override;


/*!
* \brief A virtual member, initializes the target variable for sliding mesh.
* \param[in] target_solution - Solution from the target mesh.
* \param[in] Marker_Target - Index of the target marker.
Expand Down
4 changes: 2 additions & 2 deletions SU2_CFD/src/drivers/CMultizoneDriver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ CMultizoneDriver::CMultizoneDriver(char* confFile, unsigned short val_nZone, SU2
prefixed_motion = new bool[nZone];
for (iZone = 0; iZone < nZone; iZone++){
switch (config_container[iZone]->GetKind_GridMovement()){
case RIGID_MOTION:
case RIGID_MOTION: case ROTATING_FRAME:
prefixed_motion[iZone] = true; break;
default:
prefixed_motion[iZone] = false; break;
Expand Down Expand Up @@ -269,7 +269,7 @@ void CMultizoneDriver::Preprocess(unsigned long TimeIter) {
if (driver_config->GetTime_Domain()) {
for (iZone = 0; iZone < nZone; iZone++) {
for (unsigned short jZone = 0; jZone < nZone; jZone++){
if(jZone != iZone && interpolator_container[iZone][jZone] != nullptr && prefixed_motion[iZone])
if(jZone != iZone && interpolator_container[iZone][jZone] != nullptr && (prefixed_motion[iZone] || prefixed_motion[jZone]))
interpolator_container[iZone][jZone]->SetTransferCoeff(config_container);
}
}
Expand Down
6 changes: 6 additions & 0 deletions SU2_CFD/src/interfaces/CInterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,12 @@ void CInterface::BroadcastData(const CInterpolator& interpolator,
if (donor_geometry->nodes->GetDomain(iPoint)) {

GetDonor_Variable(donor_solution, donor_geometry, donor_config, markDonor, iVertex, iPoint);

/*---rotate the velocity if rotating frame is applied---*/
if (donor_solution->GetnPrimVar() > 2){
GetDonor_Velocity_RotatingFrame(donor_config, donor_geometry, target_config, target_geometry);
}

for (auto iVar = 0u; iVar < nVar; iVar++) sendDonorVar(iSend, iVar) = Donor_Variable[iVar];

sendDonorIdx[iSend] = donor_geometry->nodes->GetGlobalIndex(iPoint);
Expand Down
76 changes: 76 additions & 0 deletions SU2_CFD/src/interfaces/cfd/CSlidingInterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
#include "../../../../Common/include/CConfig.hpp"
#include "../../../../Common/include/geometry/CGeometry.hpp"
#include "../../../include/solvers/CSolver.hpp"
#include "../../../../Common/include/toolboxes/geometry_toolbox.hpp"

CSlidingInterface::CSlidingInterface(unsigned short val_nVar, unsigned short val_nConst) : CInterface() {

Expand All @@ -43,6 +44,81 @@

}

void CSlidingInterface::GetDonor_Velocity_RotatingFrame(const CConfig *donor_config, CGeometry *donor_geometry,
const CConfig *target_config, CGeometry *target_geometry){

/*---rotate the velocity for rotating frame---*/
if (donor_config->GetRotating_Frame()==YES){

unsigned short nDim = donor_geometry->GetnDim();

su2double Theta, Phi, Psi;
su2double oriVel[3] = {0.0, 0.0, 0.0};
su2double rotVel[3] = {0.0, 0.0, 0.0};
su2double rotMatrix[3][3] = {{1.0,0.0,0.0},{0.0,1.0,0.0},{0.0,0.0,1.0}};
su2double Omega[3] = {0.0, 0.0, 0.0};
const su2double zeros[3] = {0.0};
su2double dt = donor_config->GetDelta_UnstTimeND();
unsigned long TimeIter = donor_config->GetTimeIter();
for (unsigned short iDim=0; iDim<3; iDim++){
Omega[iDim] = donor_config->GetRotation_Rate(iDim)/donor_config->GetOmega_Ref();
}

/*--- Compute the rotation matrix. Note that the implicit
ordering is rotation about the x-axis, y-axis, then z-axis. ---*/
Theta = Omega[0]*dt*TimeIter; Phi = Omega[1]*dt*TimeIter; Psi = Omega[2]*dt*TimeIter;
GeometryToolbox::RotationMatrix(Theta, Phi, Psi, rotMatrix);

/*--- Velocities before rotating ---*/
for (unsigned short iDim = 0; iDim < nDim; ++iDim)
oriVel[iDim] = Donor_Variable[iDim+1];

/*--- Compute transformed velocities. ---*/
GeometryToolbox::Rotate(rotMatrix, zeros, oriVel, rotVel);

/*--- set the rotated velocity ---*/
for (unsigned short iDim = 0; iDim < nDim; iDim++) {
Donor_Variable[iDim+1] = rotVel[iDim];
}

}

if (target_config->GetRotating_Frame()==YES){

unsigned short nDim = target_geometry->GetnDim();

su2double Theta, Phi, Psi, cosTheta, sinTheta, cosPhi, sinPhi, cosPsi, sinPsi;

Check notice

Code scanning / CodeQL

Unused local variable Note

Variable cosTheta is not used.

Check notice

Code scanning / CodeQL

Unused local variable Note

Variable sinTheta is not used.

Check notice

Code scanning / CodeQL

Unused local variable Note

Variable cosPhi is not used.

Check notice

Code scanning / CodeQL

Unused local variable Note

Variable sinPhi is not used.

Check notice

Code scanning / CodeQL

Unused local variable Note

Variable cosPsi is not used.

Check notice

Code scanning / CodeQL

Unused local variable Note

Variable sinPsi is not used.
su2double oriVel[3] = {0.0, 0.0, 0.0};
su2double rotVel[3] = {0.0, 0.0, 0.0};
su2double rotMatrix[3][3] = {{1.0,0.0,0.0},{0.0,1.0,0.0},{0.0,0.0,1.0}};
su2double Omega[3] = {0.0, 0.0, 0.0};
const su2double zeros[3] = {0.0};
su2double dt = target_config->GetDelta_UnstTimeND();
unsigned long TimeIter = donor_config->GetTimeIter();
for (unsigned short iDim=0; iDim<3; iDim++){
Omega[iDim] = -target_config->GetRotation_Rate(iDim)/target_config->GetOmega_Ref();
}

/*--- Compute the rotation matrix. Note that the implicit
ordering is rotation about the x-axis, y-axis, then z-axis. ---*/
Theta = Omega[0]*dt*TimeIter; Phi = Omega[1]*dt*TimeIter; Psi = Omega[2]*dt*TimeIter;
GeometryToolbox::RotationMatrix(Theta, Phi, Psi, rotMatrix);

/*--- velocities before rotating ---*/
for (unsigned short iDim = 0; iDim < nDim; ++iDim)
oriVel[iDim] = Donor_Variable[iDim+1];

/*--- Compute transformed velocities. ---*/
GeometryToolbox::Rotate(rotMatrix, zeros, oriVel, rotVel);

/*--- set the rotated velocity ---*/
for (unsigned short iDim = 0; iDim < nDim; iDim++) {
Donor_Variable[iDim+1] = rotVel[iDim];
}

}

}
void CSlidingInterface::GetDonor_Variable(CSolver *donor_solution, CGeometry *donor_geometry,
const CConfig *donor_config, unsigned long Marker_Donor,
unsigned long Vertex_Donor, unsigned long Point_Donor) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %
% SU2 configuration file %
% Case description: 2D Axial stage %
% Author: S. Vitale %
% Institution: Delft University of Technology %
% Date: Feb 28th, 2017 %
% File Version 5.0.0"cardinal" %
Copy link
Contributor

Choose a reason for hiding this comment

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

Change authorship and get the credit that you deserve... Can you also add all new testcases to the regression tests, at least put it into parallel_regression.py

% %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% ----------------------- DYNAMIC MESH DEFINITION -----------------------------%
%
% Type of dynamic mesh (NONE, ROTATING_FRAME)
GRID_MOVEMENT= ROTATING_FRAME
%
%
% Angular velocity vector (rad/s) about the motion origi. Example 1250 RPM -> 130.89969389957471 rad/s
ROTATION_RATE= 0.0 0.0 -1800.0
%
% Mesh input file
MESH_FILENAME= rotor35_Full.su2
Loading
Loading