Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
12 changes: 12 additions & 0 deletions SU2_CFD/include/drivers/CDriver.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -508,6 +508,18 @@ class CDriver : public CDriverBase {
*/
void SetInletAngle(unsigned short iMarker, passivedouble alpha);

/*!
* \brief Set the angle of attack of the farfield.
* \param[in] alpha - Angle (degree).
*/
void SetFarFieldAoA(passivedouble alpha);

/*!
* \brief Set the angle of sideslip of the farfield.
* \param[in] beta - Angle (degree).
*/
void SetFarFieldAoS(passivedouble beta);

/*!
* \brief Set the dynamic mesh translation rates.
* \param[in] xDot - Value of translational velocity in x-direction.
Expand Down
23 changes: 23 additions & 0 deletions SU2_CFD/include/solvers/CFVMFlowSolverBase.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2198,6 +2198,29 @@ class CFVMFlowSolverBase : public CSolver {
Inlet_FlowDir[val_marker][val_vertex][val_dim] = val_flowdir;
}

/*!
* \brief Updates the components of the farfield velocity vector.
*/
inline void UpdateFarfieldVelocity(const CConfig* config) final {
/*--- Retrieve the AoA and AoS (degrees) ---*/
const su2double AoA = config->GetAoA() * PI_NUMBER / 180.0;
const su2double AoS = config->GetAoS() * PI_NUMBER / 180.0;
/*--- Update the freestream velocity vector at the farfield
* Compute the new freestream velocity with the updated AoA,
* "Velocity_Inf" is shared with config. ---*/

const su2double Vel_Infty_Mag = GeometryToolbox::Norm(nDim, Velocity_Inf);

if (nDim == 2) {
Velocity_Inf[0] = cos(AoA) * Vel_Infty_Mag;
Velocity_Inf[1] = sin(AoA) * Vel_Infty_Mag;
} else {
Velocity_Inf[0] = cos(AoA) * cos(AoS) * Vel_Infty_Mag;
Velocity_Inf[1] = sin(AoS) * Vel_Infty_Mag;
Velocity_Inf[2] = sin(AoA) * cos(AoS) * Vel_Infty_Mag;
}
}

/*!
* \brief Compute the global error measures (L2, Linf) for verification cases.
* \param[in] geometry - Geometrical definition.
Expand Down
5 changes: 5 additions & 0 deletions SU2_CFD/include/solvers/CSolver.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2871,6 +2871,11 @@ class CSolver {
unsigned short val_dim,
su2double val_flowdir) { }

/*!
* \brief Updates the components of the farfield velocity vector.
*/
inline virtual void UpdateFarfieldVelocity(const CConfig* config) {}

/*!
* \brief A virtual member
* \param[in] iMarker - Marker identifier.
Expand Down
11 changes: 11 additions & 0 deletions SU2_CFD/src/python_wrapper_structure.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,16 @@ void CDriver::SetInletAngle(unsigned short iMarker, passivedouble alpha) {
}
}

void CDriver::SetFarFieldAoA(const passivedouble AoA) {
config_container[ZONE_0]->SetAoA(AoA);
solver_container[ZONE_0][INST_0][MESH_0][FLOW_SOL]->UpdateFarfieldVelocity(config_container[ZONE_0]);
}

void CDriver::SetFarFieldAoS(const passivedouble AoS) {
config_container[ZONE_0]->SetAoS(AoS);
solver_container[ZONE_0][INST_0][MESH_0][FLOW_SOL]->UpdateFarfieldVelocity(config_container[ZONE_0]);
}

/////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/* Functions related to simulation control, high level functions (reset convergence, set initial mesh, etc.) */
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -156,3 +166,4 @@ void CDriver::SetRotationRate(passivedouble rot_x, passivedouble rot_y, passived
config_container[iZone]->SetRotation_Rate(2, rot_z);
}
}

21 changes: 1 addition & 20 deletions SU2_CFD/src/solvers/CEulerSolver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4061,8 +4061,6 @@ void CEulerSolver::SetFarfield_AoA(CGeometry *geometry, CSolver **solver_contain
CConfig *config, unsigned short iMesh, bool Output) {

const auto InnerIter = config->GetInnerIter();
const su2double AoS = config->GetAoS()*PI_NUMBER/180.0;

/* --- Initialize values at first iteration --- */

if (InnerIter == 0) {
Expand Down Expand Up @@ -4101,24 +4099,7 @@ void CEulerSolver::SetFarfield_AoA(CGeometry *geometry, CSolver **solver_contain
AoA = AoA + AoA_inc;
config->SetAoA(AoA);
}

AoA *= PI_NUMBER/180.0;

/*--- Update the freestream velocity vector at the farfield
* Compute the new freestream velocity with the updated AoA,
* "Velocity_Inf" is shared with config. ---*/

const su2double Vel_Infty_Mag = GeometryToolbox::Norm(nDim, Velocity_Inf);

if (nDim == 2) {
Velocity_Inf[0] = cos(AoA)*Vel_Infty_Mag;
Velocity_Inf[1] = sin(AoA)*Vel_Infty_Mag;
}
else {
Velocity_Inf[0] = cos(AoA)*cos(AoS)*Vel_Infty_Mag;
Velocity_Inf[1] = sin(AoS)*Vel_Infty_Mag;
Velocity_Inf[2] = sin(AoA)*cos(AoS)*Vel_Infty_Mag;
}
UpdateFarfieldVelocity(config);
}
}

Expand Down