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 all 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
7 changes: 7 additions & 0 deletions Common/include/CConfig.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1052,6 +1052,7 @@ class CConfig {
unsigned short *nSpan_iZones; /*!< \brief number of span-wise sections for each zones */
bool turbMixingPlane; /*!< \brief option for turbulent mixingplane */
bool SpatialFourier; /*!< \brief option for computing the fourier transforms for subsonic non-reflecting BC. */
bool RelFrame_SlidingPlane; /*!< \brief option for relative frame slidingplane */
bool RampRotatingFrame; /*!< \brief option for ramping up or down the Rotating Frame values */
bool RampOutletPressure; /*!< \brief option for ramping up or down the outlet pressure */
su2double AverageMachLimit; /*!< \brief option for turbulent mixingplane */
Expand Down Expand Up @@ -5207,6 +5208,12 @@ class CConfig {
*/
bool GetBoolTurbomachinery(void) const { return (nMarker_Turbomachinery !=0);}

/*!
* \brief Verify if a sliding plane for relative frame is specified from config file.
* \return boolean.
*/
bool GetBoolRelFrame_SlidingPlane(void) const { return (RelFrame_SlidingPlane !=0);}

/*!
* \brief number Turbomachinery blades computed using the pitch information.
* \return nBlades.
Expand Down
2 changes: 2 additions & 0 deletions Common/src/CConfig.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1627,6 +1627,8 @@ void CConfig::SetConfig_Options() {
addStringListOption("MARKER_MIXINGPLANE_INTERFACE", nMarker_MixingPlaneInterface, Marker_MixingPlaneInterface);
/*!\brief TURBULENT_MIXINGPLANE \n DESCRIPTION: Activate mixing plane also for turbulent quantities \ingroup Config*/
addBoolOption("TURBULENT_MIXINGPLANE", turbMixingPlane, false);
/*!\brief RELATIVE_FRAME_SLIDINGPLANE \n DESCRIPTION: Activate sliding plane for relative frame \ingroup Config*/
addBoolOption("RELATIVE_FRAME_SLIDINGPLANE", RelFrame_SlidingPlane, false);
/*!\brief MARKER_TURBOMACHINERY \n DESCRIPTION: Identify the inflow and outflow boundaries in which the turbomachinery settings are applied. \ingroup Config*/
addTurboPerfOption("MARKER_TURBOMACHINERY", nMarker_Turbomachinery, Marker_TurboBoundIn, Marker_TurboBoundOut);
/*!\brief NUM_SPANWISE_SECTIONS \n DESCRIPTION: Integer number of spanwise sections to compute 3D turbo BC and Performance for turbomachinery */
Expand Down
60 changes: 58 additions & 2 deletions Common/src/interface_interpolation/CNearestNeighbor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -117,9 +117,65 @@ 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);

donorInfo[iDonor++] = DonorInfo(dist2, pGlobalPoint, iProcessor);
bool relframe_sp_target = config[targetZone]->GetBoolRelFrame_SlidingPlane();
bool relframe_sp_donor = config[donorZone]->GetBoolRelFrame_SlidingPlane();

/*--- Rotate the points before matching if sliding plane for relative frame is activated ---*/
if (relframe_sp_target || relframe_sp_donor) {
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);
} else {
const auto dist2 = GeometryToolbox::SquaredDistance(nDim, Coord_i, Coord_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
8 changes: 8 additions & 0 deletions SU2_CFD/src/interfaces/CInterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,14 @@ 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_config->GetBoolRelFrame_SlidingPlane()) {
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 @@ CSlidingInterface::CSlidingInterface(unsigned short val_nVar, unsigned short val

}

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;
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
Loading