Skip to content

Commit 4acbdf8

Browse files
authored
Merge pull request #1020 from su2code/feature_quasi_newton_adjoint
Quasi-Newton convergence acceleration/stabilization of discrete adjoints
2 parents 967b62c + f3e6172 commit 4acbdf8

21 files changed

Lines changed: 518 additions & 92 deletions

Common/include/CConfig.hpp

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -396,7 +396,6 @@ class CConfig {
396396
unsigned long InnerIter; /*!< \brief Current inner iterations for multizone problems. */
397397
unsigned long TimeIter; /*!< \brief Current time iterations for multizone problems. */
398398
unsigned long Unst_nIntIter; /*!< \brief Number of internal iterations (Dual time Method). */
399-
unsigned long Dyn_nIntIter; /*!< \brief Number of internal iterations (Newton-Raphson Method for nonlinear structural analysis). */
400399
long Unst_RestartIter; /*!< \brief Iteration number to restart an unsteady simulation (Dual time Method). */
401400
long Unst_AdjointIter; /*!< \brief Iteration number to begin the reverse time integration in the direct solver for the unsteady adjoint. */
402401
long Iter_Avg_Objective; /*!< \brief Iteration the number of time steps to be averaged, counting from the back */
@@ -412,6 +411,8 @@ class CConfig {
412411
unsigned short nRKStep; /*!< \brief Number of steps of the explicit Runge-Kutta method. */
413412
su2double *RK_Alpha_Step; /*!< \brief Runge-Kutta beta coefficients. */
414413

414+
unsigned short nQuasiNewtonSamples; /*!< \brief Number of samples used in quasi-Newton solution methods. */
415+
415416
unsigned short nMGLevels; /*!< \brief Number of multigrid levels (coarse levels). */
416417
unsigned short nCFL; /*!< \brief Number of CFL, one for each multigrid level. */
417418
su2double
@@ -820,9 +821,9 @@ class CConfig {
820821
su2double* CpPolyCoefficients; /*!< \brief Definition of the temperature polynomial coefficients for specific heat Cp. */
821822
su2double* MuPolyCoefficients; /*!< \brief Definition of the temperature polynomial coefficients for viscosity. */
822823
su2double* KtPolyCoefficients; /*!< \brief Definition of the temperature polynomial coefficients for thermal conductivity. */
823-
array<su2double, N_POLY_COEFFS> CpPolyCoefficientsND{0.0}; /*!< \brief Definition of the non-dimensional temperature polynomial coefficients for specific heat Cp. */
824-
array<su2double, N_POLY_COEFFS>MuPolyCoefficientsND{0.0}; /*!< \brief Definition of the non-dimensional temperature polynomial coefficients for viscosity. */
825-
array<su2double, N_POLY_COEFFS>KtPolyCoefficientsND{0.0}; /*!< \brief Definition of the non-dimensional temperature polynomial coefficients for thermal conductivity. */
824+
array<su2double, N_POLY_COEFFS> CpPolyCoefficientsND{{0.0}}; /*!< \brief Definition of the non-dimensional temperature polynomial coefficients for specific heat Cp. */
825+
array<su2double, N_POLY_COEFFS> MuPolyCoefficientsND{{0.0}}; /*!< \brief Definition of the non-dimensional temperature polynomial coefficients for viscosity. */
826+
array<su2double, N_POLY_COEFFS> KtPolyCoefficientsND{{0.0}}; /*!< \brief Definition of the non-dimensional temperature polynomial coefficients for thermal conductivity. */
826827
su2double Thermal_Conductivity_Solid, /*!< \brief Thermal conductivity in solids. */
827828
Thermal_Diffusivity_Solid, /*!< \brief Thermal diffusivity in solids. */
828829
Temperature_Freestream_Solid, /*!< \brief Temperature in solids at freestream conditions. */
@@ -1016,9 +1017,9 @@ class CConfig {
10161017
su2double FinalRotation_Rate_Z; /*!< \brief Final rotation rate Z if Ramp rotating frame is activated. */
10171018
su2double FinalOutletPressure; /*!< \brief Final outlet pressure if Ramp outlet pressure is activated. */
10181019
su2double MonitorOutletPressure; /*!< \brief Monitor outlet pressure if Ramp outlet pressure is activated. */
1019-
array<su2double, N_POLY_COEFFS> default_cp_polycoeffs{0.0}; /*!< \brief Array for specific heat polynomial coefficients. */
1020-
array<su2double, N_POLY_COEFFS> default_mu_polycoeffs{0.0}; /*!< \brief Array for viscosity polynomial coefficients. */
1021-
array<su2double, N_POLY_COEFFS> default_kt_polycoeffs{0.0}; /*!< \brief Array for thermal conductivity polynomial coefficients. */
1020+
array<su2double, N_POLY_COEFFS> default_cp_polycoeffs{{0.0}}; /*!< \brief Array for specific heat polynomial coefficients. */
1021+
array<su2double, N_POLY_COEFFS> default_mu_polycoeffs{{0.0}}; /*!< \brief Array for viscosity polynomial coefficients. */
1022+
array<su2double, N_POLY_COEFFS> default_kt_polycoeffs{{0.0}}; /*!< \brief Array for thermal conductivity polynomial coefficients. */
10221023
su2double *ExtraRelFacGiles; /*!< \brief coefficient for extra relaxation factor for Giles BC*/
10231024
bool Body_Force; /*!< \brief Flag to know if a body force is included in the formulation. */
10241025
su2double *Body_Force_Vector; /*!< \brief Values of the prescribed body force vector. */
@@ -2941,12 +2942,6 @@ class CConfig {
29412942
*/
29422943
unsigned long GetUnst_nIntIter(void) const { return Unst_nIntIter; }
29432944

2944-
/*!
2945-
* \brief Get the number of internal iterations for the Newton-Raphson Method in nonlinear structural applications.
2946-
* \return Number of internal iterations.
2947-
*/
2948-
unsigned long GetDyn_nIntIter(void) const { return Dyn_nIntIter; }
2949-
29502945
/*!
29512946
* \brief Get the starting direct iteration number for the unsteady adjoint (reverse time integration).
29522947
* \return Starting direct iteration number for the unsteady adjoint.
@@ -4026,6 +4021,11 @@ class CConfig {
40264021
*/
40274022
su2double GetRelaxation_Factor_CHT(void) const { return Relaxation_Factor_CHT; }
40284023

4024+
/*!
4025+
* \brief Get the number of samples used in quasi-Newton methods.
4026+
*/
4027+
unsigned short GetnQuasiNewtonSamples(void) const { return nQuasiNewtonSamples; }
4028+
40294029
/*!
40304030
* \brief Get the relaxation coefficient of the linear solver for the implicit formulation.
40314031
* \return relaxation coefficient of the linear solver for the implicit formulation.

Common/include/mpi_structure.hpp

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -71,18 +71,6 @@ class CBaseMPIWrapper;
7171
typedef CBaseMPIWrapper SU2_MPI;
7272
#endif // defined CODI_REVERSE_TYPE || defined CODI_FORWARD_TYPE
7373

74-
/*--- Select the appropriate MPI wrapper based on datatype, to use in templated classes. ---*/
75-
template<class T> struct SelectMPIWrapper { typedef SU2_MPI W; };
76-
77-
/*--- In AD we specialize for the passive wrapper. ---*/
78-
#if defined CODI_REVERSE_TYPE
79-
class CBaseMPIWrapper;
80-
template<> struct SelectMPIWrapper<passivedouble> { typedef CBaseMPIWrapper W; };
81-
#if defined USE_MIXED_PRECISION
82-
template<> struct SelectMPIWrapper<su2mixedfloat> { typedef CBaseMPIWrapper W; };
83-
#endif
84-
#endif
85-
8674
/*!
8775
* \class CMPIWrapper
8876
* \brief Class for defining the MPI wrapper routines; this class features as a base class for
@@ -326,6 +314,7 @@ class CMediMPIWrapper: public CBaseMPIWrapper {
326314
#define MPI_UNSIGNED_LONG 1
327315
#define MPI_LONG 2
328316
#define MPI_UNSIGNED_SHORT 3
317+
#define MPI_FLOAT 4
329318
#define MPI_DOUBLE 4
330319
#define MPI_ANY_SOURCE 5
331320
#define MPI_SUM 6
@@ -455,6 +444,17 @@ typedef CBaseMPIWrapper SU2_MPI;
455444

456445
#endif
457446

447+
/*--- Select the appropriate MPI wrapper based on datatype, to use in templated classes. ---*/
448+
template<class T> struct SelectMPIWrapper { typedef SU2_MPI W; };
449+
450+
/*--- In AD we specialize for the passive wrapper. ---*/
451+
#if defined CODI_REVERSE_TYPE
452+
template<> struct SelectMPIWrapper<passivedouble> { typedef CBaseMPIWrapper W; };
453+
#if defined USE_MIXED_PRECISION
454+
template<> struct SelectMPIWrapper<su2mixedfloat> { typedef CBaseMPIWrapper W; };
455+
#endif
456+
#endif
457+
458458
/* Depending on the compiler, define the correct macro to get the current function name */
459459

460460
#if defined(__GNUC__) || (defined(__ICC) && (__ICC >= 600))

Common/include/omp_structure.hpp

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -55,11 +55,6 @@
5555
/*--- The generic start of OpenMP constructs. ---*/
5656
#define SU2_OMP(ARGS) PRAGMIZE(omp ARGS)
5757

58-
/*--- Detect SIMD support (version 4+, after Jul 2013). ---*/
59-
#if _OPENMP >= 201307
60-
#define HAVE_OMP_SIMD
61-
#endif
62-
6358
#else // Compile without OpenMP
6459

6560
/*--- Disable pragmas to quiet compilation warnings. ---*/
@@ -98,10 +93,20 @@ inline void omp_set_lock(omp_lock_t*){}
9893
inline void omp_unset_lock(omp_lock_t*){}
9994
inline void omp_destroy_lock(omp_lock_t*){}
10095

96+
#endif // end OpenMP detection
97+
98+
/*--- Detect SIMD support (version 4+, after Jul 2013). ---*/
99+
#ifdef _OPENMP
100+
#if _OPENMP >= 201307
101+
#define HAVE_OMP_SIMD
102+
#define SU2_OMP_SIMD PRAGMIZE(omp simd)
103+
#endif
104+
#endif
105+
#ifndef SU2_OMP_SIMD
106+
#define SU2_OMP_SIMD
101107
#endif
102108

103-
/*--- Convenience macros (do not use excessive nesting of macros). ---*/
104-
#define SU2_OMP_SIMD SU2_OMP(simd)
109+
/*--- Convenience macros (do not use excessive nesting). ---*/
105110

106111
#define SU2_OMP_MASTER SU2_OMP(master)
107112
#define SU2_OMP_ATOMIC SU2_OMP(atomic)
@@ -115,12 +120,6 @@ inline void omp_destroy_lock(omp_lock_t*){}
115120
#define SU2_OMP_FOR_DYN(CHUNK) SU2_OMP(for schedule(dynamic,CHUNK))
116121
#define SU2_OMP_FOR_STAT(CHUNK) SU2_OMP(for schedule(static,CHUNK))
117122

118-
/*--- Disable some unsupported features. ---*/
119-
#ifndef HAVE_OMP_SIMD
120-
#undef SU2_OMP_SIMD
121-
#define SU2_OMP_SIMD
122-
#endif
123-
124123
/*--- Convenience functions (e.g. to compute chunk sizes). ---*/
125124

126125
/*!

0 commit comments

Comments
 (0)