diff --git a/SU2_CFD/include/drivers/CDriver.hpp b/SU2_CFD/include/drivers/CDriver.hpp index 694c66ec6bfd..236c932b6306 100644 --- a/SU2_CFD/include/drivers/CDriver.hpp +++ b/SU2_CFD/include/drivers/CDriver.hpp @@ -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. diff --git a/SU2_CFD/include/solvers/CFVMFlowSolverBase.hpp b/SU2_CFD/include/solvers/CFVMFlowSolverBase.hpp index 1fa8f1fb8b04..b1dc8b8a3082 100644 --- a/SU2_CFD/include/solvers/CFVMFlowSolverBase.hpp +++ b/SU2_CFD/include/solvers/CFVMFlowSolverBase.hpp @@ -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. diff --git a/SU2_CFD/include/solvers/CSolver.hpp b/SU2_CFD/include/solvers/CSolver.hpp index ba28bf8b1933..06cd950aa138 100644 --- a/SU2_CFD/include/solvers/CSolver.hpp +++ b/SU2_CFD/include/solvers/CSolver.hpp @@ -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. diff --git a/SU2_CFD/src/python_wrapper_structure.cpp b/SU2_CFD/src/python_wrapper_structure.cpp index f470bc035642..ffcc36d2f54a 100644 --- a/SU2_CFD/src/python_wrapper_structure.cpp +++ b/SU2_CFD/src/python_wrapper_structure.cpp @@ -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.) */ ///////////////////////////////////////////////////////////////////////////////////////////////////////////////// @@ -156,3 +166,4 @@ void CDriver::SetRotationRate(passivedouble rot_x, passivedouble rot_y, passived config_container[iZone]->SetRotation_Rate(2, rot_z); } } + diff --git a/SU2_CFD/src/solvers/CEulerSolver.cpp b/SU2_CFD/src/solvers/CEulerSolver.cpp index 547cc8c307c6..6fe92b813d3b 100644 --- a/SU2_CFD/src/solvers/CEulerSolver.cpp +++ b/SU2_CFD/src/solvers/CEulerSolver.cpp @@ -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) { @@ -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); } }