diff --git a/Common/include/config_structure.hpp b/Common/include/config_structure.hpp index e221482d17a8..3bc8f4e50788 100644 --- a/Common/include/config_structure.hpp +++ b/Common/include/config_structure.hpp @@ -615,16 +615,17 @@ class CConfig { su2double Total_CD; /*!< \brief Specify a target CL instead of AoA (external flow only). */ su2double dCL_dAlpha; /*!< \brief value of dCl/dAlpha. */ su2double dCM_diH; /*!< \brief value of dCM/dHi. */ - unsigned long Iter_Fixed_CL; /*!< \brief Iterations to re-evaluate the angle of attack (external flow only). */ unsigned long Iter_Fixed_CM; /*!< \brief Iterations to re-evaluate the angle of attack (external flow only). */ unsigned long Iter_Fixed_NetThrust; /*!< \brief Iterations to re-evaluate the angle of attack (external flow only). */ unsigned long Iter_dCL_dAlpha; /*!< \brief Number of iterations to evaluate dCL_dAlpha. */ unsigned long Update_Alpha; /*!< \brief Iterations to re-evaluate the angle of attack (external flow only). */ unsigned long Update_iH; /*!< \brief Iterations to re-evaluate the angle of attack (external flow only). */ unsigned long Update_BCThrust; /*!< \brief Iterations to re-evaluate the angle of attack (external flow only). */ - su2double dNetThrust_dBCThrust; /*!< \brief value of dCl/dAlpha. */ + su2double dNetThrust_dBCThrust; /*!< \brief value of dNetThrust/dBCThrust. */ bool Update_BCThrust_Bool; /*!< \brief Boolean flag for whether to update the AoA for fixed lift mode on a given iteration. */ bool Update_AoA; /*!< \brief Boolean flag for whether to update the AoA for fixed lift mode on a given iteration. */ + unsigned long Update_AoA_Iter_Limit; /*!< \brief Limit on number of iterations between AoA updates for fixed lift mode */ + bool Finite_Difference_Mode; bool Update_HTPIncidence; /*!< \brief Boolean flag for whether to update the AoA for fixed lift mode on a given iteration. */ su2double ChargeCoeff; /*!< \brief Charge coefficient (just for poisson problems). */ unsigned short Cauchy_Func_Flow, /*!< \brief Function where to apply the convergence criteria in the flow problem. */ @@ -8246,12 +8247,6 @@ class CConfig { */ su2double GetdCL_dAlpha(void); - /*! - * \brief Get the value of iterations to re-evaluate the angle of attack. - * \return Number of iterations. - */ - unsigned long GetUpdate_Alpha(void); - /*! * \brief Number of iterations to evaluate dCL_dAlpha. * \return Number of iterations. @@ -8264,12 +8259,6 @@ class CConfig { */ su2double GetdCM_diH(void); - /*! - * \brief Get the value of iterations to re-evaluate the angle of attack. - * \return Number of iterations. - */ - unsigned long GetIter_Fixed_CL(void); - /*! * \brief Get the value of iterations to re-evaluate the angle of attack. * \return Number of iterations. @@ -8311,6 +8300,23 @@ class CConfig { * \return TRUE if we should update the AoA for fixed lift mode; otherwise FALSE. */ bool GetUpdate_AoA(void); + + /*! + * \brief Get the maximum number of iterations between AoA updates for fixed C_L mode + * \return Number of maximum iterations between AoA updates + */ + unsigned long GetUpdate_AoA_Iter_Limit(void); + + /*! + * \brief Get whether at the end of finite differencing (Fixed CL mode) + * \return boolean indicating end of finite differencing mode (Fixed CL mode) + */ + bool GetFinite_Difference_Mode(void); + + /*! + * \brief Set whether at the end of finite differencing (Fixed CL mode) + */ + void SetFinite_Difference_Mode(bool val_fd_mode); /*! * \brief Set the current number of non-physical nodes in the solution. @@ -9214,6 +9220,13 @@ class CConfig { * \return */ unsigned long GetHistory_Wrt_Freq(unsigned short iter); + + /*! + * \brief SetHistory_Wrt_Freq_Inner + * \param[in] iter: index for Time (0), Outer (1), or Inner (2) iterations + * \param[in] nIter: Number of iterations + */ + void SetHistory_Wrt_Freq(unsigned short iter, unsigned long nIter); /*! * \brief GetScreen_Wrt_Freq_Inner @@ -9221,6 +9234,13 @@ class CConfig { */ unsigned long GetScreen_Wrt_Freq(unsigned short iter); + /*! + * \brief SetScreen_Wrt_Freq_Inner + * \param[in] iter: index for Time (0), Outer (1), or Inner (2) iterations + * \param[in] nIter: Number of iterations + */ + void SetScreen_Wrt_Freq(unsigned short iter, unsigned long nIter); + /*! * \brief GetScreen_Wrt_Freq_Inner * \return diff --git a/Common/include/config_structure.inl b/Common/include/config_structure.inl index 7d1b2024d209..c46f1512e021 100644 --- a/Common/include/config_structure.inl +++ b/Common/include/config_structure.inl @@ -1769,14 +1769,16 @@ inline su2double CConfig::GetdCM_diH(void) {return dCM_diH; } inline unsigned long CConfig::GetIter_Fixed_NetThrust(void) {return Iter_Fixed_NetThrust; } -inline unsigned long CConfig::GetIter_Fixed_CL(void) { return Iter_Fixed_CL; } - -inline unsigned long CConfig::GetUpdate_Alpha(void) {return Update_Alpha; } - inline unsigned long CConfig::GetIter_dCL_dAlpha(void) {return Iter_dCL_dAlpha; } inline bool CConfig::GetUpdate_AoA(void) { return Update_AoA; } +inline unsigned long CConfig::GetUpdate_AoA_Iter_Limit(void) { return Update_AoA_Iter_Limit; } + +inline bool CConfig::GetFinite_Difference_Mode(void) { return Finite_Difference_Mode; } + +inline void CConfig::SetFinite_Difference_Mode(bool val_fd_mode) { Finite_Difference_Mode = val_fd_mode; } + inline bool CConfig::GetUpdate_BCThrust_Bool(void) { return Update_BCThrust_Bool; } inline void CConfig::SetUpdate_AoA(bool val_update) { Update_AoA = val_update; } @@ -2074,8 +2076,12 @@ inline su2double CConfig::Get_StartTime() {return StartTime;} inline unsigned long CConfig::GetHistory_Wrt_Freq(unsigned short iter) {return HistoryWrtFreq[iter];} +inline void CConfig::SetHistory_Wrt_Freq(unsigned short iter, unsigned long nIter) { HistoryWrtFreq[iter] = nIter;} + inline unsigned long CConfig::GetScreen_Wrt_Freq(unsigned short iter) {return ScreenWrtFreq[iter];} +inline void CConfig::SetScreen_Wrt_Freq(unsigned short iter, unsigned long nIter) { ScreenWrtFreq[iter] = nIter;} + inline unsigned long CConfig::GetVolume_Wrt_Freq() {return VolumeWrtFreq;} inline unsigned short* CConfig::GetVolumeOutputFiles() {return VolumeOutputFiles;} diff --git a/Common/src/config_structure.cpp b/Common/src/config_structure.cpp index 68d765f17e2f..d2009e0f1ad2 100644 --- a/Common/src/config_structure.cpp +++ b/Common/src/config_structure.cpp @@ -1097,8 +1097,8 @@ void CConfig::SetConfig_Options() { addDoubleOption("DCL_DALPHA", dCL_dAlpha, 0.2); /* DESCRIPTION: Damping factor for fixed CL mode. */ addDoubleOption("DCM_DIH", dCM_diH, 0.05); - /* DESCRIPTION: Number of times Alpha is updated in a fix CL problem. */ - addUnsignedLongOption("UPDATE_ALPHA", Update_Alpha, 5); + /* DESCRIPTION: Maximum number of iterations between AoA updates for fixed CL problem. */ + addUnsignedLongOption("UPDATE_AOA_ITER_LIMIT", Update_AoA_Iter_Limit, 200); /* DESCRIPTION: Number of times Alpha is updated in a fix CL problem. */ addUnsignedLongOption("UPDATE_IH", Update_iH, 5); /* DESCRIPTION: Number of iterations to evaluate dCL_dAlpha . */ @@ -2947,9 +2947,8 @@ void CConfig::SetPostprocessing(unsigned short val_software, unsigned short val_ } /*--- Initialize the AoA and Sideslip variables for the incompressible - solver. This is typically unused (often internal flows). This also - is necessary to avoid any issues with the AoA adjustments for the - compressible code for fixed lift mode (including the adjoint). ---*/ + solver. This is typically unused (often internal flows). Also fixed CL + mode for incompressible flows is not implemented ---*/ if (Kind_Solver == INC_EULER || Kind_Solver == INC_NAVIER_STOKES || @@ -2976,6 +2975,10 @@ void CConfig::SetPostprocessing(unsigned short val_software, unsigned short val_ SetAoA(alpha); SetAoS(beta); + + if (Fixed_CL_Mode) { + SU2_MPI::Error(string("Fixed CL mode not implemented for the incompressible solver. \n"), CURRENT_FUNCTION); + } } @@ -3128,7 +3131,7 @@ void CConfig::SetPostprocessing(unsigned short val_software, unsigned short val_ } } - /*--- The that Discard_InFiles is false, owerwise the gradient could be wrong ---*/ + /*--- Ensure that Discard_InFiles is false, owerwise the gradient could be wrong ---*/ if ((ContinuousAdjoint || DiscreteAdjoint) && Fixed_CL_Mode && !Eval_dOF_dCX) Discard_InFiles = false; @@ -3360,6 +3363,7 @@ void CConfig::SetPostprocessing(unsigned short val_software, unsigned short val_ } } } + /*--- The Line Search should be applied only in the deformation stage. ---*/ if (Kind_SU2 != SU2_DEF) { @@ -3892,7 +3896,6 @@ void CConfig::SetPostprocessing(unsigned short val_software, unsigned short val_ /*--- Evaluate when the Cl should be evaluated ---*/ - Iter_Fixed_CL = SU2_TYPE::Int(nInnerIter / (su2double(Update_Alpha)+1)); Iter_Fixed_CM = SU2_TYPE::Int(nInnerIter / (su2double(Update_iH)+1)); Iter_Fixed_NetThrust = SU2_TYPE::Int(nInnerIter / (su2double(Update_BCThrust)+1)); @@ -3903,7 +3906,6 @@ void CConfig::SetPostprocessing(unsigned short val_software, unsigned short val_ CFL[0] = CFL[0] * CFLRedCoeff_AdjFlow; CFL_AdaptParam[2] *= CFLRedCoeff_AdjFlow; CFL_AdaptParam[3] *= CFLRedCoeff_AdjFlow; - Iter_Fixed_CL = SU2_TYPE::Int(su2double (Iter_Fixed_CL) / CFLRedCoeff_AdjFlow); Iter_Fixed_CM = SU2_TYPE::Int(su2double (Iter_Fixed_CM) / CFLRedCoeff_AdjFlow); Iter_Fixed_NetThrust = SU2_TYPE::Int(su2double (Iter_Fixed_NetThrust) / CFLRedCoeff_AdjFlow); } @@ -3916,7 +3918,9 @@ void CConfig::SetPostprocessing(unsigned short val_software, unsigned short val_ Kappa_Flow[1] = Kappa_AdjFlow[1]; } - if (Iter_Fixed_CL == 0) { Iter_Fixed_CL = nInnerIter+1; Update_Alpha = 0; } + if (Update_AoA_Iter_Limit == 0 && Fixed_CL_Mode) { + SU2_MPI::Error("ERROR: Please specify non-zero UPDATE_AOA_ITER_LIMIT.", CURRENT_FUNCTION); + } if (Iter_Fixed_CM == 0) { Iter_Fixed_CM = nInnerIter+1; Update_iH = 0; } if (Iter_Fixed_NetThrust == 0) { Iter_Fixed_NetThrust = nInnerIter+1; Update_BCThrust = 0; } @@ -4197,17 +4201,23 @@ void CConfig::SetPostprocessing(unsigned short val_software, unsigned short val_ } - /*--- If it is a fixed mode problem, then we will add 100 iterations to + /*--- If it is a fixed mode problem, then we will add Iter_dCL_dAlpha iterations to evaluate the derivatives with respect to a change in the AoA and CL ---*/ if (!ContinuousAdjoint & !DiscreteAdjoint) { - if ((Fixed_CL_Mode) || (Fixed_CM_Mode)) { - ConvCriteria = RESIDUAL; - nInnerIter += Iter_dCL_dAlpha; - MinLogResidual = -24; - } + if (Fixed_CL_Mode) nInnerIter += Iter_dCL_dAlpha; + + if (Fixed_CM_Mode) { + nInnerIter += Iter_dCL_dAlpha; + ConvCriteria = RESIDUAL; + MinLogResidual = -24; + } } + /* --- Set Finite Difference mode to false by default --- */ + + Finite_Difference_Mode = false; + /* --- Throw error if UQ used for any turbulence model other that SST --- */ if (Kind_Solver == RANS && Kind_Turb_Model != SST && Kind_Turb_Model != SST_SUST && using_uq){ diff --git a/SU2_CFD/include/iteration_structure.hpp b/SU2_CFD/include/iteration_structure.hpp index cbf3f0177c7f..894ab0423133 100644 --- a/SU2_CFD/include/iteration_structure.hpp +++ b/SU2_CFD/include/iteration_structure.hpp @@ -514,6 +514,17 @@ virtual bool Monitor(COutput *output, */ void InitializeVortexDistribution(unsigned long &nVortex, vector& x0, vector& y0, vector& vort_strength, vector& r_core); + + /*! + * \brief Fixed CL monitoring function + * \author J. Mukhopadhaya + * \param[in] output - Pointer to the COutput class. + * \param[in] geometry - Geometrical definition of the problem. + * \param[in] solver - Pointer to the flow solver + * \param[in] config - Definition of the particular problem. + * \return Boolean indicating weather calculation should be stopped + */ + bool MonitorFixed_CL(COutput *output, CGeometry *geometry, CSolver **solver, CConfig *config); }; diff --git a/SU2_CFD/include/output/CFlowCompOutput.hpp b/SU2_CFD/include/output/CFlowCompOutput.hpp index b48714ddb931..44ba12a9f41b 100644 --- a/SU2_CFD/include/output/CFlowCompOutput.hpp +++ b/SU2_CFD/include/output/CFlowCompOutput.hpp @@ -50,6 +50,7 @@ class CFlowCompOutput final: public CFlowOutput { private: unsigned short turb_model; //!< Kind of turbulence model + unsigned long lastInnerIter; public: @@ -118,5 +119,21 @@ class CFlowCompOutput final: public CFlowOutput { */ bool SetUpdate_Averages(CConfig *config) override; + /*! + * \brief Write any additional output defined for the current solver. + * \param[in] config - Definition of the particular problem per zone. + */ + void SetAdditionalScreenOutput(CConfig *config) override; + + /*! + * \brief Write additional output for fixed CL mode. + * \param[in] config - Definition of the particular problem per zone. + */ + void SetFixedCLScreenOutput(CConfig *config); + /*! + * \brief Determines if the history file output. + * \param[in] config - Definition of the particular problem. + */ + bool WriteHistoryFile_Output(CConfig *config) override; }; diff --git a/SU2_CFD/include/output/CFlowOutput.hpp b/SU2_CFD/include/output/CFlowOutput.hpp index 0e663404b286..79f495fe5ae3 100644 --- a/SU2_CFD/include/output/CFlowOutput.hpp +++ b/SU2_CFD/include/output/CFlowOutput.hpp @@ -105,10 +105,9 @@ class CFlowOutput : public COutput{ /*! * \brief Write information to meta data file - * \param[in] output - Container holding the output instances per zone. * \param[in] config - Definition of the particular problem per zone. */ - void WriteMetaData(CConfig *config, CGeometry *geometry); + void WriteMetaData(CConfig *config); /*! * \brief Write any additional files defined for the current solver. @@ -122,8 +121,9 @@ class CFlowOutput : public COutput{ * \brief Determines if the the volume output should be written. * \param[in] config - Definition of the particular problem. * \param[in] Iter - Current iteration index. + * \param[in] force_writing - boolean that forces writing of volume output */ - bool WriteVolume_Output(CConfig *config, unsigned long Iter) override; + bool WriteVolume_Output(CConfig *config, unsigned long Iter, bool force_writing) override; /*! * \brief Write the forces breakdown file diff --git a/SU2_CFD/include/output/COutput.hpp b/SU2_CFD/include/output/COutput.hpp index 71b69e618ad3..2ecb3b9459f7 100644 --- a/SU2_CFD/include/output/COutput.hpp +++ b/SU2_CFD/include/output/COutput.hpp @@ -691,8 +691,9 @@ class COutput { * \brief Determines if the the volume output should be written. * \param[in] config - Definition of the particular problem. * \param[in] Iter - Current iteration index. + * \param[in] force_writing - boolean that forces writing of volume output */ - virtual bool WriteVolume_Output(CConfig *config, unsigned long Iter); + virtual bool WriteVolume_Output(CConfig *config, unsigned long Iter, bool force_writing); /*! * \brief Set the values of the volume output fields for a point. @@ -782,5 +783,11 @@ class COutput { */ inline virtual void WriteAdditionalFiles(CConfig *config, CGeometry* geometry, CSolver** solver_container){} + /*! + * \brief Write any additional output defined for the current solver. + * \param[in] config - Definition of the particular problem per zone. + */ + inline virtual void SetAdditionalScreenOutput(CConfig *config){} + }; diff --git a/SU2_CFD/include/solver_structure.hpp b/SU2_CFD/include/solver_structure.hpp index d48fb201c88d..ae2a784bcba5 100644 --- a/SU2_CFD/include/solver_structure.hpp +++ b/SU2_CFD/include/solver_structure.hpp @@ -2103,6 +2103,44 @@ class CSolver { */ virtual void SetFarfield_AoA(CGeometry *geometry, CSolver **solver_container, CConfig *config, unsigned short iMesh, bool Output); + + /*! + * \brief A virtual member. + * \param[in] config - Definition of the particular problem. + * \param[in] convergence - boolean for whether the solution is converged + * \return boolean for whether the Fixed C_L mode is converged to target C_L + */ + virtual bool FixedCL_Convergence(CConfig *config, bool convergence); + + /*! + * \brief A virtual member. + * \return boolean for whether the Fixed C_L mode is currently in finite-differencing mode + */ + virtual bool GetStart_AoA_FD(void); + + /*! + * \brief A virtual member. + * \return boolean for whether the Fixed C_L mode is currently in finite-differencing mode + */ + virtual bool GetEnd_AoA_FD(void); + + /*! + * \brief A virtual member. + * \return value for the last iteration that the AoA was updated + */ + virtual unsigned long GetIter_Update_AoA(); + + /*! + * \brief A virtual member. + * \return value of the AoA before most recent update + */ + virtual su2double GetPrevious_AoA(); + + /*! + * \brief A virtual member. + * \return value of CL Driver control command (AoA_inc) + */ + virtual su2double GetAoA_inc(); /*! * \brief A virtual member. @@ -4835,7 +4873,6 @@ class CEulerSolver : public CSolver { su2double Total_ComboObj, /*!< \brief Total 'combo' objective for all monitored boundaries */ - AoA_Prev, /*!< \brief Old value of the AoA for fixed lift mode. */ Total_CD, /*!< \brief Total drag coefficient for all the boundaries. */ Total_CL, /*!< \brief Total lift coefficient for all the boundaries. */ Total_CL_Prev, /*!< \brief Total lift coefficient for all the boundaries (fixed lift mode). */ @@ -4910,16 +4947,14 @@ class CEulerSolver : public CSolver { su2double *Secondary, /*!< \brief Auxiliary nPrimVar vector. */ *Secondary_i, /*!< \brief Auxiliary nPrimVar vector for storing the primitive at point i. */ *Secondary_j; /*!< \brief Auxiliary nPrimVar vector for storing the primitive at point j. */ - - su2double Cauchy_Value, /*!< \brief Summed value of the convergence indicator. */ - Cauchy_Func; /*!< \brief Current value of the convergence indicator at one iteration. */ - unsigned short Cauchy_Counter; /*!< \brief Number of elements of the Cauchy serial. */ - su2double *Cauchy_Serie; /*!< \brief Complete Cauchy serial. */ - su2double Old_Func, /*!< \brief Old value of the objective function (the function which is monitored). */ - New_Func; /*!< \brief Current value of the objective function (the function which is monitored). */ - su2double AoA_old; /*!< \brief Old value of the angle of attack (monitored). */ - unsigned long AoA_Counter; - bool AoA_FD_Change; + + su2double AoA_Prev, /*!< \brief Old value of the angle of attack (monitored). */ + AoA_inc; + bool Start_AoA_FD, /*!< \brief Boolean for start of finite differencing for FixedCL mode */ + End_AoA_FD, /*!< \brief Boolean for end of finite differencing for FixedCL mode */ + Update_AoA; /*!< \brief Boolean to signal Angle of Attack Update */ + unsigned long Iter_Update_AoA; /*!< \brief Iteration at which AoA was updated last */ + su2double dCL_dAlpha; /*!< \brief Value of dCL_dAlpha used to control CL in fixed CL mode */ unsigned long BCThrust_Counter; unsigned short nSpanWiseSections; /*!< \brief Number of span-wise sections. */ unsigned short nSpanMax; /*!< \brief Max number of maximum span-wise sections for all zones */ @@ -5550,6 +5585,50 @@ class CEulerSolver : public CSolver { */ void SetFarfield_AoA(CGeometry *geometry, CSolver **solver_container, CConfig *config, unsigned short iMesh, bool Output); + + /*! + * \brief Check for convergence of the Fixed CL mode to the target CL + * \param[in] config - Definition of the particular problem. + * \param[in] convergence - boolean for whether the solution is converged + * \return boolean for whether the Fixed CL mode is converged to target CL + */ + bool FixedCL_Convergence(CConfig *config, bool convergence); + + /*! + * \brief Checking whether fixed CL mode in finite-differencing mode + * \return boolean for whether the Fixed CL mode is currently in finite-differencing mode + */ + bool GetStart_AoA_FD(void); + + /*! + * \brief Checking whether fixed CL mode in finite-differencing mode + * \return boolean for whether the Fixed CL mode is currently in finite-differencing mode + */ + bool GetEnd_AoA_FD(void); + + /*! + * \brief Get the iteration of the last AoA update (Fixed CL Mode) + * \return value for the last iteration that the AoA was updated + */ + unsigned long GetIter_Update_AoA(); + + /*! + * \brief Get the AoA before the most recent update + * \return value of the AoA before most recent update + */ + su2double GetPrevious_AoA(); + + /*! + * \brief Get the CL Driver's control command + * \return value of CL Driver control command (AoA_inc) + */ + su2double GetAoA_inc(); + + /*! + * \brief Set gradients of coefficients for fixed CL mode + * \param[in] config - Definition of the particular problem. + */ + void SetCoefficient_Gradients(CConfig *config); /*! * \brief Update the solution using the explicit Euler scheme. @@ -7181,19 +7260,13 @@ class CIncEulerSolver : public CSolver { AllBound_CQ_Mnt; /*!< \brief Total torque coefficient (inviscid contribution) for all the boundaries. */ su2double - AoA_Prev, /*!< \brief Old value of the AoA for fixed lift mode. */ Total_ComboObj, /*!< \brief Total 'combo' objective for all monitored boundaries */ Total_CD, /*!< \brief Total drag coefficient for all the boundaries. */ - Total_CD_Prev, /*!< \brief Total drag coefficient for all the boundaries (fixed lift mode). */ Total_CL, /*!< \brief Total lift coefficient for all the boundaries. */ - Total_CL_Prev, /*!< \brief Total lift coefficient for all the boundaries (fixed lift mode). */ Total_CSF, /*!< \brief Total sideforce coefficient for all the boundaries. */ Total_CMx, /*!< \brief Total x moment coefficient for all the boundaries. */ - Total_CMx_Prev, /*!< \brief Total x moment coefficient for all the boundaries. */ Total_CMy, /*!< \brief Total y moment coefficient for all the boundaries. */ - Total_CMy_Prev, /*!< \brief Total y moment coefficient for all the boundaries. */ Total_CMz, /*!< \brief Total z moment coefficient for all the boundaries. */ - Total_CMz_Prev, /*!< \brief Total z moment coefficient for all the boundaries. */ Total_CoPx, /*!< \brief Total x moment coefficient for all the boundaries. */ Total_CoPy, /*!< \brief Total y moment coefficient for all the boundaries. */ Total_CoPz, /*!< \brief Total z moment coefficient for all the boundaries. */ @@ -7236,15 +7309,6 @@ class CIncEulerSolver : public CSolver { su2double *Primitive, /*!< \brief Auxiliary nPrimVar vector. */ *Primitive_i, /*!< \brief Auxiliary nPrimVar vector for storing the primitive at point i. */ *Primitive_j; /*!< \brief Auxiliary nPrimVar vector for storing the primitive at point j. */ - - su2double Cauchy_Value, /*!< \brief Summed value of the convergence indicator. */ - Cauchy_Func; /*!< \brief Current value of the convergence indicator at one iteration. */ - unsigned short Cauchy_Counter; /*!< \brief Number of elements of the Cauchy serial. */ - su2double *Cauchy_Serie; /*!< \brief Complete Cauchy serial. */ - su2double Old_Func, /*!< \brief Old value of the objective function (the function which is monitored). */ - New_Func; /*!< \brief Current value of the objective function (the function which is monitored). */ - su2double AoA_old; /*!< \brief Old value of the angle of attack (monitored). */ - unsigned long AoA_Counter; CFluidModel *FluidModel; /*!< \brief fluid model used in the solver */ su2double **Preconditioner; /*!< \brief Auxiliary matrix for storing the low speed preconditioner. */ @@ -7600,17 +7664,6 @@ class CIncEulerSolver : public CSolver { void ExplicitRK_Iteration(CGeometry *geometry, CSolver **solver_container, CConfig *config, unsigned short iRKStep); - /*! - * \brief Update the AoA and freestream velocity at the farfield. - * \param[in] geometry - Geometrical definition of the problem. - * \param[in] solver_container - Container vector with all the solutions. - * \param[in] config - Definition of the particular problem. - * \param[in] iMesh - current mesh level for the multigrid. - * \param[in] Output - boolean to determine whether to print output. - */ - void SetFarfield_AoA(CGeometry *geometry, CSolver **solver_container, - CConfig *config, unsigned short iMesh, bool Output); - /*! * \brief Update the solution using the explicit Euler scheme. * \param[in] geometry - Geometrical definition of the problem. @@ -10385,7 +10438,6 @@ class CAdjEulerSolver : public CSolver { su2double pnorm, Area_Monitored; /*!< \brief Store the total area of the monitored outflow surface (used for normalization in continuous adjoint outflow conditions) */ - unsigned long AoA_Counter; su2double ACoeff, ACoeff_inc, ACoeff_old; bool Update_ACoeff; @@ -13104,14 +13156,6 @@ class CFEM_DG_EulerSolver : public CSolver { *Surface_CMz, /*!< \brief z Moment coefficient for each monitoring surface. */ *Surface_CEff; /*!< \brief Efficiency (Cl/Cd) for each monitoring surface. */ - su2double Cauchy_Value, /*!< \brief Summed value of the convergence indicator. */ - Cauchy_Func; /*!< \brief Current value of the convergence indicator at one iteration. */ - unsigned short Cauchy_Counter; /*!< \brief Number of elements of the Cauchy serial. */ - su2double *Cauchy_Serie; /*!< \brief Complete Cauchy serial. */ - su2double Old_Func, /*!< \brief Old value of the objective function (the function which is monitored). */ - New_Func; /*!< \brief Current value of the objective function (the function which is monitored). */ - - unsigned long nDOFsLocTot; /*!< \brief Total number of local DOFs, including halos. */ unsigned long nDOFsLocOwned; /*!< \brief Number of owned local DOFs. */ unsigned long nDOFsGlobal; /*!< \brief Number of global DOFs. */ diff --git a/SU2_CFD/include/solver_structure.inl b/SU2_CFD/include/solver_structure.inl index 9d47478bbb92..8ade67dfd50b 100644 --- a/SU2_CFD/include/solver_structure.inl +++ b/SU2_CFD/include/solver_structure.inl @@ -781,6 +781,18 @@ inline void CSolver::GetEllipticSpanLoad_Diff(CGeometry *geometry, CConfig *conf inline void CSolver::SetFarfield_AoA(CGeometry *geometry, CSolver **solver_container, CConfig *config, unsigned short iMesh, bool Output) { } +inline bool CSolver::FixedCL_Convergence(CConfig *config, bool convergence) { return false; } + +inline bool CSolver::GetStart_AoA_FD(void) { return false; } + +inline bool CSolver::GetEnd_AoA_FD(void) { return false; } + +inline unsigned long CSolver::GetIter_Update_AoA(void) { return 0; } + +inline su2double CSolver::GetPrevious_AoA(void) { return 0.0; } + +inline su2double CSolver::GetAoA_inc(void) { return 0.0; } + inline void CSolver::SetActDisk_BCThrust(CGeometry *geometry, CSolver **solver_container, CConfig *config, unsigned short iMesh, bool Output) { } @@ -1641,6 +1653,16 @@ inline void CEulerSolver::SetPressure_Inf(su2double p_inf) {Pressure_Inf = p_inf inline void CEulerSolver::SetTemperature_Inf(su2double t_inf) {Temperature_Inf = t_inf;} +inline bool CEulerSolver::GetStart_AoA_FD(void) { return Start_AoA_FD; } + +inline bool CEulerSolver::GetEnd_AoA_FD(void) { return End_AoA_FD; } + +inline unsigned long CEulerSolver::GetIter_Update_AoA(void) { return Iter_Update_AoA; } + +inline su2double CEulerSolver::GetPrevious_AoA(void) { return AoA_Prev; } + +inline su2double CEulerSolver::GetAoA_inc(void) { return AoA_inc; } + inline su2double CNSSolver::GetViscosity_Inf(void) { return Viscosity_Inf; } inline su2double CNSSolver::GetTke_Inf(void) { return Tke_Inf; } diff --git a/SU2_CFD/src/integration_time.cpp b/SU2_CFD/src/integration_time.cpp index 6f7602073fcd..46fd945665ac 100644 --- a/SU2_CFD/src/integration_time.cpp +++ b/SU2_CFD/src/integration_time.cpp @@ -172,7 +172,7 @@ void CMultiGridIntegration::MultiGrid_Cycle(CGeometry ****geometry, } /*--- Compute Forcing Term $P_(k+1) = I^(k+1)_k(P_k+F_k(u_k))-F_(k+1)(I^(k+1)_k u_k)$ and update solution for multigrid ---*/ - if ( iMesh < config[iZone]->GetnMGLevels() ) { + if ( iMesh < config[iZone]->GetnMGLevels() ) { /*--- Compute $r_k = P_k + F_k(u_k)$ ---*/ solver_container[iZone][iInst][iMesh][SolContainer_Position]->Preprocessing(geometry[iZone][iInst][iMesh], solver_container[iZone][iInst][iMesh], config[iZone], iMesh, NO_RK_ITER, RunTime_EqSystem, false); diff --git a/SU2_CFD/src/iteration_structure.cpp b/SU2_CFD/src/iteration_structure.cpp index 41e56f75383e..bf026f5c7bde 100644 --- a/SU2_CFD/src/iteration_structure.cpp +++ b/SU2_CFD/src/iteration_structure.cpp @@ -601,7 +601,6 @@ void CFluidIteration::Iterate(COutput *output, } } - } void CFluidIteration::Update(COutput *output, @@ -692,11 +691,17 @@ bool CFluidIteration::Monitor(COutput *output, /*--- If convergence was reached --*/ StopCalc = output->GetConvergence(); + + /* --- Checking convergence of Fixed CL mode to target CL, and perform finite differencing if needed --*/ - return StopCalc; + if (config[val_iZone]->GetFixed_CL_Mode()){ + StopCalc = MonitorFixed_CL(output, geometry[val_iZone][INST_0][MESH_0], solver[val_iZone][INST_0][MESH_0], config[val_iZone]); + } + return StopCalc; } + void CFluidIteration::Postprocess(COutput *output, CIntegration ****integration, CGeometry ****geometry, @@ -1033,6 +1038,29 @@ void CFluidIteration::InitializeVortexDistribution(unsigned long &nVortex, vecto } +bool CFluidIteration::MonitorFixed_CL(COutput *output, CGeometry *geometry, CSolver **solver, CConfig *config) { + + CSolver* flow_solver= solver[FLOW_SOL]; + + bool fixed_cl_convergence = flow_solver->FixedCL_Convergence(config, output->GetConvergence()); + + /* --- If Fixed CL mode has ended and Finite Differencing has started: --- */ + + if (flow_solver->GetStart_AoA_FD() && flow_solver->GetIter_Update_AoA() == config->GetInnerIter()){ + + /* --- Print convergence history and volume files since fixed CL mode has converged--- */ + if (rank == MASTER_NODE) output->PrintConvergenceSummary(); + + output->SetResult_Files(geometry, config, solver, + config->GetInnerIter(), true); + + /* --- Set finite difference mode in config (disables output) --- */ + config->SetFinite_Difference_Mode(true); + } + + /* --- Set convergence based on fixed CL convergence --- */ + return fixed_cl_convergence; +} CTurboIteration::CTurboIteration(CConfig *config) : CFluidIteration(config) { } CTurboIteration::~CTurboIteration(void) { } diff --git a/SU2_CFD/src/output/CFlowCompOutput.cpp b/SU2_CFD/src/output/CFlowCompOutput.cpp index 807bb8ce2c82..9abb42bae846 100644 --- a/SU2_CFD/src/output/CFlowCompOutput.cpp +++ b/SU2_CFD/src/output/CFlowCompOutput.cpp @@ -43,7 +43,7 @@ CFlowCompOutput::CFlowCompOutput(CConfig *config, unsigned short nDim) : CFlowOutput(config, nDim, false) { turb_model = config->GetKind_Turb_Model(); - + lastInnerIter = curInnerIter; gridMovement = config->GetGrid_Movement(); /*--- Set the default history fields if nothing is set in the config file ---*/ @@ -90,7 +90,20 @@ CFlowCompOutput::CFlowCompOutput(CConfig *config, unsigned short nDim) : CFlowOu /*--- Set the default convergence field --- */ if (convFields.empty() ) convFields.emplace_back("RMS_DENSITY"); - + + if (config->GetFixed_CL_Mode()) { + bool found = false; + for (unsigned short iField = 0; iField < convFields.size(); iField++) + if (convFields[iField] == "LIFT") found = true; + if (!found) { + if (rank == MASTER_NODE) + cout<<" Fixed CL: Adding LIFT as Convergence Field to ensure convergence to target CL"<(nCauchy_Elems, 0.0)); + } + } } CFlowCompOutput::~CFlowCompOutput(void) {} @@ -235,6 +248,18 @@ void CFlowCompOutput::SetHistoryOutputFields(CConfig *config){ AddHistoryOutput("CFL_NUMBER", "CFL number", ScreenOutputFormat::SCIENTIFIC, "CFL_NUMBER", "Current value of the CFL number"); + /// /// BEGIN_GROUP: FIXED_CL, DESCRIPTION: Relevant outputs for the Fixed CL mode + if (config->GetFixed_CL_Mode()){ + /// DESCRIPTION: Difference between current and target CL + AddHistoryOutput("DELTA_CL", "Delta_CL", ScreenOutputFormat::SCIENTIFIC, "FIXED_CL", "Difference between Target CL and current CL", HistoryFieldType::COEFFICIENT); + /// DESCRIPTION: Angle of attack before the most recent update + AddHistoryOutput("PREV_AOA", "Previous_AOA", ScreenOutputFormat::FIXED, "FIXED_CL", "Angle of Attack at the previous iteration of the Fixed CL driver"); + /// DESCRIPTION: Last change in angle of attack by the Fixed CL driver + AddHistoryOutput("CHANGE_IN_AOA", "Change_in_AOA", ScreenOutputFormat::SCIENTIFIC, "FIXED_CL", "Last change in Angle of Attack by Fixed CL Driver", HistoryFieldType::RESIDUAL); + /// DESCRIPTION: AOA control command by the CL Driver + AddHistoryOutput("CL_DRIVER_COMMAND", "CL_Driver_Command", ScreenOutputFormat::SCIENTIFIC, "FIXED_CL", "CL Driver's control command", HistoryFieldType::RESIDUAL); + } + if (config->GetDeform_Mesh()){ AddHistoryOutput("DEFORM_MIN_VOLUME", "MinVolume", ScreenOutputFormat::SCIENTIFIC, "DEFORM", "Minimum volume in the mesh"); AddHistoryOutput("DEFORM_MAX_VOLUME", "MaxVolume", ScreenOutputFormat::SCIENTIFIC, "DEFORM", "Maximum volume in the mesh"); @@ -631,6 +656,14 @@ void CFlowCompOutput::LoadHistoryData(CConfig *config, CGeometry *geometry, CSol SetHistoryOutputValue("DEFORM_ITER", mesh_solver->GetIterLinSolver()); SetHistoryOutputValue("DEFORM_RESIDUAL", log10(mesh_solver->GetLinSol_Residual())); } + + if(config->GetFixed_CL_Mode()){ + SetHistoryOutputValue("DELTA_CL", fabs(flow_solver->GetTotal_CL() - config->GetTarget_CL())); + SetHistoryOutputValue("PREV_AOA", flow_solver->GetPrevious_AoA()); + SetHistoryOutputValue("CHANGE_IN_AOA", config->GetAoA()-flow_solver->GetPrevious_AoA()); + SetHistoryOutputValue("CL_DRIVER_COMMAND", flow_solver->GetAoA_inc()); + + } /*--- Set the analyse surface history values --- */ @@ -664,3 +697,53 @@ bool CFlowCompOutput::SetUpdate_Averages(CConfig *config){ } +void CFlowCompOutput::SetAdditionalScreenOutput(CConfig *config){ + + if (config->GetFixed_CL_Mode()){ + SetFixedCLScreenOutput(config); + } +} + +void CFlowCompOutput::SetFixedCLScreenOutput(CConfig *config){ + PrintingToolbox::CTablePrinter FixedCLSummary(&cout); + + if (fabs(historyOutput_Map["CL_DRIVER_COMMAND"].value) > 1e-16){ + FixedCLSummary.AddColumn("Fixed CL Mode", 40); + FixedCLSummary.AddColumn("Value", 30); + FixedCLSummary.SetAlign(PrintingToolbox::CTablePrinter::LEFT); + FixedCLSummary.PrintHeader(); + FixedCLSummary << "Current CL" << historyOutput_Map["LIFT"].value; + FixedCLSummary << "Target CL" << config->GetTarget_CL(); + FixedCLSummary << "Previous AOA" << historyOutput_Map["PREV_AOA"].value; + if (config->GetFinite_Difference_Mode()){ + FixedCLSummary << "Changed AoA by (Finite Difference step)" << historyOutput_Map["CL_DRIVER_COMMAND"].value; + lastInnerIter = curInnerIter - 1; + } + else + FixedCLSummary << "Changed AoA by" << historyOutput_Map["CL_DRIVER_COMMAND"].value; + FixedCLSummary.PrintFooter(); + SetScreen_Header(config); + } + + else if (config->GetFinite_Difference_Mode() && historyOutput_Map["AOA"].value == historyOutput_Map["PREV_AOA"].value){ + FixedCLSummary.AddColumn("Fixed CL Mode (Finite Difference)", 40); + FixedCLSummary.AddColumn("Value", 30); + FixedCLSummary.SetAlign(PrintingToolbox::CTablePrinter::LEFT); + FixedCLSummary.PrintHeader(); + FixedCLSummary << "Delta CL / Delta AoA" << config->GetdCL_dAlpha(); + FixedCLSummary << "Delta CD / Delta CL" << config->GetdCD_dCL(); + if (nDim == 3){ + FixedCLSummary << "Delta CMx / Delta CL" << config->GetdCMx_dCL(); + FixedCLSummary << "Delta CMy / Delta CL" << config->GetdCMy_dCL(); + } + FixedCLSummary << "Delta CMz / Delta CL" << config->GetdCMz_dCL(); + FixedCLSummary.PrintFooter(); + curInnerIter = lastInnerIter; + WriteMetaData(config); + curInnerIter = config->GetInnerIter(); + } +} + +bool CFlowCompOutput::WriteHistoryFile_Output(CConfig *config) { + return !config->GetFinite_Difference_Mode() && COutput::WriteHistoryFile_Output(config); +} diff --git a/SU2_CFD/src/output/CFlowOutput.cpp b/SU2_CFD/src/output/CFlowOutput.cpp index 7d9e36e7d237..8f740eaf4117 100644 --- a/SU2_CFD/src/output/CFlowOutput.cpp +++ b/SU2_CFD/src/output/CFlowOutput.cpp @@ -734,7 +734,7 @@ void CFlowOutput::AddAerodynamicCoefficients(CConfig *config){ /// END_GROUP /// DESCRIPTION: Angle of attack - AddHistoryOutput("AOA", "AoA", ScreenOutputFormat::SCIENTIFIC, "AOA", "Angle of attack"); + AddHistoryOutput("AOA", "AoA", ScreenOutputFormat::FIXED, "AOA", "Angle of attack"); } void CFlowOutput::SetAerodynamicCoefficients(CConfig *config, CSolver *flow_solver){ @@ -958,7 +958,7 @@ su2double CFlowOutput::GetQ_Criterion(su2double** VelocityGradient) const { void CFlowOutput::WriteAdditionalFiles(CConfig *config, CGeometry *geometry, CSolver **solver_container){ if (config->GetFixed_CL_Mode() || config->GetFixed_CM_Mode()){ - WriteMetaData(config, geometry); + WriteMetaData(config); } if (config->GetWrt_ForcesBreakdown()){ @@ -967,7 +967,7 @@ void CFlowOutput::WriteAdditionalFiles(CConfig *config, CGeometry *geometry, CSo } -void CFlowOutput::WriteMetaData(CConfig *config, CGeometry *geometry){ +void CFlowOutput::WriteMetaData(CConfig *config){ ofstream meta_file; @@ -985,13 +985,19 @@ void CFlowOutput::WriteMetaData(CConfig *config, CGeometry *geometry){ meta_file <<"ITER= " << curTimeIter + 1 << endl; else meta_file <<"ITER= " << curInnerIter + config->GetExtIter_OffSet() + 1 << endl; - meta_file <<"AOA= " << config->GetAoA() - config->GetAoA_Offset() << endl; - meta_file <<"SIDESLIP_ANGLE= " << config->GetAoS() - config->GetAoS_Offset() << endl; + + if (config->GetFixed_CL_Mode()){ + meta_file <<"AOA= " << config->GetAoA() - config->GetAoA_Offset() << endl; + meta_file <<"SIDESLIP_ANGLE= " << config->GetAoS() - config->GetAoS_Offset() << endl; + meta_file <<"DCD_DCL_VALUE= " << config->GetdCD_dCL() << endl; + if (nDim==3){ + meta_file <<"DCMX_DCL_VALUE= " << config->GetdCMx_dCL() << endl; + meta_file <<"DCMY_DCL_VALUE= " << config->GetdCMy_dCL() << endl; + } + meta_file <<"DCMZ_DCL_VALUE= " << config->GetdCMz_dCL() << endl; + } meta_file <<"INITIAL_BCTHRUST= " << config->GetInitial_BCThrust() << endl; - meta_file <<"DCD_DCL_VALUE= " << config->GetdCD_dCL() << endl; - meta_file <<"DCMX_DCL_VALUE= " << config->GetdCMx_dCL() << endl; - meta_file <<"DCMY_DCL_VALUE= " << config->GetdCMy_dCL() << endl; - meta_file <<"DCMZ_DCL_VALUE= " << config->GetdCMz_dCL() << endl; + if (( config->GetKind_Solver() == DISC_ADJ_EULER || config->GetKind_Solver() == DISC_ADJ_NAVIER_STOKES || @@ -2836,7 +2842,7 @@ void CFlowOutput::WriteForcesBreakdown(CConfig *config, CGeometry *geometry, CSo } -bool CFlowOutput::WriteVolume_Output(CConfig *config, unsigned long Iter){ +bool CFlowOutput::WriteVolume_Output(CConfig *config, unsigned long Iter, bool force_writing){ if (config->GetTime_Domain()){ if (((config->GetTime_Marching() == DT_STEPPING_1ST) || @@ -2852,10 +2858,11 @@ bool CFlowOutput::WriteVolume_Output(CConfig *config, unsigned long Iter){ return true; } } else { - return ((Iter > 0) && Iter % config->GetVolume_Wrt_Freq() == 0); + if (config->GetFixed_CL_Mode() && config->GetFinite_Difference_Mode()) return false; + return ((Iter > 0) && Iter % config->GetVolume_Wrt_Freq() == 0) || force_writing; } - return false; + return false || force_writing; } void CFlowOutput::SetTimeAveragedFields(){ diff --git a/SU2_CFD/src/output/COutput.cpp b/SU2_CFD/src/output/COutput.cpp index 8614c0999d11..f70f90a4de93 100644 --- a/SU2_CFD/src/output/COutput.cpp +++ b/SU2_CFD/src/output/COutput.cpp @@ -674,7 +674,7 @@ void COutput::WriteToFile(CConfig *config, CGeometry *geometry, unsigned short f bool COutput::SetResult_Files(CGeometry *geometry, CConfig *config, CSolver** solver_container, unsigned long iter, bool force_writing){ - bool writeFiles = WriteVolume_Output(config, iter) || force_writing; + bool writeFiles = WriteVolume_Output(config, iter, force_writing); /*--- Check if the data sorters are allocated, if not, allocate them. --- */ @@ -991,6 +991,7 @@ void COutput::SetScreen_Output(CConfig *config) { } (*convergenceTable) << out.str(); } + SetAdditionalScreenOutput(config); } void COutput::PreprocessHistoryOutput(CConfig *config, bool wrt){ @@ -1798,10 +1799,10 @@ bool COutput::WriteHistoryFile_Output(CConfig *config) { } -bool COutput::WriteVolume_Output(CConfig *config, unsigned long Iter){ - if (config->GetTime_Domain()) return ((Iter % config->GetVolume_Wrt_Freq() == 0)); +bool COutput::WriteVolume_Output(CConfig *config, unsigned long Iter, bool force_writing){ + if (config->GetTime_Domain()) return ((Iter % config->GetVolume_Wrt_Freq() == 0)) || force_writing; else { - return ((Iter > 0) && (Iter % config->GetVolume_Wrt_Freq() == 0)); + return ((Iter > 0) && (Iter % config->GetVolume_Wrt_Freq() == 0)) || force_writing; } } diff --git a/SU2_CFD/src/output/output_structure_legacy.cpp b/SU2_CFD/src/output/output_structure_legacy.cpp index 6f984688e9ab..050bec05079b 100644 --- a/SU2_CFD/src/output/output_structure_legacy.cpp +++ b/SU2_CFD/src/output/output_structure_legacy.cpp @@ -4620,6 +4620,7 @@ void COutputLegacy::SetConvHistory_Body(ofstream *ConvHist_file, bool disc_adj = config[val_iZone]->GetDiscrete_Adjoint(); bool energy = config[val_iZone]->GetEnergy_Equation(); bool incload = config[val_iZone]->GetIncrementalLoad(); + bool fixed_cl = config[val_iZone]->GetFixed_CL_Mode(); bool output_files = true; bool compressible = (config[val_iZone]->GetKind_Regime() == COMPRESSIBLE); @@ -4627,8 +4628,9 @@ void COutputLegacy::SetConvHistory_Body(ofstream *ConvHist_file, if (!disc_adj && !cont_adj && !DualTime_Iteration) { - if ((config[val_iZone]->GetFixed_CL_Mode()) && - (config[val_iZone]->GetnInner_Iter()-config[val_iZone]->GetIter_dCL_dAlpha() - 1 < iExtIter)) { + if (fixed_cl && + (solver_container[val_iZone][val_iInst][MESH_0][FLOW_SOL]->GetStart_AoA_FD()) && + (iExtIter != solver_container[val_iZone][val_iInst][MESH_0][FLOW_SOL]->GetIter_Update_AoA())) { output_files = false; } @@ -4638,10 +4640,11 @@ void COutputLegacy::SetConvHistory_Body(ofstream *ConvHist_file, /*--- We need to evaluate some of the objective functions to write the value on the history file ---*/ if (((iExtIter % (config[val_iZone]->GetWrt_Sol_Freq())) == 0) || - ((!config[val_iZone]->GetFixed_CL_Mode()) && (iExtIter == (config[val_iZone]->GetnInner_Iter()-1))) || + (!fixed_cl && (iExtIter == (config[val_iZone]->GetnInner_Iter()-1))) || /*--- If CL mode we need to compute the complete solution at two very particular iterations ---*/ - ((config[val_iZone]->GetFixed_CL_Mode()) && (iExtIter == (config[val_iZone]->GetnInner_Iter()-2))) || - ((config[val_iZone]->GetFixed_CL_Mode()) && (config[val_iZone]->GetnInner_Iter()-config[val_iZone]->GetIter_dCL_dAlpha() - 1 == iExtIter))) { + (fixed_cl && (iExtIter == (config[val_iZone]->GetnInner_Iter()-2) || + (solver_container[val_iZone][val_iInst][MESH_0][FLOW_SOL]->GetStart_AoA_FD() && + iExtIter == solver_container[val_iZone][val_iInst][MESH_0][FLOW_SOL]->GetIter_Update_AoA())))) { if ((rank == MASTER_NODE) && output_files) cout << endl << "------------------------ Evaluate Special Output ------------------------"; @@ -12422,7 +12425,9 @@ void COutputLegacy::SetResult_Files_Parallel(CSolver *****solver_container, /*--- Store the solution to be used on the final iteration with cte. lift mode. ---*/ if ((!cont_adj) && (!disc_adj) && (config[iZone]->GetFixed_CL_Mode()) && - (config[iZone]->GetnInner_Iter()-config[iZone]->GetIter_dCL_dAlpha() -1 == iExtIter)) { + (solver_container[iZone][iInst][MESH_0][FLOW_SOL]->GetStart_AoA_FD()) && + iExtIter == solver_container[iZone][iInst][MESH_0][FLOW_SOL]->GetIter_Update_AoA()) { + //(config[iZone]->GetnExtIter()-config[iZone]->GetIter_dCL_dAlpha() -1 == iExtIter)) { if (rank == MASTER_NODE) cout << "Storing solution output data locally on each rank (cte. CL mode)." << endl; @@ -12443,7 +12448,9 @@ void COutputLegacy::SetResult_Files_Parallel(CSolver *****solver_container, /*--- Recover the solution to be used on the final iteration with cte. lift mode. ---*/ if ((!cont_adj) && (!disc_adj) && (config[iZone]->GetFixed_CL_Mode()) && - (config[iZone]->GetnInner_Iter() - 1 == iExtIter) && (Local_Data_Copy != NULL)) { + (solver_container[iZone][iInst][MESH_0][FLOW_SOL]->GetEnd_AoA_FD()) && + //(iExtIter - solver_container[iZone][iInst][MESH_0][FLOW_SOL]->GetIter_Update_AoA() == config[iZone]->GetIter_dCL_dAlpha()) && + (Local_Data_Copy != NULL)) { if (rank == MASTER_NODE) cout << "Recovering solution output data locally on each rank (cte. CL mode)." << endl; diff --git a/SU2_CFD/src/solver_adjoint_mean.cpp b/SU2_CFD/src/solver_adjoint_mean.cpp index e1af84656d27..f9aeb308694a 100644 --- a/SU2_CFD/src/solver_adjoint_mean.cpp +++ b/SU2_CFD/src/solver_adjoint_mean.cpp @@ -2884,13 +2884,13 @@ void CAdjEulerSolver::Smooth_Sensitivity(CGeometry *geometry, CSolver **solver_c void CAdjEulerSolver::SetFarfield_AoA(CGeometry *geometry, CSolver **solver_container, CConfig *config, unsigned short iMesh, bool Output) { - unsigned long Iter_Fixed_CL = config->GetIter_Fixed_CL(); - unsigned long InnerIter = config->GetInnerIter(); + unsigned long Iter_Fixed_CL = config->GetUpdate_AoA_Iter_Limit(); + unsigned long InnerIter = config->GetInnerIter(); bool Update_AoA = false; su2double dCL_dAlpha = config->GetdCL_dAlpha()*180.0/PI_NUMBER; - unsigned long Update_Alpha = config->GetUpdate_Alpha(); + //unsigned long Update_Alpha = config->GetUpdate_Alpha(); - if (InnerIter == 0) AoA_Counter = 0; + //if (ExtIter == 0) AoA_Counter = 0; /*--- Only the fine mesh level should check the convergence criteria ---*/ @@ -2904,8 +2904,8 @@ void CAdjEulerSolver::SetFarfield_AoA(CGeometry *geometry, CSolver **solver_cont at a fix number of iterations ---*/ if ((InnerIter % Iter_Fixed_CL == 0) && (InnerIter != 0)) { - AoA_Counter++; - if ((AoA_Counter <= Update_Alpha)) Update_AoA = true; + //AoA_Counter++; + //if ((AoA_Counter <= Update_Alpha)) Update_AoA = true; Update_AoA = true; } diff --git a/SU2_CFD/src/solver_direct_mean.cpp b/SU2_CFD/src/solver_direct_mean.cpp index 21d126923825..a712e484036a 100644 --- a/SU2_CFD/src/solver_direct_mean.cpp +++ b/SU2_CFD/src/solver_direct_mean.cpp @@ -106,16 +106,12 @@ CEulerSolver::CEulerSolver(void) : CSolver() { Secondary = NULL; Secondary_i = NULL; Secondary_j = NULL; - /*--- Fixed CL mode initialization (cauchy criteria) ---*/ + /*--- Fixed CL mode initialization ---*/ - Cauchy_Value = 0; - Cauchy_Func = 0; - Old_Func = 0; - New_Func = 0; - Cauchy_Counter = 0; - Cauchy_Serie = NULL; - - AoA_FD_Change = false; + Start_AoA_FD = false; + End_AoA_FD = false; + Update_AoA = false; + Iter_Update_AoA = 0; FluidModel = NULL; @@ -223,7 +219,7 @@ CEulerSolver::CEulerSolver(CGeometry *geometry, CConfig *config, unsigned short /*--- Read and store the restart metadata. ---*/ - Read_SU2_Restart_Metadata(geometry, config, false, filename_); + Read_SU2_Restart_Metadata(geometry, config, adjoint, filename_); } @@ -291,16 +287,12 @@ CEulerSolver::CEulerSolver(CGeometry *geometry, CConfig *config, unsigned short Secondary=NULL; Secondary_i=NULL; Secondary_j=NULL; - /*--- Fixed CL mode initialization (cauchy criteria) ---*/ - - Cauchy_Value = 0; - Cauchy_Func = 0; - Old_Func = 0; - New_Func = 0; - Cauchy_Counter = 0; - Cauchy_Serie = NULL; + /*--- Fixed CL mode initialization ---*/ - AoA_FD_Change = false; + Start_AoA_FD = false; + End_AoA_FD = false; + Update_AoA = false; + Iter_Update_AoA = 0; FluidModel = NULL; @@ -1120,8 +1112,6 @@ CEulerSolver::~CEulerSolver(void) { delete [] YPlus; } - if (Cauchy_Serie != NULL) delete [] Cauchy_Serie; - if (FluidModel != NULL) delete FluidModel; if(AverageVelocity !=NULL){ @@ -7306,71 +7296,51 @@ void CEulerSolver::SetActDisk_BCThrust(CGeometry *geometry, CSolver **solver_con void CEulerSolver::SetFarfield_AoA(CGeometry *geometry, CSolver **solver_container, CConfig *config, unsigned short iMesh, bool Output) { - su2double Target_CL = 0.0, AoA = 0.0, Vel_Infty[3], AoA_inc = 0.0, Vel_Infty_Mag, Old_AoA, - dCL_dAlpha_, dCD_dCL_, dCMx_dCL_, dCMy_dCL_, dCMz_dCL_; - unsigned long Wrt_Con_Freq; + su2double AoA = 0.0, Vel_Infty[3], Vel_Infty_Mag; unsigned short iDim; - - unsigned long Iter_Fixed_CL = config->GetIter_Fixed_CL(); - unsigned long Update_Alpha = config->GetUpdate_Alpha(); - - unsigned long InnerIter = config->GetInnerIter(); - bool write_heads = ((InnerIter % Iter_Fixed_CL == 0) && (InnerIter != 0)); - su2double Beta = config->GetAoS()*PI_NUMBER/180.0; - su2double dCL_dAlpha = config->GetdCL_dAlpha()*180.0/PI_NUMBER; - bool Update_AoA = false; - - if (InnerIter == 0) AoA_Counter = 0; - - /*--- Only the fine mesh level should check the convergence criteria ---*/ - - if ((iMesh == MESH_0) && Output) { - - /*--- Initialize the update flag to false ---*/ - - Update_AoA = false; + unsigned long InnerIter = config->GetInnerIter(); + su2double Beta = config->GetAoS(); - /*--- Reevaluate Angle of Attack at a fixed number of iterations ---*/ - - if ((InnerIter % Iter_Fixed_CL == 0) && (InnerIter != 0)) { - AoA_Counter++; - if ((AoA_Counter <= Update_Alpha)) Update_AoA = true; - else Update_AoA = false; - } - - /*--- Store the update boolean for use on other mesh levels in the MG ---*/ - - config->SetUpdate_AoA(Update_AoA); - - } + /* --- Initialize values at first iteration --- */ - else { - Update_AoA = config->GetUpdate_AoA(); + if (InnerIter == 0) { + Total_CD_Prev = 0.0; + Total_CL_Prev = 0.0; + Total_CMx_Prev = 0.0; + Total_CMy_Prev = 0.0; + Total_CMz_Prev = 0.0; + AoA_Prev = config->GetAoA(); + dCL_dAlpha = config->GetdCL_dAlpha(); } - if (Update_AoA && Output) { - - /*--- Retrieve the specified target CL value. ---*/ - - Target_CL = config->GetTarget_CL(); - - /*--- Retrieve the old AoA (radians) ---*/ - - AoA_old = config->GetAoA()*PI_NUMBER/180.0; - - /*--- Estimate the increment in AoA based on dCL_dAlpha (radians) ---*/ - - AoA_inc = (1.0/dCL_dAlpha)*(Target_CL - Total_CL); + /*--- Retrieve the AoA (degrees) ---*/ - /*--- Compute a new value for AoA on the fine mesh only (radians)---*/ + AoA = config->GetAoA(); + + /* --- Set new AoA if needed --- */ + + if (fabs(AoA_inc) > 0.0 && Output) { - if (iMesh == MESH_0) AoA = AoA_old + AoA_inc; - else { AoA = config->GetAoA()*PI_NUMBER/180.0; } + /* --- Update *_Prev values with current coefficients --- */ + + SetCoefficient_Gradients(config); + Total_CD_Prev = Total_CD; + Total_CL_Prev = Total_CL; + Total_CMx_Prev = Total_CMx; + Total_CMy_Prev = Total_CMy; + Total_CMz_Prev = Total_CMz; + AoA_Prev = AoA; + + /*--- Compute a new value for AoA on the fine mesh only (degrees)---*/ + + if (iMesh == MESH_0) AoA = AoA + AoA_inc; + else { AoA = config->GetAoA(); } + /*--- Only the fine mesh stores the updated values for AoA in config ---*/ - + if (iMesh == MESH_0) { - config->SetAoA(AoA*180.0/PI_NUMBER); + config->SetAoA(AoA); } /*--- Update the freestream velocity vector at the farfield ---*/ @@ -7388,13 +7358,13 @@ void CEulerSolver::SetFarfield_AoA(CGeometry *geometry, CSolver **solver_contain /*--- Compute the new freestream velocity with the updated AoA ---*/ if (nDim == 2) { - Vel_Infty[0] = cos(AoA)*Vel_Infty_Mag; - Vel_Infty[1] = sin(AoA)*Vel_Infty_Mag; + Vel_Infty[0] = cos(AoA*PI_NUMBER/180.0)*Vel_Infty_Mag; + Vel_Infty[1] = sin(AoA*PI_NUMBER/180.0)*Vel_Infty_Mag; } if (nDim == 3) { - Vel_Infty[0] = cos(AoA)*cos(Beta)*Vel_Infty_Mag; + Vel_Infty[0] = cos(AoA*PI_NUMBER/180.0)*cos(Beta*PI_NUMBER/180.0)*Vel_Infty_Mag; Vel_Infty[1] = sin(Beta)*Vel_Infty_Mag; - Vel_Infty[2] = sin(AoA)*cos(Beta)*Vel_Infty_Mag; + Vel_Infty[2] = sin(AoA*PI_NUMBER/180.0)*cos(Beta*PI_NUMBER/180.0)*Vel_Infty_Mag; } /*--- Store the new freestream velocity vector for the next iteration ---*/ @@ -7409,140 +7379,134 @@ void CEulerSolver::SetFarfield_AoA(CGeometry *geometry, CSolver **solver_contain for (iDim = 0; iDim < nDim; iDim++) config->SetVelocity_FreeStreamND(Vel_Infty[iDim], iDim); } - - /*--- Output some information to the console with the headers ---*/ - - if ((rank == MASTER_NODE) && (iMesh == MESH_0) && write_heads && !config->GetDiscrete_Adjoint()) { - Old_AoA = config->GetAoA() - AoA_inc*(180.0/PI_NUMBER); - - cout.precision(7); - cout.setf(ios::fixed, ios::floatfield); - cout << endl << "----------------------------- Fixed CL Mode -----------------------------" << endl; - cout << "CL: " << Total_CL; - cout << " (target: " << config->GetTarget_CL() <<")." << endl; - cout.precision(4); - cout << "Previous AoA: " << Old_AoA << " deg"; - cout << ", new AoA: " << config->GetAoA() << " deg." << endl; - cout << "-------------------------------------------------------------------------" << endl << endl; - } } +} - unsigned long Iter_dCL_dAlpha = config->GetIter_dCL_dAlpha(); - - if ((config->GetnInner_Iter()-Iter_dCL_dAlpha == InnerIter) && Output) { +bool CEulerSolver::FixedCL_Convergence(CConfig* config, bool convergence) { + su2double Target_CL = config->GetTarget_CL(); + unsigned long curr_iter = config->GetInnerIter(); + unsigned long Iter_dCL_dAlpha = config->GetIter_dCL_dAlpha(); + bool fixed_cl_conv = false; + AoA_inc = 0.0; - AoA_old = config->GetAoA(); - if (config->GetnInner_Iter()-Iter_dCL_dAlpha == InnerIter) { - Wrt_Con_Freq = SU2_TYPE::Int(su2double(config->GetIter_dCL_dAlpha())/10.0); - config->SetWrt_Con_Freq(Wrt_Con_Freq); - Total_CD_Prev = Total_CD; - Total_CL_Prev = Total_CL; - Total_CMx_Prev = Total_CMx; - Total_CMy_Prev = Total_CMy; - Total_CMz_Prev = Total_CMz; - AoA_inc = 0.001; - AoA_FD_Change = true; - } - - if ((rank == MASTER_NODE) && (iMesh == MESH_0)) { - - if (config->GetnInner_Iter()-Iter_dCL_dAlpha == InnerIter) { - cout << endl << "----------------------------- Fixed CL Mode -----------------------------" << endl; - cout << " Change AoA by +0.001 deg to evaluate gradient." << endl; - cout << "-------------------------------------------------------------------------" << endl << endl; - } + /*--- if in Fixed CL mode, before finite differencing --- */ - } + if (!Start_AoA_FD){ + if (convergence){ - /*--- Compute a new value for AoA on the fine mesh only (radians)---*/ + /* --- C_L and solution are converged, start finite differencing --- */ - if (iMesh == MESH_0) AoA = AoA_old + AoA_inc; - else { AoA = config->GetAoA(); } + if (fabs(Total_CL-Target_CL) < (config->GetCauchy_Eps()/2)) { - /*--- Only the fine mesh stores the updated values for AoA in config ---*/ + /* --- If no finite differencing required --- */ - if (iMesh == MESH_0) { config->SetAoA(AoA); } - - /*--- Update the freestream velocity vector at the farfield ---*/ - - for (iDim = 0; iDim < nDim; iDim++) - Vel_Infty[iDim] = GetVelocity_Inf(iDim); - - /*--- Compute the magnitude of the free stream velocity ---*/ + if (Iter_dCL_dAlpha == 0){ + fixed_cl_conv = true; + return fixed_cl_conv; + } - Vel_Infty_Mag = 0.0; - for (iDim = 0; iDim < nDim; iDim++) - Vel_Infty_Mag += Vel_Infty[iDim]*Vel_Infty[iDim]; - Vel_Infty_Mag = sqrt(Vel_Infty_Mag); + /* --- Else, set up finite differencing routine ---*/ + + Iter_Update_AoA = curr_iter; + Start_AoA_FD = true; + fixed_cl_conv = false; + AoA_inc = 0.001; + } - /*--- Compute the new freestream velocity with the updated AoA ---*/ + /* --- C_L is not converged to target value and some iterations + have passed since last update, so update AoA --- */ - if (nDim == 2) { - Vel_Infty[0] = cos(AoA*PI_NUMBER/180.0)*Vel_Infty_Mag; - Vel_Infty[1] = sin(AoA*PI_NUMBER/180.0)*Vel_Infty_Mag; - } - if (nDim == 3) { - Vel_Infty[0] = cos(AoA*PI_NUMBER/180.0)*cos(Beta)*Vel_Infty_Mag; - Vel_Infty[1] = sin(Beta)*Vel_Infty_Mag; - Vel_Infty[2] = sin(AoA*PI_NUMBER/180.0)*cos(Beta)*Vel_Infty_Mag; + else if ((curr_iter - Iter_Update_AoA) > config->GetStartConv_Iter()){ + Iter_Update_AoA = curr_iter; + fixed_cl_conv = false; + if (fabs(Total_CL-Target_CL) > (config->GetCauchy_Eps()/2)) { + AoA_inc = (1.0/dCL_dAlpha)*(Target_CL - Total_CL); + } + } } - /*--- Store the new freestream velocity vector for the next iteration ---*/ + /* --- If the iteration limit between AoA updates is met, so update AoA --- */ - for (iDim = 0; iDim < nDim; iDim++) { - Velocity_Inf[iDim] = Vel_Infty[iDim]; + else if ((curr_iter - Iter_Update_AoA) == config->GetUpdate_AoA_Iter_Limit()) { + Iter_Update_AoA = curr_iter; + fixed_cl_conv = false; + if (fabs(Total_CL-Target_CL) > (config->GetCauchy_Eps()/2)) { + AoA_inc = (1.0/dCL_dAlpha)*(Target_CL - Total_CL); + } } - /*--- Only the fine mesh stores the updated values for velocity in config ---*/ + /* --- If the total iteration limit is reached, start finite differencing --- */ - if (iMesh == MESH_0) { - for (iDim = 0; iDim < nDim; iDim++) - config->SetVelocity_FreeStreamND(Vel_Infty[iDim], iDim); + if (curr_iter == config->GetnInner_Iter() - Iter_dCL_dAlpha){ + if (Iter_dCL_dAlpha == 0){ + End_AoA_FD = true; + } + Iter_Update_AoA = curr_iter; + Start_AoA_FD = true; + fixed_cl_conv = false; + AoA_inc = 0.001; } + } + /* --- If Finite Difference Mode has ended, end simulation --- */ + + if (End_AoA_FD){ + //fixed_cl_conv = true; + return true; } - if (AoA_FD_Change && (config->GetnInner_Iter()-1 == InnerIter) && Output && (iMesh == MESH_0) && !config->GetDiscrete_Adjoint()) { - - /*--- Update angle of attack ---*/ + /* --- If starting Finite Difference Mode --- */ - AoA_old = config->GetAoA(); - AoA = AoA_old - 0.001; - config->SetAoA(AoA); + if (Start_AoA_FD){ - /*--- Use finite differences to compute ---*/ + /* --- Disable history writing --- */ - dCL_dAlpha_ = (Total_CL-Total_CL_Prev)/0.001; - dCD_dCL_ = (Total_CD-Total_CD_Prev)/(Total_CL-Total_CL_Prev); - dCMx_dCL_ = (Total_CMx-Total_CMx_Prev)/(Total_CL-Total_CL_Prev); - dCMy_dCL_ = (Total_CMy-Total_CMy_Prev)/(Total_CL-Total_CL_Prev); - dCMz_dCL_ = (Total_CMz-Total_CMz_Prev)/(Total_CL-Total_CL_Prev); + config->SetHistory_Wrt_Freq(2, 0); + + /* --- End Finite Difference Mode if iteration limit is reached, so simualtion is converged --- */ - /*--- Set the value of the dOF/dCL in the config file ---*/ + End_AoA_FD = ((curr_iter - Iter_Update_AoA - 2) == Iter_dCL_dAlpha || + curr_iter == config->GetnInner_Iter()- 2 ); - config->SetdCD_dCL(dCD_dCL_); - config->SetdCMx_dCL(dCMx_dCL_); - config->SetdCMy_dCL(dCMy_dCL_); - config->SetdCMz_dCL(dCMz_dCL_); + if (convergence && (curr_iter - Iter_Update_AoA) > config->GetStartConv_Iter()) + End_AoA_FD = true; - config->SetdCL_dAlpha(dCL_dAlpha_); + + /* --- If Finite Difference mode is ending, reset AoA and calculate Coefficient Gradients --- */ - if (rank == MASTER_NODE) { - cout << endl << "----------------------------- Fixed CL Mode -----------------------------" << endl; - cout << "Approx. Delta CL / Delta AoA: " << dCL_dAlpha_ << " (1/deg)." << endl; - cout << "Approx. Delta CD / Delta CL: " << dCD_dCL_ << ". " << endl; - if (nDim == 3 ) { - cout << "Approx. Delta CMx / Delta CL: " << dCMx_dCL_ << ". " << endl; - cout << "Approx. Delta CMy / Delta CL: " << dCMy_dCL_ << ". " << endl; - } - cout << "Approx. Delta CMz / Delta CL: " << dCMz_dCL_ << ". " << endl; - cout << "-------------------------------------------------------------------------" << endl << endl; + if (End_AoA_FD){ + SetCoefficient_Gradients(config); + config->SetAoA(AoA_Prev); } - } + return fixed_cl_conv; + +} + +void CEulerSolver::SetCoefficient_Gradients(CConfig *config){ + su2double dCL_dAlpha_, dCD_dCL_, dCMx_dCL_, dCMy_dCL_, dCMz_dCL_; + su2double AoA = config->GetAoA(); + + if (AoA != AoA_Prev) { + /* --- Calculate gradients of coefficients w.r.t. CL --- */ + + dCL_dAlpha_ = (Total_CL-Total_CL_Prev)/(AoA - AoA_Prev); + dCD_dCL_ = (Total_CD-Total_CD_Prev)/(Total_CL-Total_CL_Prev); + dCMx_dCL_ = (Total_CMx-Total_CMx_Prev)/(Total_CL-Total_CL_Prev); + dCMy_dCL_ = (Total_CMy-Total_CMy_Prev)/(Total_CL-Total_CL_Prev); + dCMz_dCL_ = (Total_CMz-Total_CMz_Prev)/(Total_CL-Total_CL_Prev); + + /*--- Set the value of the dOF/dCL in the config file ---*/ + + config->SetdCD_dCL(dCD_dCL_); + config->SetdCMx_dCL(dCMx_dCL_); + config->SetdCMy_dCL(dCMy_dCL_); + config->SetdCMz_dCL(dCMz_dCL_); + config->SetdCL_dAlpha(dCL_dAlpha_); + } } void CEulerSolver::SetInletAtVertex(su2double *val_inlet, @@ -14021,7 +13985,7 @@ CNSSolver::CNSSolver(CGeometry *geometry, CConfig *config, unsigned short iMesh) /*--- Read and store the restart metadata. ---*/ - Read_SU2_Restart_Metadata(geometry, config, false, filename_); + Read_SU2_Restart_Metadata(geometry, config, adjoint, filename_); } @@ -14043,7 +14007,7 @@ CNSSolver::CNSSolver(CGeometry *geometry, CConfig *config, unsigned short iMesh) CMerit_Visc = NULL; CT_Visc = NULL; CQ_Visc = NULL; MaxHF_Visc = NULL; ForceViscous = NULL; MomentViscous = NULL; - CSkinFriction = NULL; Cauchy_Serie = NULL; HF_Visc = NULL; + CSkinFriction = NULL; HF_Visc = NULL; HeatConjugateVar = NULL; /*--- Initialize quantities for the average process for internal flow ---*/ @@ -14556,15 +14520,15 @@ CNSSolver::CNSSolver(CGeometry *geometry, CConfig *config, unsigned short iMesh) Total_CD = 0.0; Total_CL = 0.0; Total_CSF = 0.0; Total_CMx = 0.0; Total_CMy = 0.0; Total_CMz = 0.0; - Total_CoPx = 0.0; Total_CoPy = 0.0; Total_CoPz = 0.0; + Total_CoPx = 0.0; Total_CoPy = 0.0; Total_CoPz = 0.0; Total_CEff = 0.0; Total_CEquivArea = 0.0; Total_CNearFieldOF = 0.0; Total_CFx = 0.0; Total_CFy = 0.0; Total_CFz = 0.0; Total_CT = 0.0; Total_CQ = 0.0; Total_CMerit = 0.0; Total_MaxHeat = 0.0; Total_Heat = 0.0; Total_ComboObj = 0.0; Total_CpDiff = 0.0; Total_HeatFluxDiff = 0.0; - Total_NetThrust = 0.0; Total_CL_Prev = 0.0; - Total_Power = 0.0; AoA_Prev = 0.0; Total_CD_Prev = 0.0; - Total_CMx_Prev = 0.0; Total_CMy_Prev = 0.0; Total_CMz_Prev = 0.0; + Total_NetThrust = 0.0; Total_Power = 0.0; + Total_CL_Prev = 0.0; Total_CD_Prev = 0.0; Total_CMx_Prev = 0.0; + Total_CMy_Prev = 0.0; Total_CMz_Prev = 0.0; Total_AeroCD = 0.0; Total_SolidCD = 0.0; Total_IDR = 0.0; Total_IDC = 0.0; Total_Custom_ObjFunc = 0.0; diff --git a/SU2_CFD/src/solver_direct_mean_fem.cpp b/SU2_CFD/src/solver_direct_mean_fem.cpp index 2c06eee59ea2..38a04ae1550e 100644 --- a/SU2_CFD/src/solver_direct_mean_fem.cpp +++ b/SU2_CFD/src/solver_direct_mean_fem.cpp @@ -53,8 +53,6 @@ CFEM_DG_EulerSolver::CFEM_DG_EulerSolver(void) : CSolver() { Surface_CFx = NULL; Surface_CFy = NULL; Surface_CFz = NULL; Surface_CMx = NULL; Surface_CMy = NULL; Surface_CMz = NULL; - Cauchy_Serie = NULL; - /*--- Initialization of the boolean symmetrizingTermsPresent. ---*/ symmetrizingTermsPresent = true; @@ -89,8 +87,6 @@ CFEM_DG_EulerSolver::CFEM_DG_EulerSolver(CConfig *config, unsigned short val_nDi Surface_CFx = NULL; Surface_CFy = NULL; Surface_CFz = NULL; Surface_CMx = NULL; Surface_CMy = NULL; Surface_CMz = NULL; - Cauchy_Serie = NULL; - /*--- Store the multigrid level. ---*/ MGLevel = iMesh; @@ -135,8 +131,6 @@ CFEM_DG_EulerSolver::CFEM_DG_EulerSolver(CGeometry *geometry, CConfig *config, u Surface_CFx = NULL; Surface_CFy = NULL; Surface_CFz = NULL; Surface_CMx = NULL; Surface_CMy = NULL; Surface_CMz = NULL; - Cauchy_Serie = NULL; - /*--- Store the multigrid level. ---*/ MGLevel = iMesh; @@ -774,7 +768,6 @@ CFEM_DG_EulerSolver::~CFEM_DG_EulerSolver(void) { if (Surface_CMz != NULL) delete [] Surface_CMz; if (CEff_Inv != NULL) delete [] CEff_Inv; - if (Cauchy_Serie != NULL) delete [] Cauchy_Serie; } void CFEM_DG_EulerSolver::SetNondimensionalization(CConfig *config, @@ -9555,8 +9548,6 @@ CFEM_DG_NSSolver::CFEM_DG_NSSolver(CGeometry *geometry, CConfig *config, unsigne Surface_CMx_Visc = NULL; Surface_CMy_Visc = NULL; Surface_CMz_Visc = NULL; MaxHeatFlux_Visc = NULL; Heat_Visc = NULL; - Cauchy_Serie = NULL; - /*--- Initialize the solution and right hand side vectors for storing the residuals and updating the solution (always needed even for explicit schemes). ---*/ @@ -9672,8 +9663,6 @@ CFEM_DG_NSSolver::~CFEM_DG_NSSolver(void) { if (Heat_Visc != NULL) delete [] Heat_Visc; if (MaxHeatFlux_Visc != NULL) delete [] MaxHeatFlux_Visc; - if (Cauchy_Serie != NULL) delete [] Cauchy_Serie; - if( SGSModel ) delete SGSModel; } diff --git a/SU2_CFD/src/solver_direct_mean_inc.cpp b/SU2_CFD/src/solver_direct_mean_inc.cpp index 773bd1957c4f..1ea438ddc3a0 100644 --- a/SU2_CFD/src/solver_direct_mean_inc.cpp +++ b/SU2_CFD/src/solver_direct_mean_inc.cpp @@ -84,15 +84,6 @@ CIncEulerSolver::CIncEulerSolver(void) : CSolver() { Smatrix = NULL; Cvector = NULL; Preconditioner = NULL; - /*--- Fixed CL mode initialization (cauchy criteria) ---*/ - - Cauchy_Value = 0; - Cauchy_Func = 0; - Old_Func = 0; - New_Func = 0; - Cauchy_Counter = 0; - Cauchy_Serie = NULL; - FluidModel = NULL; SlidingState = NULL; @@ -202,15 +193,6 @@ CIncEulerSolver::CIncEulerSolver(CGeometry *geometry, CConfig *config, unsigned Smatrix = NULL; Cvector = NULL; Preconditioner = NULL; - /*--- Fixed CL mode initialization (cauchy criteria) ---*/ - - Cauchy_Value = 0; - Cauchy_Func = 0; - Old_Func = 0; - New_Func = 0; - Cauchy_Counter = 0; - Cauchy_Serie = NULL; - /*--- Fluid model pointer initialization ---*/ FluidModel = NULL; @@ -497,10 +479,7 @@ CIncEulerSolver::CIncEulerSolver(CGeometry *geometry, CConfig *config, unsigned Total_CT = 0.0; Total_CQ = 0.0; Total_CMerit = 0.0; Total_MaxHeat = 0.0; Total_Heat = 0.0; Total_ComboObj = 0.0; Total_CpDiff = 0.0; Total_HeatFluxDiff = 0.0; Total_Custom_ObjFunc = 0.0; - AoA_Prev = 0.0; - Total_CL_Prev = 0.0; Total_CD_Prev = 0.0; - Total_CMx_Prev = 0.0; Total_CMy_Prev = 0.0; Total_CMz_Prev = 0.0; - + /*--- Read farfield conditions ---*/ Density_Inf = config->GetDensity_FreeStreamND(); @@ -568,11 +547,6 @@ CIncEulerSolver::CIncEulerSolver(CGeometry *geometry, CConfig *config, unsigned } - /*--- Initialize the cauchy critera array for fixed CL mode ---*/ - - if (config->GetFixed_CL_Mode()) - Cauchy_Serie = new su2double [config->GetCauchy_Elems()+1]; - /*--- Initialize the solution to the far-field state everywhere. ---*/ nodes = new CIncEulerVariable(Pressure_Inf, Velocity_Inf, Temperature_Inf, nPoint, nDim, nVar, config); @@ -807,8 +781,6 @@ CIncEulerSolver::~CIncEulerSolver(void) { delete [] YPlus; } - if (Cauchy_Serie != NULL) delete [] Cauchy_Serie; - if (FluidModel != NULL) delete FluidModel; if (nodes != nullptr) delete nodes; @@ -1540,14 +1512,9 @@ void CIncEulerSolver::Preprocessing(CGeometry *geometry, CSolver **solver_contai bool limiter = (config->GetKind_SlopeLimit_Flow() != NO_LIMITER) && (InnerIter <= config->GetLimiterIter()); bool center = ((config->GetKind_ConvNumScheme_Flow() == SPACE_CENTERED) || (cont_adjoint && config->GetKind_ConvNumScheme_AdjFlow() == SPACE_CENTERED)); bool center_jst = center && (config->GetKind_Centered_Flow() == JST); - bool fixed_cl = config->GetFixed_CL_Mode(); bool van_albada = config->GetKind_SlopeLimit_Flow() == VAN_ALBADA_EDGE; bool outlet = ((config->GetnMarker_Outlet() != 0)); - /*--- Update the angle of attack at the far-field for fixed CL calculations (only direct problem). ---*/ - - if ((fixed_cl) && (!disc_adjoint) && (!cont_adjoint)) { SetFarfield_AoA(geometry, solver_container, config, iMesh, Output); } - /*--- Set the primitive variables ---*/ ErrorCounter = SetPrimitive_Variables(solver_container, config, Output); @@ -4103,132 +4070,6 @@ void CIncEulerSolver::SetPrimitive_Limiter(CGeometry *geometry, CConfig *config) #endif } -void CIncEulerSolver::SetFarfield_AoA(CGeometry *geometry, CSolver **solver_container, - CConfig *config, unsigned short iMesh, bool Output) { - - su2double Target_CL = 0.0, AoA = 0.0, Vel_Infty[3] = {0.0,0.0,0.0}, - AoA_inc = 0.0, Vel_Infty_Mag, Old_AoA; - - unsigned short iDim; - - unsigned long Iter_Fixed_CL = config->GetIter_Fixed_CL(); - unsigned long Update_Alpha = config->GetUpdate_Alpha(); - - unsigned long InnerIter = config->GetInnerIter(); - bool write_heads = ((InnerIter % Iter_Fixed_CL == 0) && (InnerIter != 0)); - su2double Beta = config->GetAoS()*PI_NUMBER/180.0; - su2double dCL_dAlpha = config->GetdCL_dAlpha()*180.0/PI_NUMBER; - bool Update_AoA = false; - - if (InnerIter == 0) AoA_Counter = 0; - - /*--- Only the fine mesh level should check the convergence criteria ---*/ - - if ((iMesh == MESH_0) && Output) { - - /*--- Initialize the update flag to false ---*/ - - Update_AoA = false; - - /*--- Reevaluate Angle of Attack at a fixed number of iterations ---*/ - - if ((InnerIter % Iter_Fixed_CL == 0) && (InnerIter != 0)) { - AoA_Counter++; - if ((AoA_Counter <= Update_Alpha)) Update_AoA = true; - Update_AoA = true; - } - - /*--- Store the update boolean for use on other mesh levels in the MG ---*/ - - config->SetUpdate_AoA(Update_AoA); - - } else { - Update_AoA = config->GetUpdate_AoA(); - } - - if (Update_AoA && Output) { - - /*--- Retrieve the specified target CL value. ---*/ - - Target_CL = config->GetTarget_CL(); - - /*--- Retrieve the old AoA (radians) ---*/ - - AoA_old = config->GetAoA()*PI_NUMBER/180.0; - - /*--- Estimate the increment in AoA based on dCL_dAlpha (radians) ---*/ - - AoA_inc = (1.0/dCL_dAlpha)*(Target_CL - Total_CL); - - /*--- Compute a new value for AoA on the fine mesh only (radians)---*/ - - if (iMesh == MESH_0) AoA = AoA_old + AoA_inc; - else { AoA = config->GetAoA()*PI_NUMBER/180.0; } - - /*--- Only the fine mesh stores the updated values for AoA in config ---*/ - - if (iMesh == MESH_0) { - config->SetAoA(AoA*180.0/PI_NUMBER); - } - - /*--- Update the freestream velocity vector at the farfield ---*/ - - for (iDim = 0; iDim < nDim; iDim++) - Vel_Infty[iDim] = GetVelocity_Inf(iDim); - - /*--- Compute the magnitude of the free stream velocity ---*/ - - Vel_Infty_Mag = 0; - for (iDim = 0; iDim < nDim; iDim++) - Vel_Infty_Mag += Vel_Infty[iDim]*Vel_Infty[iDim]; - Vel_Infty_Mag = sqrt(Vel_Infty_Mag); - - /*--- Compute the new freestream velocity with the updated AoA ---*/ - - if (nDim == 2) { - Vel_Infty[0] = cos(AoA)*Vel_Infty_Mag; - Vel_Infty[1] = sin(AoA)*Vel_Infty_Mag; - } - if (nDim == 3) { - Vel_Infty[0] = cos(AoA)*cos(Beta)*Vel_Infty_Mag; - Vel_Infty[1] = sin(Beta)*Vel_Infty_Mag; - Vel_Infty[2] = sin(AoA)*cos(Beta)*Vel_Infty_Mag; - } - - /*--- Store the new freestream velocity vector for the next iteration ---*/ - - for (iDim = 0; iDim < nDim; iDim++) { - Velocity_Inf[iDim] = Vel_Infty[iDim]; - } - - /*--- Only the fine mesh stores the updated values for velocity in config ---*/ - - if (iMesh == MESH_0) { - for (iDim = 0; iDim < nDim; iDim++) - config->SetVelocity_FreeStreamND(Vel_Infty[iDim], iDim); - } - - /*--- Output some information to the console with the headers ---*/ - - if ((rank == MASTER_NODE) && (iMesh == MESH_0) && write_heads && !config->GetDiscrete_Adjoint()) { - Old_AoA = config->GetAoA() - AoA_inc*(180.0/PI_NUMBER); - - cout.precision(7); - cout.setf(ios::fixed, ios::floatfield); - cout << endl << "----------------------------- Fixed CL Mode -----------------------------" << endl; - cout << "CL: " << Total_CL; - cout << " (target: " << config->GetTarget_CL() <<")." << endl; - cout.precision(4); - cout << "Previous AoA: " << Old_AoA << " deg"; - cout << ", new AoA: " << config->GetAoA() << " deg." << endl; - - cout << "-------------------------------------------------------------------------" << endl << endl; - } - - } - -} - void CIncEulerSolver::SetInletAtVertex(su2double *val_inlet, unsigned short iMarker, unsigned long iVertex) { @@ -4389,8 +4230,6 @@ void CIncEulerSolver::Evaluate_ObjFunc(CConfig *config) { switch(Kind_ObjFunc) { case DRAG_COEFFICIENT: Total_ComboObj+=Weight_ObjFunc*(Surface_CD[iMarker_Monitoring]); - if (config->GetFixed_CL_Mode()) Total_ComboObj -= Weight_ObjFunc*config->GetdCD_dCL()*(Surface_CL[iMarker_Monitoring]); - if (config->GetFixed_CM_Mode()) Total_ComboObj -= Weight_ObjFunc*config->GetdCD_dCMy()*(Surface_CMy[iMarker_Monitoring]); break; case LIFT_COEFFICIENT: Total_ComboObj+=Weight_ObjFunc*(Surface_CL[iMarker_Monitoring]); @@ -4403,15 +4242,12 @@ void CIncEulerSolver::Evaluate_ObjFunc(CConfig *config) { break; case MOMENT_X_COEFFICIENT: Total_ComboObj+=Weight_ObjFunc*(Surface_CMx[iMarker_Monitoring]); - if (config->GetFixed_CL_Mode()) Total_ComboObj -= Weight_ObjFunc*config->GetdCMx_dCL()*(Surface_CL[iMarker_Monitoring]); break; case MOMENT_Y_COEFFICIENT: Total_ComboObj+=Weight_ObjFunc*(Surface_CMy[iMarker_Monitoring]); - if (config->GetFixed_CL_Mode()) Total_ComboObj -= Weight_ObjFunc*config->GetdCMy_dCL()*(Surface_CL[iMarker_Monitoring]); break; case MOMENT_Z_COEFFICIENT: Total_ComboObj+=Weight_ObjFunc*(Surface_CMz[iMarker_Monitoring]); - if (config->GetFixed_CL_Mode()) Total_ComboObj -= Weight_ObjFunc*config->GetdCMz_dCL()*(Surface_CL[iMarker_Monitoring]); break; case FORCE_X_COEFFICIENT: Total_ComboObj+=Weight_ObjFunc*Surface_CFx[iMarker_Monitoring]; @@ -6766,7 +6602,7 @@ CIncNSSolver::CIncNSSolver(CGeometry *geometry, CConfig *config, unsigned short CMerit_Visc = NULL; CT_Visc = NULL; CQ_Visc = NULL; MaxHF_Visc = NULL; ForceViscous = NULL; MomentViscous = NULL; - CSkinFriction = NULL; Cauchy_Serie = NULL; HF_Visc = NULL; + CSkinFriction = NULL; HF_Visc = NULL; /*--- Set the gamma value ---*/ @@ -7143,16 +6979,7 @@ CIncNSSolver::CIncNSSolver(CGeometry *geometry, CConfig *config, unsigned short Total_CT = 0.0; Total_CQ = 0.0; Total_CMerit = 0.0; Total_MaxHeat = 0.0; Total_Heat = 0.0; Total_ComboObj = 0.0; Total_CpDiff = 0.0; Total_HeatFluxDiff = 0.0; Total_Custom_ObjFunc = 0.0; - AoA_Prev = 0.0; - Total_CL_Prev = 0.0; Total_CD_Prev = 0.0; - Total_CMx_Prev = 0.0; Total_CMy_Prev = 0.0; Total_CMz_Prev = 0.0; - - /*--- Coefficients for fixed lift mode. ---*/ - AoA_Prev = 0.0; - Total_CL_Prev = 0.0; Total_CD_Prev = 0.0; - Total_CMx_Prev = 0.0; Total_CMy_Prev = 0.0; Total_CMz_Prev = 0.0; - /*--- Read farfield conditions from config ---*/ Density_Inf = config->GetDensity_FreeStreamND(); @@ -7225,11 +7052,6 @@ CIncNSSolver::CIncNSSolver(CGeometry *geometry, CConfig *config, unsigned short } - /*--- Initialize the cauchy critera array for fixed CL mode ---*/ - - if (config->GetFixed_CL_Mode()) - Cauchy_Serie = new su2double [config->GetCauchy_Elems()+1]; - /*--- Initialize the solution to the far-field state everywhere. ---*/ nodes = new CIncNSVariable(Pressure_Inf, Velocity_Inf, Temperature_Inf, nPoint, nDim, nVar, config); @@ -7323,8 +7145,6 @@ CIncNSSolver::~CIncNSSolver(void) { if (Surface_HF_Visc != NULL) delete [] Surface_HF_Visc; if (Surface_MaxHF_Visc != NULL) delete [] Surface_MaxHF_Visc; - if (Cauchy_Serie != NULL) delete [] Cauchy_Serie; - if (CSkinFriction != NULL) { for (iMarker = 0; iMarker < nMarker; iMarker++) { for (iDim = 0; iDim < nDim; iDim++) { @@ -7361,14 +7181,9 @@ void CIncNSSolver::Preprocessing(CGeometry *geometry, CSolver **solver_container bool limiter_flow = (config->GetKind_SlopeLimit_Flow() != NO_LIMITER) && (InnerIter <= config->GetLimiterIter()); bool limiter_turb = (config->GetKind_SlopeLimit_Turb() != NO_LIMITER) && (InnerIter <= config->GetLimiterIter()); bool limiter_adjflow = (cont_adjoint && (config->GetKind_SlopeLimit_AdjFlow() != NO_LIMITER) && (InnerIter <= config->GetLimiterIter())); - bool fixed_cl = config->GetFixed_CL_Mode(); bool van_albada = config->GetKind_SlopeLimit_Flow() == VAN_ALBADA_EDGE; bool outlet = ((config->GetnMarker_Outlet() != 0)); - /*--- Update the angle of attack at the far-field for fixed CL calculations (only direct problem). ---*/ - - if ((fixed_cl) && (!disc_adjoint) && (!cont_adjoint)) { SetFarfield_AoA(geometry, solver_container, config, iMesh, Output); } - /*--- Set the primitive variables ---*/ ErrorCounter = SetPrimitive_Variables(solver_container, config, Output); diff --git a/SU2_CFD/src/solver_structure.cpp b/SU2_CFD/src/solver_structure.cpp index 464ff29ec7ed..3778a21ff255 100644 --- a/SU2_CFD/src/solver_structure.cpp +++ b/SU2_CFD/src/solver_structure.cpp @@ -4526,19 +4526,18 @@ void CSolver::Read_SU2_Restart_Binary(CGeometry *geometry, CConfig *config, stri } -void CSolver::Read_SU2_Restart_Metadata(CGeometry *geometry, CConfig *config, bool adjoint_run, string val_filename) { - - su2double AoA_ = config->GetAoA(); - su2double AoS_ = config->GetAoS(); - su2double BCThrust_ = config->GetInitial_BCThrust(); - su2double dCD_dCL_ = config->GetdCD_dCL(); - su2double dCMx_dCL_ = config->GetdCMx_dCL(); - su2double dCMy_dCL_ = config->GetdCMy_dCL(); - su2double dCMz_dCL_ = config->GetdCMz_dCL(); +void CSolver::Read_SU2_Restart_Metadata(CGeometry *geometry, CConfig *config, bool adjoint, string val_filename) { + + su2double AoA_ = config->GetAoA(); + su2double AoS_ = config->GetAoS(); + su2double BCThrust_ = config->GetInitial_BCThrust(); + su2double dCD_dCL_ = config->GetdCD_dCL(); + su2double dCMx_dCL_ = config->GetdCMx_dCL(); + su2double dCMy_dCL_ = config->GetdCMy_dCL(); + su2double dCMz_dCL_ = config->GetdCMz_dCL(); string::size_type position; - unsigned long InnerIter_ = 0; - ifstream restart_file; - bool adjoint = (config->GetContinuous_Adjoint()) || (config->GetDiscrete_Adjoint()); + unsigned long InnerIter_ = 0; + ifstream restart_file; /*--- Carry on with ASCII metadata reading. ---*/ @@ -4548,7 +4547,8 @@ void CSolver::Read_SU2_Restart_Metadata(CGeometry *geometry, CConfig *config, bo cout << " Warning: There is no restart file (" << val_filename.data() << ")."<< endl; cout << " Computation will continue without updating metadata parameters." << endl; } - } else { + } + else { string text_line; @@ -4558,7 +4558,7 @@ void CSolver::Read_SU2_Restart_Metadata(CGeometry *geometry, CConfig *config, bo /*--- External iteration ---*/ - position = text_line.find ("EXT_ITER=",0); + position = text_line.find ("ITER=",0); if (position != string::npos) { text_line.erase (0,9); InnerIter_ = atoi(text_line.c_str()); } @@ -4583,46 +4583,37 @@ void CSolver::Read_SU2_Restart_Metadata(CGeometry *geometry, CConfig *config, bo if (position != string::npos) { text_line.erase (0,17); BCThrust_ = atof(text_line.c_str()); } + + /*--- dCD_dCL coefficient ---*/ - if (adjoint_run) { - - if (config->GetEval_dOF_dCX() == true) { - - /*--- dCD_dCL coefficient ---*/ - - position = text_line.find ("DCD_DCL_VALUE=",0); - if (position != string::npos) { - text_line.erase (0,14); dCD_dCL_ = atof(text_line.c_str()); - } - - /*--- dCMx_dCL coefficient ---*/ - - position = text_line.find ("DCMX_DCL_VALUE=",0); - if (position != string::npos) { - text_line.erase (0,15); dCMx_dCL_ = atof(text_line.c_str()); - } - - /*--- dCMy_dCL coefficient ---*/ - - position = text_line.find ("DCMY_DCL_VALUE=",0); - if (position != string::npos) { - text_line.erase (0,15); dCMy_dCL_ = atof(text_line.c_str()); - } - - /*--- dCMz_dCL coefficient ---*/ - - position = text_line.find ("DCMZ_DCL_VALUE=",0); - if (position != string::npos) { - text_line.erase (0,15); dCMz_dCL_ = atof(text_line.c_str()); - } - - } - + position = text_line.find ("DCD_DCL_VALUE=",0); + if (position != string::npos) { + text_line.erase (0,14); dCD_dCL_ = atof(text_line.c_str()); } + /*--- dCMx_dCL coefficient ---*/ + + position = text_line.find ("DCMX_DCL_VALUE=",0); + if (position != string::npos) { + text_line.erase (0,15); dCMx_dCL_ = atof(text_line.c_str()); + } + + /*--- dCMy_dCL coefficient ---*/ + + position = text_line.find ("DCMY_DCL_VALUE=",0); + if (position != string::npos) { + text_line.erase (0,15); dCMy_dCL_ = atof(text_line.c_str()); + } + + /*--- dCMz_dCL coefficient ---*/ + + position = text_line.find ("DCMZ_DCL_VALUE=",0); + if (position != string::npos) { + text_line.erase (0,15); dCMz_dCL_ = atof(text_line.c_str()); + } + } - /*--- Close the restart meta file. ---*/ restart_file.close(); @@ -4630,146 +4621,89 @@ void CSolver::Read_SU2_Restart_Metadata(CGeometry *geometry, CConfig *config, bo } - /*--- Load the metadata. ---*/ - - /*--- Only from the direct problem ---*/ - - if (!adjoint_run) { - - /*--- Angle of attack ---*/ - - if (config->GetDiscard_InFiles() == false) { - if ((config->GetAoA() != AoA_) && (rank == MASTER_NODE)) { - cout.precision(6); - cout <<"WARNING: AoA in the solution file (" << AoA_ << " deg.) +" << endl; - cout << " AoA offset in mesh file (" << config->GetAoA_Offset() << " deg.) = " << AoA_ + config->GetAoA_Offset() << " deg." << endl; - } - config->SetAoA(AoA_ + config->GetAoA_Offset()); - } - else { - if ((config->GetAoA() != AoA_) && (rank == MASTER_NODE)) - cout <<"WARNING: Discarding the AoA in the solution file." << endl; - } - - /*--- Sideslip angle ---*/ - - if (config->GetDiscard_InFiles() == false) { - if ((config->GetAoS() != AoS_) && (rank == MASTER_NODE)) { - cout.precision(6); - cout <<"WARNING: AoS in the solution file (" << AoS_ << " deg.) +" << endl; - cout << " AoS offset in mesh file (" << config->GetAoS_Offset() << " deg.) = " << AoS_ + config->GetAoS_Offset() << " deg." << endl; - } - config->SetAoS(AoS_ + config->GetAoS_Offset()); - } - else { - if ((config->GetAoS() != AoS_) && (rank == MASTER_NODE)) - cout <<"WARNING: Discarding the AoS in the solution file." << endl; - } - - /*--- BCThrust angle ---*/ - - if (config->GetDiscard_InFiles() == false) { - if ((config->GetInitial_BCThrust() != BCThrust_) && (rank == MASTER_NODE)) - cout <<"WARNING: SU2 will use the initial BC Thrust provided in the solution file: " << BCThrust_ << " lbs." << endl; - config->SetInitial_BCThrust(BCThrust_); - } - else { - if ((config->GetInitial_BCThrust() != BCThrust_) && (rank == MASTER_NODE)) - cout <<"WARNING: Discarding the BC Thrust in the solution file." << endl; - } - - - /*--- The adjoint problem needs this information from the direct solution ---*/ - - if (adjoint) { - - if (config->GetEval_dOF_dCX() == false) { - - if (config->GetDiscard_InFiles() == false) { - - if ((config->GetdCD_dCL() != dCD_dCL_) && (rank == MASTER_NODE)) - cout <<"WARNING: SU2 will use the dCD/dCL provided in the direct solution file: " << dCD_dCL_ << "." << endl; - config->SetdCD_dCL(dCD_dCL_); - - if ((config->GetdCMx_dCL() != dCMx_dCL_) && (rank == MASTER_NODE)) - cout <<"WARNING: SU2 will use the dCMx/dCL provided in the direct solution file: " << dCMx_dCL_ << "." << endl; - config->SetdCMx_dCL(dCMx_dCL_); - - if ((config->GetdCMy_dCL() != dCMy_dCL_) && (rank == MASTER_NODE)) - cout <<"WARNING: SU2 will use the dCMy/dCL provided in the direct solution file: " << dCMy_dCL_ << "." << endl; - config->SetdCMy_dCL(dCMy_dCL_); - - if ((config->GetdCMz_dCL() != dCMz_dCL_) && (rank == MASTER_NODE)) - cout <<"WARNING: SU2 will use the dCMz/dCL provided in the direct solution file: " << dCMz_dCL_ << "." << endl; - config->SetdCMz_dCL(dCMz_dCL_); + /*--- Load the metadata. ---*/ + + /*--- Angle of attack ---*/ - } - else { - - if ((config->GetdCD_dCL() != dCD_dCL_) && (rank == MASTER_NODE)) - cout <<"WARNING: Discarding the dCD/dCL in the direct solution file." << endl; - - if ((config->GetdCMx_dCL() != dCMx_dCL_) && (rank == MASTER_NODE)) - cout <<"WARNING: Discarding the dCMx/dCL in the direct solution file." << endl; - - if ((config->GetdCMy_dCL() != dCMy_dCL_) && (rank == MASTER_NODE)) - cout <<"WARNING: Discarding the dCMy/dCL in the direct solution file." << endl; - - if ((config->GetdCMz_dCL() != dCMz_dCL_) && (rank == MASTER_NODE)) - cout <<"WARNING: Discarding the dCMz/dCL in the direct solution file." << endl; - + if (config->GetDiscard_InFiles() == false) { + if ((config->GetAoA() != AoA_) && (rank == MASTER_NODE)) { + cout.precision(6); + cout <<"WARNING: AoA in the solution file (" << AoA_ << " deg.) +" << endl; + cout << " AoA offset in mesh file (" << config->GetAoA_Offset() << " deg.) = " << AoA_ + config->GetAoA_Offset() << " deg." << endl; } + config->SetAoA(AoA_ + config->GetAoA_Offset()); + } - } + else { + if ((config->GetAoA() != AoA_) && (rank == MASTER_NODE)) + cout <<"WARNING: Discarding the AoA in the solution file." << endl; + } - } + /*--- Sideslip angle ---*/ - } + if (config->GetDiscard_InFiles() == false) { + if ((config->GetAoS() != AoS_) && (rank == MASTER_NODE)) { + cout.precision(6); + cout <<"WARNING: AoS in the solution file (" << AoS_ << " deg.) +" << endl; + cout << " AoS offset in mesh file (" << config->GetAoS_Offset() << " deg.) = " << AoS_ + config->GetAoS_Offset() << " deg." << endl; + } + config->SetAoS(AoS_ + config->GetAoS_Offset()); + } + else { + if ((config->GetAoS() != AoS_) && (rank == MASTER_NODE)) + cout <<"WARNING: Discarding the AoS in the solution file." << endl; + } - /*--- Only from the adjoint restart file ---*/ + /*--- BCThrust ---*/ - else { + if (config->GetDiscard_InFiles() == false) { + if ((config->GetInitial_BCThrust() != BCThrust_) && (rank == MASTER_NODE)) + cout <<"WARNING: SU2 will use the initial BC Thrust provided in the solution file: " << BCThrust_ << " lbs." << endl; + config->SetInitial_BCThrust(BCThrust_); + } + else { + if ((config->GetInitial_BCThrust() != BCThrust_) && (rank == MASTER_NODE)) + cout <<"WARNING: Discarding the BC Thrust in the solution file." << endl; + } - /*--- The adjoint problem needs this information from the adjoint solution file ---*/ - if (config->GetEval_dOF_dCX() == true) { + if (config->GetDiscard_InFiles() == false) { - /*--- If it is a restart it will use the value that was stored in the adjoint solution file ---*/ + if ((config->GetdCD_dCL() != dCD_dCL_) && (rank == MASTER_NODE)) + cout <<"WARNING: SU2 will use the dCD/dCL provided in the direct solution file: " << dCD_dCL_ << "." << endl; + config->SetdCD_dCL(dCD_dCL_); - if (config->GetRestart()) { + if ((config->GetdCMx_dCL() != dCMx_dCL_) && (rank == MASTER_NODE)) + cout <<"WARNING: SU2 will use the dCMx/dCL provided in the direct solution file: " << dCMx_dCL_ << "." << endl; + config->SetdCMx_dCL(dCMx_dCL_); - /*--- dCD_dCL coefficient ---*/ - - if ((config->GetdCD_dCL() != dCD_dCL_) && (rank == MASTER_NODE)) - cout <<"WARNING: SU2 will use the dCD/dCL provided in\nthe adjoint solution file: " << dCD_dCL_ << " ." << endl; - config->SetdCD_dCL(dCD_dCL_); - - /*--- dCMx_dCL coefficient ---*/ - - if ((config->GetdCMx_dCL() != dCMx_dCL_) && (rank == MASTER_NODE)) - cout <<"WARNING: SU2 will use the dCMx/dCL provided in\nthe adjoint solution file: " << dCMx_dCL_ << " ." << endl; - config->SetdCMx_dCL(dCMx_dCL_); - - /*--- dCMy_dCL coefficient ---*/ - - if ((config->GetdCMy_dCL() != dCMy_dCL_) && (rank == MASTER_NODE)) - cout <<"WARNING: SU2 will use the dCMy/dCL provided in\nthe adjoint solution file: " << dCMy_dCL_ << " ." << endl; - config->SetdCMy_dCL(dCMy_dCL_); - - /*--- dCMz_dCL coefficient ---*/ - - if ((config->GetdCMz_dCL() != dCMz_dCL_) && (rank == MASTER_NODE)) - cout <<"WARNING: SU2 will use the dCMz/dCL provided in\nthe adjoint solution file: " << dCMz_dCL_ << " ." << endl; - config->SetdCMz_dCL(dCMz_dCL_); - - } + if ((config->GetdCMy_dCL() != dCMy_dCL_) && (rank == MASTER_NODE)) + cout <<"WARNING: SU2 will use the dCMy/dCL provided in the direct solution file: " << dCMy_dCL_ << "." << endl; + config->SetdCMy_dCL(dCMy_dCL_); + if ((config->GetdCMz_dCL() != dCMz_dCL_) && (rank == MASTER_NODE)) + cout <<"WARNING: SU2 will use the dCMz/dCL provided in the direct solution file: " << dCMz_dCL_ << "." << endl; + config->SetdCMz_dCL(dCMz_dCL_); - } + } + + else { - } + if ((config->GetdCD_dCL() != dCD_dCL_) && (rank == MASTER_NODE)) + cout <<"WARNING: Discarding the dCD/dCL in the direct solution file." << endl; + + if ((config->GetdCMx_dCL() != dCMx_dCL_) && (rank == MASTER_NODE)) + cout <<"WARNING: Discarding the dCMx/dCL in the direct solution file." << endl; + + if ((config->GetdCMy_dCL() != dCMy_dCL_) && (rank == MASTER_NODE)) + cout <<"WARNING: Discarding the dCMy/dCL in the direct solution file." << endl; + + if ((config->GetdCMz_dCL() != dCMz_dCL_) && (rank == MASTER_NODE)) + cout <<"WARNING: Discarding the dCMz/dCL in the direct solution file." << endl; - /*--- External iteration ---*/ + } + + /*--- External iteration ---*/ if ((config->GetDiscard_InFiles() == false) && (!adjoint || (adjoint && config->GetRestart()))) config->SetExtIter_OffSet(InnerIter_); diff --git a/SU2_PY/SU2/eval/functions.py b/SU2_PY/SU2/eval/functions.py index 1293c5c79d63..88f2b8a20f64 100644 --- a/SU2_PY/SU2/eval/functions.py +++ b/SU2_PY/SU2/eval/functions.py @@ -439,7 +439,8 @@ def multipoint( config, state=None, step=1e-2 ): target_cl_list = config['MULTIPOINT_TARGET_CL'].replace("(", "").replace(")", "").split(',') weight_list = config['MULTIPOINT_WEIGHT'].replace("(", "").replace(")", "").split(',') outlet_value_list = config['MULTIPOINT_OUTLET_VALUE'].replace("(", "").replace(")", "").split(',') - solution_flow_list = su2io.expand_multipoint(config.SOLUTION_FLOW_FILENAME, config) + solution_flow_list = su2io.expand_multipoint(config.SOLUTION_FILENAME, config) + flow_meta_list = su2io.expand_multipoint('flow.meta', config) restart_sol = config['RESTART_SOL'] dv_value_old = config['DV_VALUE_OLD']; @@ -452,6 +453,11 @@ def multipoint( config, state=None, step=1e-2 ): for i in range(len(weight_list)): folder[i] = 'MULTIPOINT_' + str(i) + opt_names = [] + for key in su2io.historyOutFields: + if su2io.historyOutFields[key]['TYPE'] == 'COEFFICIENT': + opt_names.append(key) + # ---------------------------------------------------- # Initialize # ---------------------------------------------------- @@ -497,13 +503,23 @@ def multipoint( config, state=None, step=1e-2 ): orig_marker_outlet = orig_marker_outlet.replace("(", "").replace(")", "").split(',') new_marker_outlet = "(" + orig_marker_outlet[0] + "," + outlet_value_list[0] + ")" config.MARKER_OUTLET = new_marker_outlet - config.SOLUTION_FLOW_FILENAME = solution_flow_list[0] + config.SOLUTION_FILENAME = solution_flow_list[0] # If solution file for the first point is available, use it if 'MULTIPOINT_DIRECT' in state.FILES and state.FILES.MULTIPOINT_DIRECT[0]: state.FILES['DIRECT'] = state.FILES.MULTIPOINT_DIRECT[0] + # If flow.meta file for the first point is available, rename it before using it + if 'MULTIPOINT_FLOW_META' in state.FILES and state.FILES.MULTIPOINT_FLOW_META[0]: + os.rename(state.FILES.MULTIPOINT_FLOW_META[0], 'flow.meta') + state.FILES['FLOW_META'] = 'flow.meta' + func[0] = aerodynamics(config,state) + + # change name of flow.meta back to multipoint name + if os.path.exists('flow.meta'): + os.rename('flow.meta', flow_meta_list[0]) + state.FILES['FLOW_META'] = flow_meta_list[0] src = os.getcwd() src = os.path.abspath(src).rstrip('/')+'/DIRECT/' @@ -525,6 +541,10 @@ def multipoint( config, state=None, step=1e-2 ): else: config['RESTART_SOL'] = 'NO' + # files: meta data for the flow + if 'FLOW_META' in files: + pull.append(files['FLOW_META']) + # files: target equivarea distribution if ( 'EQUIV_AREA' in special_cases and 'TARGET_EA' in files ) : @@ -562,16 +582,23 @@ def multipoint( config, state=None, step=1e-2 ): konfig = copy.deepcopy(config) ztate = copy.deepcopy(state) - konfig.SOLUTION_FLOW_FILENAME = solution_flow_list[i+1] + konfig.SOLUTION_FILENAME = solution_flow_list[i+1] # delete direct solution file from previous point if 'DIRECT' in ztate.FILES: del ztate.FILES.DIRECT + if 'FLOW_META' in ztate.FILES: + del ztate.FILES.FLOW_META + # use direct solution file from relevant point if 'MULTIPOINT_DIRECT' in state.FILES and state.FILES.MULTIPOINT_DIRECT[i+1]: ztate.FILES['DIRECT'] = state.FILES.MULTIPOINT_DIRECT[i+1] + # use flow.meta file from relevant point + if 'MULTIPOINT_FLOW_META' in state.FILES and state.FILES.MULTIPOINT_FLOW_META[i+1]: + ztate.FILES['FLOW_META'] = state.FILES.MULTIPOINT_FLOW_META[i+1] + # use mesh file from relevant point if 'MULTIPOINT_MESH_FILENAME' in ztate.FILES: ztate.FILES.MESH = ztate.FILES.MULTIPOINT_MESH_FILENAME[i+1] @@ -580,6 +607,7 @@ def multipoint( config, state=None, step=1e-2 ): files = ztate.FILES link = [] + pull = [] # files: mesh name = files['MESH'] @@ -594,14 +622,19 @@ def multipoint( config, state=None, step=1e-2 ): else: konfig['RESTART_SOL'] = 'NO' - # pull needed files, start folder_1 + # files: meta data for the flow + if 'FLOW_META' in files: + pull.append(files['FLOW_META']) + + # pull needed files, start folder_1 with redirect_folder( folder[i+1], pull, link ) as push: with redirect_output(log_direct): # Perform deformation on multipoint mesh if 'MULTIPOINT_MESH_FILENAME' in state.FILES: info = update_mesh(konfig,ztate) - + + # Update config values konfig.AOA = aoa_list[i+1] konfig.SIDESLIP_ANGLE = sideslip_list[i+1] konfig.MACH_NUMBER = mach_list[i+1] @@ -609,7 +642,6 @@ def multipoint( config, state=None, step=1e-2 ): konfig.FREESTREAM_TEMPERATURE = freestream_temp_list[i+1] konfig.FREESTREAM_PRESSURE = freestream_press_list[i+1] konfig.TARGET_CL = target_cl_list[i+1] - orig_marker_outlet = config['MARKER_OUTLET'] orig_marker_outlet = orig_marker_outlet.replace("(", "").replace(")", "").split(',') new_marker_outlet = "(" + orig_marker_outlet[0] + "," + outlet_value_list[i+1] + ")" @@ -617,10 +649,23 @@ def multipoint( config, state=None, step=1e-2 ): ztate.FUNCTIONS.clear() + # rename meta data to flow.meta + if 'FLOW_META' in ztate.FILES: + ztate.FILES['FLOW_META'] = 'flow.meta' + os.rename(ztate.FILES.MULTIPOINT_FLOW_META[i+1], 'flow.meta') + func[i+1] = aerodynamics(konfig,ztate) - # direct files to push dst = os.getcwd() + + # revert name of flow.meta file to multipoint name + if os.path.exists('flow.meta'): + os.rename('flow.meta', flow_meta_list[i+1]) + ztate.FILES['FLOW_META'] = flow_meta_list[i+1] + dst_flow_meta = os.path.abspath(dst).rstrip('/')+'/'+ztate.FILES['FLOW_META'] + push.append(ztate.FILES['FLOW_META']) + + # direct files to push dst_direct = os.path.abspath(dst).rstrip('/')+'/'+ztate.FILES['DIRECT'] name = ztate.FILES['DIRECT'] name = su2io.expand_zones(name,konfig) @@ -642,21 +687,29 @@ def multipoint( config, state=None, step=1e-2 ): # make unix link os.symlink(src_direct, dst_direct) - # If the mesh doesn't already exist, link + # If the mesh doesn't already exist, link it if 'MULTIPOINT_MESH_FILENAME' in state.FILES: src_mesh = os.path.abspath(src).rstrip('/')+'/'+ztate.FILES['MESH'] if not os.path.exists(src_mesh): os.symlink(src_mesh, dst_mesh) + # link flow.meta + if 'MULTIPOINT_FLOW_META' in state.FILES: + src_flow_meta = os.path.abspath(src).rstrip('/')+'/'+ztate.FILES['FLOW_META'] + if not os.path.exists(src_flow_meta): + os.symlink(src_flow_meta, dst_flow_meta) + # Update MULTIPOINT_DIRECT in state.FILES state.FILES.MULTIPOINT_DIRECT = solution_flow_list + if 'FLOW_META' in state.FILES: + state.FILES.MULTIPOINT_FLOW_META = flow_meta_list # ---------------------------------------------------- # WEIGHT FUNCTIONS # ---------------------------------------------------- for derv_name in su2io.optnames_multi: - matches = [ k for k in su2io.optnames_aero if k in derv_name ] + matches = [ k for k in opt_names if k in derv_name ] if not len(matches) == 1: continue func_name = matches[0] obj_func = 0.0 diff --git a/SU2_PY/SU2/eval/gradients.py b/SU2_PY/SU2/eval/gradients.py index 997a05871cab..8f61701ec9b8 100644 --- a/SU2_PY/SU2/eval/gradients.py +++ b/SU2_PY/SU2/eval/gradients.py @@ -435,8 +435,9 @@ def multipoint( func_name, config, state=None, step=1e-2 ): sideslip_list = config['MULTIPOINT_SIDESLIP_ANGLE'].replace("(", "").replace(")", "").split(',') target_cl_list = config['MULTIPOINT_TARGET_CL'].replace("(", "").replace(")", "").split(',') weight_list = config['MULTIPOINT_WEIGHT'].replace("(", "").replace(")", "").split(',') - solution_flow_list = su2io.expand_multipoint(config.SOLUTION_FLOW_FILENAME, config) + solution_flow_list = su2io.expand_multipoint(config.SOLUTION_FILENAME, config) solution_adj_list = su2io.expand_multipoint(config.SOLUTION_ADJ_FILENAME, config) + flow_meta_list = su2io.expand_multipoint('flow.meta', config) restart_sol = config['RESTART_SOL'] grads = [] folder = [] @@ -446,6 +447,11 @@ def multipoint( func_name, config, state=None, step=1e-2 ): for i in range(len(weight_list)): folder[i] = 'MULTIPOINT_' + str(i) + + opt_names = [] + for key in su2io.historyOutFields: + if su2io.historyOutFields[key]['TYPE'] == 'COEFFICIENT': + opt_names.append(key) # ---------------------------------------------------- # Initialize @@ -458,7 +464,7 @@ def multipoint( func_name, config, state=None, step=1e-2 ): special_cases = su2io.get_specialCases(config) # find base func name - matches = [ k for k in su2io.optnames_aero if k in func_name ] + matches = [ k for k in opt_names if k in func_name ] if not len(matches) == 1: raise Exception('could not find multipoint function name') base_name = matches[0] @@ -492,18 +498,25 @@ def multipoint( func_name, config, state=None, step=1e-2 ): config.FREESTREAM_TEMPERATURE = freestream_temp_list[0] config.FREESTREAM_PRESSURE = freestream_press_list[0] config.TARGET_CL = target_cl_list[0] - config.SOLUTION_FLOW_FILENAME = solution_flow_list[0] + config.SOLUTION_FILENAME = solution_flow_list[0] config.SOLUTION_ADJ_FILENAME = solution_adj_list[0] if MULTIPOINT_ADJ_NAME in state.FILES and state.FILES[MULTIPOINT_ADJ_NAME][0]: state.FILES[ADJ_NAME] = state.FILES[MULTIPOINT_ADJ_NAME][0] - #state.find_files(config) + # If flow.meta file for the first point is available, rename it before using it + if os.path.exists(flow_meta_list[0]): + os.rename(flow_meta_list[0], 'flow.meta') + state.FILES['FLOW_META'] = 'flow.meta' grads[0] = gradient(base_name,'DISCRETE_ADJOINT',config,state) src = os.getcwd() src = os.path.abspath(src).rstrip('/') + '/' + ADJ_NAME + '/' + # change name of flow.meta back to multipoint name + if os.path.exists('flow.meta'): + os.rename('flow.meta',flow_meta_list[0]) + state.FILES['FLOW_META'] = flow_meta_list[0] # ---------------------------------------------------- # Run Multipoint @@ -555,7 +568,7 @@ def multipoint( func_name, config, state=None, step=1e-2 ): # Reset RESTART_SOL to original value konfig['RESTART_SOL'] = restart_sol # Set correct config option names - konfig.SOLUTION_FLOW_FILENAME = solution_flow_list[i+1] + konfig.SOLUTION_FILENAME = solution_flow_list[i+1] konfig.SOLUTION_ADJ_FILENAME = solution_adj_list[i+1] # Delete file run in previous case @@ -574,6 +587,10 @@ def multipoint( func_name, config, state=None, step=1e-2 ): ztate.FILES.MESH = ztate.FILES.MULTIPOINT_MESH_FILENAME[i+1] konfig.MESH_FILENAME= ztate.FILES.MULTIPOINT_MESH_FILENAME[i+1] + # use flow.meta file from relevant point + if 'MULTIPOINT_FLOW_META' in state.FILES and state.FILES.MULTIPOINT_FLOW_META[i+1]: + ztate.FILES['FLOW_META'] = state.FILES.MULTIPOINT_FLOW_META[i+1] + files = ztate.FILES link = [] files['DIRECT'] = state.FILES.MULTIPOINT_DIRECT[i+1] @@ -597,9 +614,14 @@ def multipoint( func_name, config, state=None, step=1e-2 ): else: konfig['RESTART_SOL'] = 'NO' - # pull needed files, start folder + # files: meta data of solution + if 'FLOW_META' in files: + pull.append(files['FLOW_META']) + + # pull needed files, start folder with redirect_folder( folder[i+1], pull, link ) as push: with redirect_output(log_direct): + # Set the multipoint options konfig.AOA = aoa_list[i+1] konfig.SIDESLIP_ANGLE = sideslip_list[i+1] @@ -607,7 +629,12 @@ def multipoint( func_name, config, state=None, step=1e-2 ): konfig.REYNOLDS_NUMBER = reynolds_list[i+1] konfig.FREESTREAM_TEMPERATURE = freestream_temp_list[i+1] konfig.FREESTREAM_PRESSURE = freestream_press_list[i+1] - konfig.TARGET_CL = target_cl_list[i+1] + konfig.TARGET_CL = target_cl_list[i+1] + + # rename meta data to flow.meta + if 'FLOW_META' in ztate.FILES: + os.rename(ztate.FILES.MULTIPOINT_FLOW_META[i+1], 'flow.meta') + ztate.FILES['FLOW_META'] = 'flow.meta' # let's start somethin somthin ztate.GRADIENTS.clear() @@ -615,6 +642,10 @@ def multipoint( func_name, config, state=None, step=1e-2 ): # the gradient grads[i+1] = gradient(base_name,'DISCRETE_ADJOINT',konfig,ztate) + # rename meta data to multipoint name + if os.path.exists('flow.meta'): + os.rename('flow.meta', flow_meta_list[i+1]) + # adjoint files to push dst = os.getcwd() dst = os.path.abspath(dst).rstrip('/')+'/'+ztate.FILES[ADJ_NAME] @@ -626,7 +657,7 @@ def multipoint( func_name, config, state=None, step=1e-2 ): # Link adjoint solution to MULTIPOINT_# folder src = os.getcwd() - src = os.path.abspath(src).rstrip('/')+'/'+ztate.FILES['DIRECT'] + src = os.path.abspath(src).rstrip('/')+'/'+ztate.FILES[ADJ_NAME] # make unix link string = "ln -s " + src + " " + dst diff --git a/SU2_PY/SU2/io/state.py b/SU2_PY/SU2/io/state.py index 837ad459b612..cf58e82844b1 100644 --- a/SU2_PY/SU2/io/state.py +++ b/SU2_PY/SU2/io/state.py @@ -92,9 +92,11 @@ def State_Factory(state=None,config=None): MESH: mesh.su2 DIRECT: solution_flow.dat ADJOINT_DRAG: solution_adj_cd.dat + FLOW_META: flow.meta MULTIPOINT_DIRECT: [solution_flow_point0.dat solution_flow_point1.dat, ...] MULTIPOINT_ADJOINT_DRAG: [solution_adj_point0_cd.dat solution_adj_point1_cd.dat, ...] MULTIPOINT_MESH_FILENAME: [mesh_0.su2, mesh_1.su2, ... ] + MULTIPOINT_FLOW_META: [flow_point0.meta, flow_point1.meta, ...] HISTORY: DIRECT: {ITERATION=[1.0, 2.0, 3.0, (...) ADJOINT_DRAG: {ITERATION=[1.0, 2.0, 3.0, (...) @@ -326,6 +328,7 @@ def register_file(label,filename): register_file('MESH',mesh_name) + # direct solutions if restart: register_file('DIRECT',direct_name) if multipoint: @@ -333,6 +336,13 @@ def register_file(label,filename): name_list = expand_zones(name_list,config) register_file('MULTIPOINT_DIRECT',name_list) + # flow meta data file + if restart: + register_file('FLOW_META','flow.meta') + if multipoint: + name_list = expand_multipoint('flow.meta',config) + register_file('MULTIPOINT_FLOW_META',name_list) + # adjoint solutions if restart: for obj, suff in adj_map.items(): @@ -355,9 +365,6 @@ def register_file(label,filename): # heat flux inverse design if 'INV_DESIGN_HEATFLUX' in special_cases: register_file('TARGET_HEATFLUX',targetheatflux_name) - - # flow meta data file - register_file('FLOW_META', 'flow.meta') return diff --git a/SU2_PY/SU2/io/tools.py b/SU2_PY/SU2/io/tools.py index 264cc64f48ff..e41ebf9b1466 100755 --- a/SU2_PY/SU2/io/tools.py +++ b/SU2_PY/SU2/io/tools.py @@ -1036,7 +1036,10 @@ def restart2solution(config,state={}): for res,sol in zip(restarts,solutions): shutil.move( res , sol ) # update state - if state: state.FILES.DIRECT = solution + if state: + state.FILES.DIRECT = solution + if os.path.exists('flow.meta'): + state.FILES.FLOW_META = 'flow.meta' # adjoint solution elif any([config.MATH_PROBLEM == 'CONTINUOUS_ADJOINT', config.MATH_PROBLEM == 'DISCRETE_ADJOINT']): diff --git a/SU2_PY/SU2/opt/project.py b/SU2_PY/SU2/opt/project.py index 72ae05579c7a..4a3963e5d8e6 100644 --- a/SU2_PY/SU2/opt/project.py +++ b/SU2_PY/SU2/opt/project.py @@ -134,6 +134,8 @@ def __init__( self, config, state=None , config['OBJECTIVE_FUNCTION'] = ",".join(objectives) for this_obj in def_objs: + if this_obj in su2io.optnames_multi: + this_obj = this_obj.split('_')[1] group = historyOutFields[this_obj]['GROUP'] if not group in config.HISTORY_OUTPUT: config.HISTORY_OUTPUT.append(group) diff --git a/SU2_PY/compute_polar.py b/SU2_PY/compute_polar.py index 994967b6896b..deddc1ce5b8e 100755 --- a/SU2_PY/compute_polar.py +++ b/SU2_PY/compute_polar.py @@ -68,10 +68,10 @@ def main(): help="number of PARTITIONS", metavar="PARTITIONS") parser.add_option("-i", "--iterations", dest="iterations", default=-1, help="number of ITERATIONS", metavar="ITERATIONS") - parser.add_option("-d", "--dimmension", dest="geomDim", default=2, + parser.add_option("-d", "--dimension", dest="geomDim", default=2, help="Geometry dimension (2 or 3)", metavar="geomDim") parser.add_option("-w", "--Wind", action="store_true", dest="Wind", default=False, - help=" Wind system (default is body system") + help=" Wind system (default is body system)") parser.add_option("-v", "--Verbose", action="store_true", dest="verbose", default=False, help=" Verbose printout (if activated)") diff --git a/TestCases/disc_adj_euler/oneram6/inv_ONERAM6.cfg b/TestCases/disc_adj_euler/oneram6/inv_ONERAM6.cfg index ceb4ecb2e057..d3be5e0ccaf5 100644 --- a/TestCases/disc_adj_euler/oneram6/inv_ONERAM6.cfg +++ b/TestCases/disc_adj_euler/oneram6/inv_ONERAM6.cfg @@ -45,7 +45,7 @@ FREESTREAM_PRESSURE= 101325.0 % Free-stream temperature (288.15 K by default) FREESTREAM_TEMPERATURE= 288.15 -% -------------------------- CL & CM DRIVER DEFINITION ------------------------% +% -------------------------- CL DRIVER DEFINITION -----------------------------% % % Activate fixed lift mode (specify a CL instead of AoA, NO/YES) FIXED_CL_MODE= NO @@ -56,8 +56,8 @@ TARGET_CL= 0.286 % Estimation of dCL/dAlpha (0.2 per degree by default) DCL_DALPHA= 0.1 % -% Number of times the AoA is updated in a fix CL problem (5 by default) -UPDATE_ALPHA= 10 +% Maximum number of iterations between AoA updates +UPDATE_AOA_ITER_LIMIT= 100 % % Number of iterations to evaluate dCL_dAlpha by using finite differences (500 by default) ITER_DCL_DALPHA= 500 diff --git a/TestCases/fixed_cl/naca0012/inv_NACA0012.cfg b/TestCases/fixed_cl/naca0012/inv_NACA0012.cfg index dfb0dcc5032b..54a2d1a38475 100644 --- a/TestCases/fixed_cl/naca0012/inv_NACA0012.cfg +++ b/TestCases/fixed_cl/naca0012/inv_NACA0012.cfg @@ -35,31 +35,28 @@ MACH_NUMBER= 0.8 % Angle of attack (degrees) AOA= 1.25 % -% Activate fixed lift mode (specify a CL instead of AoA, NO/YES) -FIXED_CL_MODE= YES -% -% Number of iterations to evaluate dCL/dAlpha at the end of the simulation -ITER_DCL_DALPHA= 250 -% -% Target coefficient of lift for fixed lift mode (0.0 by default) -TARGET_CL= 0.30 -% % Free-stream pressure (101325.0 N/m^2 by default, only Euler flows) FREESTREAM_PRESSURE= 101325.0 % % Free-stream temperature (288.15 K by default) FREESTREAM_TEMPERATURE= 288.15 -% -------------------------- CL & CM DRIVER DEFINITION ------------------------% +% -------------------------- CL DRIVER DEFINITION -----------------------------% +% +% Activate fixed lift mode (specify a CL instead of AoA, NO/YES) +FIXED_CL_MODE= YES +% +% Target coefficient of lift for fixed lift mode (0.0 by default) +TARGET_CL= 0.30 % % Estimation of dCL/dAlpha (0.2 per degree by default) DCL_DALPHA= 0.2 % -% Estimation dCD/dCL (0.07 by default) -DCD_DCL_VALUE= 0.07 +% Maximum number of iterations between AoA updates +UPDATE_AOA_ITER_LIMIT= 20 % -% Number of times Alpha is updated in a fix CL problem (5 by default) -UPDATE_ALPHA= 5 +% Number of iterations to evaluate dCL/dAlpha at the end of the simulation +ITER_DCL_DALPHA= 50 % % Evaluate DeltaC_D/DeltaC_X during runtime (YES) or use the provided numbers (NO). EVAL_DOF_DCX= YES @@ -111,10 +108,10 @@ NUM_METHOD_GRAD= GREEN_GAUSS OBJECTIVE_FUNCTION= DRAG % % Courant-Friedrichs-Lewy condition of the finest grid -CFL_NUMBER= 4.0 +CFL_NUMBER= 5.0 % % Number of total iterations -ITER=101 +ITER= 1000 % ------------------------ LINEAR SOLVER DEFINITION ---------------------------% % diff --git a/TestCases/fixed_cl/naca0012/inv_NACA0012_ContAdj.cfg b/TestCases/fixed_cl/naca0012/inv_NACA0012_ContAdj.cfg index 54615e658a60..9620faf78512 100644 --- a/TestCases/fixed_cl/naca0012/inv_NACA0012_ContAdj.cfg +++ b/TestCases/fixed_cl/naca0012/inv_NACA0012_ContAdj.cfg @@ -40,22 +40,25 @@ MACH_NUMBER= 0.8 % Angle of attack (degrees) AOA= 1.25 % +% Free-stream pressure (101325.0 N/m^2 by default, only Euler flows) +FREESTREAM_PRESSURE= 101325.0 +% +% Free-stream temperature (288.15 K by default) +FREESTREAM_TEMPERATURE= 288.15 + +% -------------------------- CL DRIVER DEFINITION ----------------------------% +% % Activate fixed lift mode (specify a CL instead of AoA, NO/YES) FIXED_CL_MODE= YES % -% Number of iterations to evaluate dCL/dAlpha at the end of the simulation -ITER_DCL_DALPHA= 250 -% % Target coefficient of lift for fixed lift mode (0.0 by default) TARGET_CL= 0.30 % -% Free-stream pressure (101325.0 N/m^2 by default, only Euler flows) -FREESTREAM_PRESSURE= 101325.0 +% Maximum number of iterations between AoA updates +UPDATE_AOA_ITER_LIMIT= 20 % -% Free-stream temperature (288.15 K by default) -FREESTREAM_TEMPERATURE= 288.15 - -% -------------------------- CL & CM DRIVER DEFINITION ------------------------% +% Number of iterations to evaluate dCL/dAlpha at the end of the simulation +ITER_DCL_DALPHA= 250 % % Estimation of dCL/dAlpha (0.2 per degree by default) DCL_DALPHA= 0.2 @@ -63,9 +66,6 @@ DCL_DALPHA= 0.2 % Estimation dCD/dCL (0.07 by default) DCD_DCL_VALUE= 0.07 % -% Number of times Alpha is updated in a fix CL problem (5 by default) -UPDATE_ALPHA= 5 -% % Evaluate DeltaC_D/DeltaC_X during runtime (YES) or use the provided numbers (NO). EVAL_DOF_DCX= YES diff --git a/TestCases/optimization_euler/multipoint_naca0012/inv_NACA0012_multipoint.cfg b/TestCases/optimization_euler/multipoint_naca0012/inv_NACA0012_multipoint.cfg index f1ab985e9403..b55a1bbc030a 100644 --- a/TestCases/optimization_euler/multipoint_naca0012/inv_NACA0012_multipoint.cfg +++ b/TestCases/optimization_euler/multipoint_naca0012/inv_NACA0012_multipoint.cfg @@ -88,7 +88,7 @@ CFL_ADAPT_PARAM= ( 1.5, 0.5, 1.0, 100.0 ) RK_ALPHA_COEFF= ( 0.66667, 0.66667, 1.000000 ) % % Number of total iterations -ITER= 2500 +ITER= 100 % ------------------------ LINEAR SOLVER DEFINITION ---------------------------% % diff --git a/TestCases/parallel_regression.py b/TestCases/parallel_regression.py index f0477b8a9577..d57391263820 100644 --- a/TestCases/parallel_regression.py +++ b/TestCases/parallel_regression.py @@ -101,7 +101,7 @@ def main(): fixedCL_naca0012.cfg_dir = "fixed_cl/naca0012" fixedCL_naca0012.cfg_file = "inv_NACA0012.cfg" fixedCL_naca0012.test_iter = 10 - fixedCL_naca0012.test_vals = [-4.054559, 1.470661, 0.300113, 0.019483] #last 4 columns + fixedCL_naca0012.test_vals = [-12.175228, -6.778440, 0.300000, 0.019470] #last 4 columns fixedCL_naca0012.su2_exec = "parallel_computation.py -f" fixedCL_naca0012.timeout = 1600 fixedCL_naca0012.tol = 0.00001 @@ -563,7 +563,7 @@ def main(): contadj_fixed_CL_naca0012.cfg_dir = "fixed_cl/naca0012" contadj_fixed_CL_naca0012.cfg_file = "inv_NACA0012_ContAdj.cfg" contadj_fixed_CL_naca0012.test_iter = 100 - contadj_fixed_CL_naca0012.test_vals = [0.378722, -5.157473, 0.268300, -0.000151] #last 4 columns + contadj_fixed_CL_naca0012.test_vals = [0.319630, -5.191448, 0.361280, 0.000084] #last 4 columns contadj_fixed_CL_naca0012.su2_exec = "parallel_computation.py -f" contadj_fixed_CL_naca0012.timeout = 1600 contadj_fixed_CL_naca0012.tol = 0.00001 diff --git a/TestCases/serial_regression.py b/TestCases/serial_regression.py index 9067007c5a26..69b18f5b6a43 100644 --- a/TestCases/serial_regression.py +++ b/TestCases/serial_regression.py @@ -103,7 +103,7 @@ def main(): fixedCL_naca0012.cfg_dir = "fixed_cl/naca0012" fixedCL_naca0012.cfg_file = "inv_NACA0012.cfg" fixedCL_naca0012.test_iter = 10 - fixedCL_naca0012.test_vals = [-4.031390, 1.500719, 0.300135, 0.019485] #last 4 columns + fixedCL_naca0012.test_vals = [-12.181731, -6.784160, 0.300000, 0.019470] #last 4 columns fixedCL_naca0012.su2_exec = "SU2_CFD" fixedCL_naca0012.new_output = True fixedCL_naca0012.timeout = 1600 @@ -600,7 +600,7 @@ def main(): contadj_fixedCL_naca0012.cfg_dir = "fixed_cl/naca0012" contadj_fixedCL_naca0012.cfg_file = "inv_NACA0012_ContAdj.cfg" contadj_fixedCL_naca0012.test_iter = 100 - contadj_fixedCL_naca0012.test_vals = [0.340921, -5.166616, 0.265490, -0.000324] #last 4 columns + contadj_fixedCL_naca0012.test_vals = [0.294602, -5.201081, 3.6098e-01, -1.3983e-05] #last 4 columns contadj_fixedCL_naca0012.su2_exec = "SU2_CFD" contadj_fixedCL_naca0012.new_output= True contadj_fixedCL_naca0012.timeout = 1600 diff --git a/config_template.cfg b/config_template.cfg index 3a376c493fff..01e151eb2722 100644 --- a/config_template.cfg +++ b/config_template.cfg @@ -170,8 +170,8 @@ TARGET_CL= 0.80 % Estimation of dCL/dAlpha (0.2 per degree by default) DCL_DALPHA= 0.2 % -% Number of times the AoA is updated in a fix CL problem (5 by default) -UPDATE_ALPHA= 5 +% Maximum number of iterations between AoA updates +UPDATE_AOA_ITER_LIMIT= 100 % % Number of iterations to evaluate dCL_dAlpha by using finite differences (500 by default) ITER_DCL_DALPHA= 500 @@ -1443,7 +1443,7 @@ MULTIPOINT_FREESTREAM_PRESSURE= (101325.0, 101325.0, 101325.0) MULTIPOINT_FREESTREAM_TEMPERATURE= (288.15, 288.15, 288.15) MULTIPOINT_OUTLET_VALUE= (0.0, 0.0, 0.0) MULTIPOINT_WEIGHT= (0.33333, 0.33333, 0.33333) -MULTIPOINT_MESH_FILENAME(mesh_NACA0012_m79.su2, mesh_NACA0012_m8.su2, mesh_NACA0012_m81.su2) +MULTIPOINT_MESH_FILENAME= (mesh_NACA0012_m79.su2, mesh_NACA0012_m8.su2, mesh_NACA0012_m81.su2) % % Optimization objective function with scaling factor, separated by semicolons. % To include quadratic penalty function: use OPT_CONSTRAINT option syntax within the OPT_OBJECTIVE list.