From 3e8ba472217acbc25b99fad22da985ad59226d4e Mon Sep 17 00:00:00 2001 From: Filip Hahs Date: Tue, 11 Jul 2023 13:24:32 -0400 Subject: [PATCH 01/48] add basic support for rotation changes --- Common/include/CConfig.hpp | 7 +++++++ SU2_CFD/include/drivers/CDriver.hpp | 1 + SU2_CFD/src/iteration/CIteration.cpp | 13 ++++++++++++- SU2_CFD/src/python_wrapper_structure.cpp | 7 +++++++ 4 files changed, 27 insertions(+), 1 deletion(-) diff --git a/Common/include/CConfig.hpp b/Common/include/CConfig.hpp index 39ebcf28c01..83d574deb1c 100644 --- a/Common/include/CConfig.hpp +++ b/Common/include/CConfig.hpp @@ -5946,6 +5946,13 @@ class CConfig { * \return Rotation velocity of the marker. */ su2double GetMarkerRotationRate(unsigned short iMarkerMoving, unsigned short iDim) const { return MarkerRotation_Rate[3*iMarkerMoving + iDim];} + /*! + * \brief Set the rotation rate of the marker. + * \param[in] iMarkerMoving - Index of the moving marker (as specified in Marker_Moving) + * \param[in] iDim - spatial component + * \return Rotation velocity of the marker. + */ + void SetMarkerRotation_Rate(unsigned short iMarkerMoving, unsigned short iDim, su2double val) const { MarkerRotation_Rate[3*iMarkerMoving + iDim] = val;} /*! * \brief Get the pitching rate of the mesh. diff --git a/SU2_CFD/include/drivers/CDriver.hpp b/SU2_CFD/include/drivers/CDriver.hpp index 236c932b630..e6bcd68eb9a 100644 --- a/SU2_CFD/include/drivers/CDriver.hpp +++ b/SU2_CFD/include/drivers/CDriver.hpp @@ -536,6 +536,7 @@ class CDriver : public CDriverBase { */ void SetRotationRate(passivedouble rot_x, passivedouble rot_y, passivedouble rot_z); + void SetMarkerRotationRate(short int iMarker, passivedouble rot_x, passivedouble rot_y, passivedouble rot_z); /// \} }; diff --git a/SU2_CFD/src/iteration/CIteration.cpp b/SU2_CFD/src/iteration/CIteration.cpp index 517f3bff2c4..4b6de158796 100644 --- a/SU2_CFD/src/iteration/CIteration.cpp +++ b/SU2_CFD/src/iteration/CIteration.cpp @@ -88,11 +88,18 @@ void CIteration::SetGrid_Movement(CGeometry** geometry, CSurfaceMovement* surfac } break; + + } - if (config->GetSurface_Movement(AEROELASTIC) || config->GetSurface_Movement(AEROELASTIC_RIGID_MOTION)) { + if (config->GetSurface_Movement(AEROELASTIC) || config->GetSurface_Movement(AEROELASTIC_RIGID_MOTION) || config->GetSurface_Movement(MOVING_WALL)) { /*--- Apply rigid mesh transformation to entire grid first, if necessary ---*/ + if (IntIter == 0) { + cout << "TESTING:\n"; + + cout << config->GetSurface_Movement(MOVING_WALL); + cout << "\n"; if (Kind_Grid_Movement == AEROELASTIC_RIGID_MOTION) { if (rank == MASTER_NODE) cout << endl << " Performing rigid mesh transformation." << endl; @@ -110,6 +117,10 @@ void CIteration::SetGrid_Movement(CGeometry** geometry, CSurfaceMovement* surfac grid_movement->UpdateMultiGrid(geometry, config); } + if(config->GetSurface_Movement(MOVING_WALL)){ + geometry[MESH_0]->SetWallVelocity(config, true); + + } } diff --git a/SU2_CFD/src/python_wrapper_structure.cpp b/SU2_CFD/src/python_wrapper_structure.cpp index ffcc36d2f54..ffa2b051065 100644 --- a/SU2_CFD/src/python_wrapper_structure.cpp +++ b/SU2_CFD/src/python_wrapper_structure.cpp @@ -166,4 +166,11 @@ void CDriver::SetRotationRate(passivedouble rot_x, passivedouble rot_y, passived config_container[iZone]->SetRotation_Rate(2, rot_z); } } +void CDriver::SetMarkerRotationRate(short int iMarker, passivedouble rot_x, passivedouble rot_y, passivedouble rot_z){ + for (iZone = 0; iZone < nZone; iZone++) { + config_container[iZone]->SetMarkerRotation_Rate(iMarker, 0, rot_x); + config_container[iZone]->SetMarkerRotation_Rate(iMarker, 1, rot_y); + config_container[iZone]->SetMarkerRotation_Rate(iMarker, 2, rot_z); + } +} From 5fdc66439e42de5175da68f6948e706b4ad84094 Mon Sep 17 00:00:00 2001 From: Filip Hahs Date: Fri, 28 Jul 2023 10:38:09 +0200 Subject: [PATCH 02/48] add translation --- Common/include/CConfig.hpp | 11 ++++++++++- SU2_CFD/include/drivers/CDriver.hpp | 17 ++++++++++++++++- SU2_CFD/src/iteration/CIteration.cpp | 5 +---- SU2_CFD/src/python_wrapper_structure.cpp | 7 +++++++ 4 files changed, 34 insertions(+), 6 deletions(-) diff --git a/Common/include/CConfig.hpp b/Common/include/CConfig.hpp index 83d574deb1c..9955a9b010a 100644 --- a/Common/include/CConfig.hpp +++ b/Common/include/CConfig.hpp @@ -5924,6 +5924,14 @@ class CConfig { */ su2double GetMarkerTranslationRate(unsigned short iMarkerMoving, unsigned short iDim) const { return MarkerTranslation_Rate[3*iMarkerMoving + iDim];} + /*! + * \brief Set the translation rate of the marker. + * \param[in] iDim - spatial component + * \param[in] val - translational velocity + * \return Translational velocity of the mesh. + */ + void SetMarkerTranslation_Rate(unsigned short iMarkerMoving, unsigned short iDim, su2double val) const { MarkerTranslation_Rate[3*iMarkerMoving + iDim] = val;} + /*! * \brief Get the rotation rate of the mesh. * \param[in] iDim - spatial component @@ -5950,7 +5958,8 @@ class CConfig { * \brief Set the rotation rate of the marker. * \param[in] iMarkerMoving - Index of the moving marker (as specified in Marker_Moving) * \param[in] iDim - spatial component - * \return Rotation velocity of the marker. + * \param[in] val - Rotational velocity + */ void SetMarkerRotation_Rate(unsigned short iMarkerMoving, unsigned short iDim, su2double val) const { MarkerRotation_Rate[3*iMarkerMoving + iDim] = val;} diff --git a/SU2_CFD/include/drivers/CDriver.hpp b/SU2_CFD/include/drivers/CDriver.hpp index e6bcd68eb9a..928753dc019 100644 --- a/SU2_CFD/include/drivers/CDriver.hpp +++ b/SU2_CFD/include/drivers/CDriver.hpp @@ -535,8 +535,23 @@ class CDriver : public CDriverBase { * \param[in] rot_z - Value of Angular velocity about z-axes. */ void SetRotationRate(passivedouble rot_x, passivedouble rot_y, passivedouble rot_z); - + /*! + * \brief Set the moving wall marker rotation rates. + * \param[in] iMaker - Index of moving wall marker. + * \param[in] rot_x - Value of Angular velocity about x-axes. + * \param[in] rot_y - Value of Angular velocity about y-axes. + * \param[in] rot_z - Value of Angular velocity about z-axes. + */ void SetMarkerRotationRate(short int iMarker, passivedouble rot_x, passivedouble rot_y, passivedouble rot_z); + /*! + * \brief Set the moving wall marker rotation rates. + * \param[in] iMaker - Index of moving wall marker. + * \param[in] vel_x - Value of velocity about x-axes. + * \param[in] vel_y - Value of velocity about y-axes. + * \param[in] vel_z - Value of velocity about z-axes. + */ + void SetMarkerTranslationRate(short int iMarker, passivedouble vel_x, passivedouble vel_y, passivedouble vel_z); + /// \} }; diff --git a/SU2_CFD/src/iteration/CIteration.cpp b/SU2_CFD/src/iteration/CIteration.cpp index 4b6de158796..8224b45950a 100644 --- a/SU2_CFD/src/iteration/CIteration.cpp +++ b/SU2_CFD/src/iteration/CIteration.cpp @@ -96,10 +96,7 @@ void CIteration::SetGrid_Movement(CGeometry** geometry, CSurfaceMovement* surfac /*--- Apply rigid mesh transformation to entire grid first, if necessary ---*/ if (IntIter == 0) { - cout << "TESTING:\n"; - - cout << config->GetSurface_Movement(MOVING_WALL); - cout << "\n"; + if (Kind_Grid_Movement == AEROELASTIC_RIGID_MOTION) { if (rank == MASTER_NODE) cout << endl << " Performing rigid mesh transformation." << endl; diff --git a/SU2_CFD/src/python_wrapper_structure.cpp b/SU2_CFD/src/python_wrapper_structure.cpp index ffa2b051065..ee7ae45a3e7 100644 --- a/SU2_CFD/src/python_wrapper_structure.cpp +++ b/SU2_CFD/src/python_wrapper_structure.cpp @@ -173,4 +173,11 @@ void CDriver::SetMarkerRotationRate(short int iMarker, passivedouble rot_x, pass config_container[iZone]->SetMarkerRotation_Rate(iMarker, 2, rot_z); } } +void CDriver::SetMarkerTranslationRate(short int iMarker, passivedouble vel_x, passivedouble vel_y, passivedouble vel_z){ + for (iZone = 0; iZone < nZone; iZone++) { + config_container[iZone]->SetMarkerTranslation_Rate(iMarker, 0, vel_x); + config_container[iZone]->SetMarkerTranslation_Rate(iMarker, 1, vel_y); + config_container[iZone]->SetMarkerTranslation_Rate(iMarker, 2, vel_z); + } +} From ba0e7328ab9eaff30c61e4e0ba95e16ebca8a4f4 Mon Sep 17 00:00:00 2001 From: Filip Hahs Date: Fri, 28 Jul 2023 14:10:33 +0200 Subject: [PATCH 03/48] add example --- TestCases/py_wrapper/rotating_cylinder/run.py | 30 +++++ .../rotating_cylinder/spinning_cylinder.cfg | 115 ++++++++++++++++++ 2 files changed, 145 insertions(+) create mode 100644 TestCases/py_wrapper/rotating_cylinder/run.py create mode 100644 TestCases/py_wrapper/rotating_cylinder/spinning_cylinder.cfg diff --git a/TestCases/py_wrapper/rotating_cylinder/run.py b/TestCases/py_wrapper/rotating_cylinder/run.py new file mode 100644 index 00000000000..64e36c2eddb --- /dev/null +++ b/TestCases/py_wrapper/rotating_cylinder/run.py @@ -0,0 +1,30 @@ +import sys +from optparse import OptionParser # use a parser for configuration +import pysu2 # imports the SU2 wrapped module +from math import * +import os +import pysu2ad +from mpi4py import MPI +import numpy as np +import shutil +comm = MPI.COMM_WORLD +rank = comm.Get_rank() +ad_com = MPI.COMM_WORLD +rank_ad = ad_com.Get_rank() +n_of_steps = 10 +rotation_vector = np.zeros(n_of_steps)+20 +rotation_vector[5:9] = -rotation_vector[5:9] + +SU2Driver = pysu2.CSinglezoneDriver("spinning_cylinder.cfg",1, comm) + +for i in range(n_of_steps): + + SU2Driver.SetMarkerRotationRate(0,0,0,rotation_vector[n_of_steps-i-1]) + SU2Driver.Preprocess(i) + SU2Driver.Run() + SU2Driver.Postprocess() + SU2Driver.Output(i) + SU2Driver.Update() +SU2Driver.Finalize() + + \ No newline at end of file diff --git a/TestCases/py_wrapper/rotating_cylinder/spinning_cylinder.cfg b/TestCases/py_wrapper/rotating_cylinder/spinning_cylinder.cfg new file mode 100644 index 00000000000..194a46064dd --- /dev/null +++ b/TestCases/py_wrapper/rotating_cylinder/spinning_cylinder.cfg @@ -0,0 +1,115 @@ +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% % +% SU2 configuration file % +% Case description: Laminar flow around a spinning cylinder % +% Author: Thomas D. Economon % +% Institution: Stanford University % +% Date: 2013.08.21 % +% File Version 7.5.1 "Blackbird" % +% % +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +% ------------- DIRECT, ADJOINT, AND LINEARIZED PROBLEM DEFINITION ------------% +% +SOLVER= NAVIER_STOKES +KIND_TURB_MODEL= NONE +MATH_PROBLEM= DIRECT +RESTART_SOL= NO + +% ----------- COMPRESSIBLE AND INCOMPRESSIBLE FREE-STREAM DEFINITION ----------% +% +MACH_NUMBER= 0.1 +AOA= 0.0 +SIDESLIP_ANGLE= 0.0 +FREESTREAM_TEMPERATURE= 288.15 +REYNOLDS_NUMBER= 200.0 +REYNOLDS_LENGTH= 1.0 + +% ----------------------- DYNAMIC MESH DEFINITION -----------------------------% +% +SURFACE_MOVEMENT= MOVING_WALL +MACH_MOTION= 0.1 +MARKER_MOVING= ( cylinder ) +SURFACE_MOTION_ORIGIN= 0.5 0.0 0.0 +SURFACE_ROTATION_RATE = 0.0 0.0 -199.0738 + +% ---------------------- REFERENCE VALUE DEFINITION ---------------------------% +% +REF_ORIGIN_MOMENT_X = 0.00 +REF_ORIGIN_MOMENT_Y = 0.00 +REF_ORIGIN_MOMENT_Z = 0.00 +REF_LENGTH= 1.0 +REF_AREA= 1.0 + +% -------------------- BOUNDARY CONDITION DEFINITION --------------------------% +% +MARKER_HEATFLUX= ( cylinder, 0.0 ) +MARKER_FAR= ( farfield ) +MARKER_PLOTTING= ( cylinder ) +MARKER_MONITORING= ( cylinder ) + +% ------------- COMMON PARAMETERS DEFINING THE NUMERICAL METHOD ---------------% +% +NUM_METHOD_GRAD= WEIGHTED_LEAST_SQUARES +CFL_NUMBER= 100.0 +CFL_ADAPT= NO +CFL_ADAPT_PARAM= ( 1.5, 0.5, 1.0, 100.0 ) +ITER= 99999 + +% ----------------------- SLOPE LIMITER DEFINITION ----------------------------% +% +VENKAT_LIMITER_COEFF= 0.03 +ADJ_SHARP_LIMITER_COEFF= 3.0 +REF_SHARP_EDGES= 3.0 +SENS_REMOVE_SHARP= NO + +% ------------------------ LINEAR SOLVER DEFINITION ---------------------------% +% +LINEAR_SOLVER= FGMRES +LINEAR_SOLVER_PREC= LU_SGS +LINEAR_SOLVER_ERROR= 1E-4 +LINEAR_SOLVER_ITER= 5 + +% -------------------------- MULTIGRID PARAMETERS -----------------------------% +% +MGLEVEL= 3 +MGCYCLE= V_CYCLE +MG_PRE_SMOOTH= ( 1, 1, 1, 1 ) +MG_POST_SMOOTH= ( 0, 0, 0, 0 ) +MG_CORRECTION_SMOOTH= ( 0, 0, 0, 0 ) +MG_DAMP_RESTRICTION= 0.5 +MG_DAMP_PROLONGATION= 0.5 + +% -------------------- FLOW NUMERICAL METHOD DEFINITION -----------------------% +% +CONV_NUM_METHOD_FLOW= ROE +MUSCL_FLOW= YES +SLOPE_LIMITER_FLOW= NONE +JST_SENSOR_COEFF= ( 0.5, 0.02 ) +TIME_DISCRE_FLOW= EULER_IMPLICIT + +% --------------------------- CONVERGENCE PARAMETERS --------------------------% +% +CONV_RESIDUAL_MINVAL= -15 +CONV_STARTITER= 10 +CONV_CAUCHY_ELEMS= 100 +CONV_CAUCHY_EPS= 1E-7 + +% ------------------------- INPUT/OUTPUT INFORMATION --------------------------% +% +MESH_FILENAME= mesh_cylinder_lam.su2 +MESH_FORMAT= SU2 +MESH_OUT_FILENAME= mesh_out.su2 +SOLUTION_FILENAME= solution_flow.dat +SOLUTION_ADJ_FILENAME= solution_adj.dat +TABULAR_FORMAT= CSV +CONV_FILENAME= history +RESTART_FILENAME= restart_flow.dat +RESTART_ADJ_FILENAME= restart_adj.dat +VOLUME_FILENAME= flow +VOLUME_ADJ_FILENAME= adjoint +GRAD_OBJFUNC_FILENAME= of_grad.dat +SURFACE_FILENAME= surface_flow +SURFACE_ADJ_FILENAME= surface_adjoint +OUTPUT_WRT_FREQ= 100 +SCREEN_OUTPUT= (INNER_ITER, RMS_DENSITY, RMS_ENERGY, LIFT, DRAG) From ce66598aa62f441d18349417e6d61252cb38c8b4 Mon Sep 17 00:00:00 2001 From: Filip Hahs Date: Sat, 29 Jul 2023 08:50:19 +0200 Subject: [PATCH 04/48] remove unused imports --- TestCases/py_wrapper/rotating_cylinder/run.py | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/TestCases/py_wrapper/rotating_cylinder/run.py b/TestCases/py_wrapper/rotating_cylinder/run.py index 64e36c2eddb..cbf2d968686 100644 --- a/TestCases/py_wrapper/rotating_cylinder/run.py +++ b/TestCases/py_wrapper/rotating_cylinder/run.py @@ -1,12 +1,8 @@ -import sys -from optparse import OptionParser # use a parser for configuration import pysu2 # imports the SU2 wrapped module from math import * -import os -import pysu2ad from mpi4py import MPI import numpy as np -import shutil + comm = MPI.COMM_WORLD rank = comm.Get_rank() ad_com = MPI.COMM_WORLD From 5d90c340f9600fcacebc21e731d36b47d0505288 Mon Sep 17 00:00:00 2001 From: Filip Hahs Date: Sat, 29 Jul 2023 21:43:29 +0200 Subject: [PATCH 05/48] i hope the test will pass --- Common/include/CConfig.hpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Common/include/CConfig.hpp b/Common/include/CConfig.hpp index 77df929dc58..fd78b7e54ba 100644 --- a/Common/include/CConfig.hpp +++ b/Common/include/CConfig.hpp @@ -5973,8 +5973,8 @@ class CConfig { * \brief Set the rotation rate of the marker. * \param[in] iMarkerMoving - Index of the moving marker (as specified in Marker_Moving) * \param[in] iDim - spatial component - * \param[in] val - Rotational velocity - + * \param[in] val - Rotational velocity + */ void SetMarkerRotation_Rate(unsigned short iMarkerMoving, unsigned short iDim, su2double val) const { MarkerRotation_Rate[3*iMarkerMoving + iDim] = val;} From 7331adb1b8b1944d4212d1df4a4c0b8c8e9d75eb Mon Sep 17 00:00:00 2001 From: Pedro Gomes <38071223+pcarruscag@users.noreply.github.com> Date: Sat, 29 Jul 2023 17:12:36 -0700 Subject: [PATCH 06/48] Apply suggestions from code review --- Common/include/CConfig.hpp | 13 ++++++++----- SU2_CFD/include/drivers/CDriver.hpp | 15 ++++++++------- SU2_CFD/src/iteration/CIteration.cpp | 9 ++++----- SU2_CFD/src/python_wrapper_structure.cpp | 6 ++++-- 4 files changed, 24 insertions(+), 19 deletions(-) diff --git a/Common/include/CConfig.hpp b/Common/include/CConfig.hpp index fd78b7e54ba..256444b7f37 100644 --- a/Common/include/CConfig.hpp +++ b/Common/include/CConfig.hpp @@ -5943,9 +5943,10 @@ class CConfig { * \brief Set the translation rate of the marker. * \param[in] iDim - spatial component * \param[in] val - translational velocity - * \return Translational velocity of the mesh. */ - void SetMarkerTranslation_Rate(unsigned short iMarkerMoving, unsigned short iDim, su2double val) const { MarkerTranslation_Rate[3*iMarkerMoving + iDim] = val;} + void SetMarkerTranslationRate(unsigned short iMarkerMoving, unsigned short iDim, su2double val) { + MarkerTranslation_Rate[3 * iMarkerMoving + iDim] = val; + } /*! * \brief Get the rotation rate of the mesh. @@ -5969,14 +5970,16 @@ class CConfig { * \return Rotation velocity of the marker. */ su2double GetMarkerRotationRate(unsigned short iMarkerMoving, unsigned short iDim) const { return MarkerRotation_Rate[3*iMarkerMoving + iDim];} + /*! * \brief Set the rotation rate of the marker. - * \param[in] iMarkerMoving - Index of the moving marker (as specified in Marker_Moving) + * \param[in] iMarkerMoving - Index of the moving marker (as specified in Marker_Moving) * \param[in] iDim - spatial component * \param[in] val - Rotational velocity - */ - void SetMarkerRotation_Rate(unsigned short iMarkerMoving, unsigned short iDim, su2double val) const { MarkerRotation_Rate[3*iMarkerMoving + iDim] = val;} + void SetMarkerRotation_Rate(unsigned short iMarkerMoving, unsigned short iDim, su2double val) { + MarkerRotation_Rate[3 * iMarkerMoving + iDim] = val; + } /*! * \brief Get the pitching rate of the mesh. diff --git a/SU2_CFD/include/drivers/CDriver.hpp b/SU2_CFD/include/drivers/CDriver.hpp index 928753dc019..74bc0c11059 100644 --- a/SU2_CFD/include/drivers/CDriver.hpp +++ b/SU2_CFD/include/drivers/CDriver.hpp @@ -542,15 +542,16 @@ class CDriver : public CDriverBase { * \param[in] rot_y - Value of Angular velocity about y-axes. * \param[in] rot_z - Value of Angular velocity about z-axes. */ - void SetMarkerRotationRate(short int iMarker, passivedouble rot_x, passivedouble rot_y, passivedouble rot_z); - /*! - * \brief Set the moving wall marker rotation rates. + void SetMarkerRotationRate(unsigned short iMarker, passivedouble rot_x, passivedouble rot_y, passivedouble rot_z); + + /*! + * \brief Set the moving wall marker translation rates. * \param[in] iMaker - Index of moving wall marker. - * \param[in] vel_x - Value of velocity about x-axes. - * \param[in] vel_y - Value of velocity about y-axes. - * \param[in] vel_z - Value of velocity about z-axes. + * \param[in] vel_x - Value of velocity along x-axis. + * \param[in] vel_y - Value of velocity along y-axis. + * \param[in] vel_z - Value of velocity along z-axis. */ - void SetMarkerTranslationRate(short int iMarker, passivedouble vel_x, passivedouble vel_y, passivedouble vel_z); + void SetMarkerTranslationRate(unsigned short iMarker, passivedouble vel_x, passivedouble vel_y, passivedouble vel_z); /// \} }; diff --git a/SU2_CFD/src/iteration/CIteration.cpp b/SU2_CFD/src/iteration/CIteration.cpp index 8224b45950a..15d8106981d 100644 --- a/SU2_CFD/src/iteration/CIteration.cpp +++ b/SU2_CFD/src/iteration/CIteration.cpp @@ -88,8 +88,6 @@ void CIteration::SetGrid_Movement(CGeometry** geometry, CSurfaceMovement* surfac } break; - - } if (config->GetSurface_Movement(AEROELASTIC) || config->GetSurface_Movement(AEROELASTIC_RIGID_MOTION) || config->GetSurface_Movement(MOVING_WALL)) { @@ -114,9 +112,10 @@ void CIteration::SetGrid_Movement(CGeometry** geometry, CSurfaceMovement* surfac grid_movement->UpdateMultiGrid(geometry, config); } - if(config->GetSurface_Movement(MOVING_WALL)){ - geometry[MESH_0]->SetWallVelocity(config, true); - + if (config->GetSurface_Movement(MOVING_WALL)) { + for (auto iMGlevel = 0u; iMGlevel <= config->GetnMGLevels(); iMGlevel++) { + geometry[iMGlevel]->SetWallVelocity(config, iMGlevel == 0u); + } } } diff --git a/SU2_CFD/src/python_wrapper_structure.cpp b/SU2_CFD/src/python_wrapper_structure.cpp index ee7ae45a3e7..155ec1e216d 100644 --- a/SU2_CFD/src/python_wrapper_structure.cpp +++ b/SU2_CFD/src/python_wrapper_structure.cpp @@ -166,14 +166,16 @@ void CDriver::SetRotationRate(passivedouble rot_x, passivedouble rot_y, passived config_container[iZone]->SetRotation_Rate(2, rot_z); } } -void CDriver::SetMarkerRotationRate(short int iMarker, passivedouble rot_x, passivedouble rot_y, passivedouble rot_z){ + +void CDriver::SetMarkerRotationRate(unsigned short iMarker, passivedouble rot_x, passivedouble rot_y, passivedouble rot_z) { for (iZone = 0; iZone < nZone; iZone++) { config_container[iZone]->SetMarkerRotation_Rate(iMarker, 0, rot_x); config_container[iZone]->SetMarkerRotation_Rate(iMarker, 1, rot_y); config_container[iZone]->SetMarkerRotation_Rate(iMarker, 2, rot_z); } } -void CDriver::SetMarkerTranslationRate(short int iMarker, passivedouble vel_x, passivedouble vel_y, passivedouble vel_z){ + +void CDriver::SetMarkerTranslationRate(unsigned short iMarker, passivedouble vel_x, passivedouble vel_y, passivedouble vel_z) { for (iZone = 0; iZone < nZone; iZone++) { config_container[iZone]->SetMarkerTranslation_Rate(iMarker, 0, vel_x); config_container[iZone]->SetMarkerTranslation_Rate(iMarker, 1, vel_y); From eb21853c7b28660cb663e00cd4abb5fc447cc60d Mon Sep 17 00:00:00 2001 From: Pedro Gomes <38071223+pcarruscag@users.noreply.github.com> Date: Sat, 29 Jul 2023 17:13:45 -0700 Subject: [PATCH 07/48] Apply suggestions from code review --- Common/include/CConfig.hpp | 2 +- SU2_CFD/src/python_wrapper_structure.cpp | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/Common/include/CConfig.hpp b/Common/include/CConfig.hpp index 256444b7f37..56987e00989 100644 --- a/Common/include/CConfig.hpp +++ b/Common/include/CConfig.hpp @@ -5977,7 +5977,7 @@ class CConfig { * \param[in] iDim - spatial component * \param[in] val - Rotational velocity */ - void SetMarkerRotation_Rate(unsigned short iMarkerMoving, unsigned short iDim, su2double val) { + void SetMarkerRotationRate(unsigned short iMarkerMoving, unsigned short iDim, su2double val) { MarkerRotation_Rate[3 * iMarkerMoving + iDim] = val; } diff --git a/SU2_CFD/src/python_wrapper_structure.cpp b/SU2_CFD/src/python_wrapper_structure.cpp index 155ec1e216d..61945348c4b 100644 --- a/SU2_CFD/src/python_wrapper_structure.cpp +++ b/SU2_CFD/src/python_wrapper_structure.cpp @@ -169,17 +169,17 @@ void CDriver::SetRotationRate(passivedouble rot_x, passivedouble rot_y, passived void CDriver::SetMarkerRotationRate(unsigned short iMarker, passivedouble rot_x, passivedouble rot_y, passivedouble rot_z) { for (iZone = 0; iZone < nZone; iZone++) { - config_container[iZone]->SetMarkerRotation_Rate(iMarker, 0, rot_x); - config_container[iZone]->SetMarkerRotation_Rate(iMarker, 1, rot_y); - config_container[iZone]->SetMarkerRotation_Rate(iMarker, 2, rot_z); + config_container[iZone]->SetMarkerRotationRate(iMarker, 0, rot_x); + config_container[iZone]->SetMarkerRotationRate(iMarker, 1, rot_y); + config_container[iZone]->SetMarkerRotationRate(iMarker, 2, rot_z); } } void CDriver::SetMarkerTranslationRate(unsigned short iMarker, passivedouble vel_x, passivedouble vel_y, passivedouble vel_z) { for (iZone = 0; iZone < nZone; iZone++) { - config_container[iZone]->SetMarkerTranslation_Rate(iMarker, 0, vel_x); - config_container[iZone]->SetMarkerTranslation_Rate(iMarker, 1, vel_y); - config_container[iZone]->SetMarkerTranslation_Rate(iMarker, 2, vel_z); + config_container[iZone]->SetMarkerTranslationRate(iMarker, 0, vel_x); + config_container[iZone]->SetMarkerTranslationRate(iMarker, 1, vel_y); + config_container[iZone]->SetMarkerTranslationRate(iMarker, 2, vel_z); } } From 32dcd85b1f2118fbf0ae3607c82b7a037b682378 Mon Sep 17 00:00:00 2001 From: Pedro Gomes <38071223+pcarruscag@users.noreply.github.com> Date: Thu, 26 Oct 2023 13:38:43 +0100 Subject: [PATCH 08/48] Apply suggestions from code review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Kürşat Yurt <57598663+kursatyurt@users.noreply.github.com> --- SU2_CFD/include/drivers/CDriver.hpp | 1 + SU2_CFD/src/python_wrapper_structure.cpp | 16 ++++++---------- TestCases/py_wrapper/rotating_cylinder/run.py | 5 ++--- 3 files changed, 9 insertions(+), 13 deletions(-) diff --git a/SU2_CFD/include/drivers/CDriver.hpp b/SU2_CFD/include/drivers/CDriver.hpp index 74bc0c11059..b2bafc35ea6 100644 --- a/SU2_CFD/include/drivers/CDriver.hpp +++ b/SU2_CFD/include/drivers/CDriver.hpp @@ -535,6 +535,7 @@ class CDriver : public CDriverBase { * \param[in] rot_z - Value of Angular velocity about z-axes. */ void SetRotationRate(passivedouble rot_x, passivedouble rot_y, passivedouble rot_z); + /*! * \brief Set the moving wall marker rotation rates. * \param[in] iMaker - Index of moving wall marker. diff --git a/SU2_CFD/src/python_wrapper_structure.cpp b/SU2_CFD/src/python_wrapper_structure.cpp index 3e18df5a84d..ede28e36943 100644 --- a/SU2_CFD/src/python_wrapper_structure.cpp +++ b/SU2_CFD/src/python_wrapper_structure.cpp @@ -168,18 +168,14 @@ void CDriver::SetRotationRate(passivedouble rot_x, passivedouble rot_y, passived } void CDriver::SetMarkerRotationRate(unsigned short iMarker, passivedouble rot_x, passivedouble rot_y, passivedouble rot_z) { - for (iZone = 0; iZone < nZone; iZone++) { - config_container[iZone]->SetMarkerRotationRate(iMarker, 0, rot_x); - config_container[iZone]->SetMarkerRotationRate(iMarker, 1, rot_y); - config_container[iZone]->SetMarkerRotationRate(iMarker, 2, rot_z); - } + config_container[selected_zone]->SetMarkerRotationRate(iMarker, 0, rot_x); + config_container[selected_zone]->SetMarkerRotationRate(iMarker, 1, rot_y); + config_container[selected_zone]->SetMarkerRotationRate(iMarker, 2, rot_z); } void CDriver::SetMarkerTranslationRate(unsigned short iMarker, passivedouble vel_x, passivedouble vel_y, passivedouble vel_z) { - for (iZone = 0; iZone < nZone; iZone++) { - config_container[iZone]->SetMarkerTranslationRate(iMarker, 0, vel_x); - config_container[iZone]->SetMarkerTranslationRate(iMarker, 1, vel_y); - config_container[iZone]->SetMarkerTranslationRate(iMarker, 2, vel_z); - } + config_container[selected_zone]->SetMarkerTranslationRate(iMarker, 0, vel_x); + config_container[selected_zone]->SetMarkerTranslationRate(iMarker, 1, vel_y); + config_container[selected_zone]->SetMarkerTranslationRate(iMarker, 2, vel_z); } diff --git a/TestCases/py_wrapper/rotating_cylinder/run.py b/TestCases/py_wrapper/rotating_cylinder/run.py index cbf2d968686..737c3dd74ee 100644 --- a/TestCases/py_wrapper/rotating_cylinder/run.py +++ b/TestCases/py_wrapper/rotating_cylinder/run.py @@ -13,9 +13,8 @@ SU2Driver = pysu2.CSinglezoneDriver("spinning_cylinder.cfg",1, comm) -for i in range(n_of_steps): - - SU2Driver.SetMarkerRotationRate(0,0,0,rotation_vector[n_of_steps-i-1]) +for i, rate in enumerate(rotation_vector): + SU2Driver.SetMarkerRotationRate(0,0,0,rate) SU2Driver.Preprocess(i) SU2Driver.Run() SU2Driver.Postprocess() From a7f4e92312a637d27a2b5b1831bab15a81bd9e21 Mon Sep 17 00:00:00 2001 From: Filip Hahs Date: Sat, 4 Nov 2023 09:49:52 +0100 Subject: [PATCH 09/48] chaged tests to remove numerical noise, remove unused lines, add name to authors --- AUTHORS.md | 1 + TestCases/hybrid_regression.py | 6 +++--- TestCases/parallel_regression.py | 4 ++-- TestCases/py_wrapper/rotating_cylinder/run.py | 8 +------- TestCases/serial_regression.py | 4 ++-- 5 files changed, 9 insertions(+), 14 deletions(-) diff --git a/AUTHORS.md b/AUTHORS.md index f47640de49a..f8c364f411b 100644 --- a/AUTHORS.md +++ b/AUTHORS.md @@ -71,6 +71,7 @@ Eduardo Molina Edwin van der Weide Ethan Alan Hereth Florian Dittmann +Filip Hahs Francesco Poli Francisco D. Palacios Gaurav Bansal diff --git a/TestCases/hybrid_regression.py b/TestCases/hybrid_regression.py index 801ca167f31..11743264640 100644 --- a/TestCases/hybrid_regression.py +++ b/TestCases/hybrid_regression.py @@ -436,7 +436,7 @@ def main(): cavity.cfg_dir = "moving_wall/cavity" cavity.cfg_file = "lam_cavity.cfg" cavity.test_iter = 25 - cavity.test_vals = [-5.627934, -0.164469, 0.052000, 2.547063] + cavity.test_vals = [-5.627868, -0.164404, 0.053310, 2.545839] test_list.append(cavity) # Spinning cylinder @@ -444,8 +444,8 @@ def main(): spinning_cylinder.cfg_dir = "moving_wall/spinning_cylinder" spinning_cylinder.cfg_file = "spinning_cylinder.cfg" spinning_cylinder.test_iter = 25 - spinning_cylinder.test_vals = [-8.001291, -2.607959, 1.501321, 1.488559] - spinning_cylinder.test_vals_aarch64 = [-8.001291, -2.607959, 1.501321, 1.488559] + spinning_cylinder.test_vals = [-8.006541, -2.609759, 1.495662, 1.486341] + spinning_cylinder.test_vals_aarch64 = [-8.006541, -2.609759, 1.495662, 1.486341] test_list.append(spinning_cylinder) ###################################### diff --git a/TestCases/parallel_regression.py b/TestCases/parallel_regression.py index f26049592b8..f4f3e4ab7b2 100644 --- a/TestCases/parallel_regression.py +++ b/TestCases/parallel_regression.py @@ -915,7 +915,7 @@ def main(): cavity.cfg_dir = "moving_wall/cavity" cavity.cfg_file = "lam_cavity.cfg" cavity.test_iter = 25 - cavity.test_vals = [-5.611007, -0.146826, 1.113206, 1.491678] + cavity.test_vals = [-5.610928, -0.146749, 1.114461, 1.490381] test_list.append(cavity) # Spinning cylinder @@ -923,7 +923,7 @@ def main(): spinning_cylinder.cfg_dir = "moving_wall/spinning_cylinder" spinning_cylinder.cfg_file = "spinning_cylinder.cfg" spinning_cylinder.test_iter = 25 - spinning_cylinder.test_vals = [-7.802803, -2.362844, 1.687705, 1.519676] + spinning_cylinder.test_vals = [-7.806016, -2.364954, 1.683365, 1.517059] test_list.append(spinning_cylinder) ###################################### diff --git a/TestCases/py_wrapper/rotating_cylinder/run.py b/TestCases/py_wrapper/rotating_cylinder/run.py index 737c3dd74ee..537cdcb696e 100644 --- a/TestCases/py_wrapper/rotating_cylinder/run.py +++ b/TestCases/py_wrapper/rotating_cylinder/run.py @@ -1,16 +1,10 @@ import pysu2 # imports the SU2 wrapped module -from math import * from mpi4py import MPI import numpy as np comm = MPI.COMM_WORLD rank = comm.Get_rank() -ad_com = MPI.COMM_WORLD -rank_ad = ad_com.Get_rank() -n_of_steps = 10 -rotation_vector = np.zeros(n_of_steps)+20 -rotation_vector[5:9] = -rotation_vector[5:9] - +rotation_vector = np.linspace(0,20,10) SU2Driver = pysu2.CSinglezoneDriver("spinning_cylinder.cfg",1, comm) for i, rate in enumerate(rotation_vector): diff --git a/TestCases/serial_regression.py b/TestCases/serial_regression.py index a8486bc11ea..1ad3263d2e3 100644 --- a/TestCases/serial_regression.py +++ b/TestCases/serial_regression.py @@ -750,7 +750,7 @@ def main(): cavity.cfg_dir = "moving_wall/cavity" cavity.cfg_file = "lam_cavity.cfg" cavity.test_iter = 25 - cavity.test_vals = [-5.627934, -0.164470, 0.051972, 2.547039] + cavity.test_vals = [ -5.627868, -0.164405, 0.053283, 2.545817] test_list.append(cavity) # Spinning cylinder @@ -758,7 +758,7 @@ def main(): spinning_cylinder.cfg_dir = "moving_wall/spinning_cylinder" spinning_cylinder.cfg_file = "spinning_cylinder.cfg" spinning_cylinder.test_iter = 25 - spinning_cylinder.test_vals = [-7.889994, -2.469385, 1.708162, 1.670039] + spinning_cylinder.test_vals = [-7.892807, -2.467378, 1.702819, 1.669208] test_list.append(spinning_cylinder) ###################################### From d0486c1823ff5bcbe98def4d4cf61fd23a0e14c3 Mon Sep 17 00:00:00 2001 From: Filip Hahs Date: Sat, 4 Nov 2023 11:46:22 +0100 Subject: [PATCH 10/48] change fsi serial regression test --- TestCases/serial_regression.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/TestCases/serial_regression.py b/TestCases/serial_regression.py index 1ad3263d2e3..15d9f544ab4 100644 --- a/TestCases/serial_regression.py +++ b/TestCases/serial_regression.py @@ -1066,7 +1066,7 @@ def main(): airfoilRBF.cfg_dir = "fea_fsi/Airfoil_RBF" airfoilRBF.cfg_file = "config.cfg" airfoilRBF.test_iter = 1 - airfoilRBF.test_vals = [1.000000, -2.786183, -4.977959] + airfoilRBF.test_vals = [ 1.000000, -2.786186, -4.977944] airfoilRBF.multizone = True test_list.append(airfoilRBF) From 4e36eee2f72714fb878ff3ae515a3c8ca7ea3c83 Mon Sep 17 00:00:00 2001 From: Filip Hahs Date: Fri, 10 Nov 2023 16:08:29 +0100 Subject: [PATCH 11/48] more test changes --- TestCases/hybrid_regression_AD.py | 4 ++-- TestCases/serial_regression.py | 2 +- externals/codi | 2 +- externals/mel | 2 +- subprojects/CoolProp | 2 +- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/TestCases/hybrid_regression_AD.py b/TestCases/hybrid_regression_AD.py index a2243e14e24..f333c9ba7a9 100644 --- a/TestCases/hybrid_regression_AD.py +++ b/TestCases/hybrid_regression_AD.py @@ -253,8 +253,8 @@ def main(): pywrapper_CFD_AD_MeshDisp.cfg_dir = "py_wrapper/disc_adj_flow/mesh_disp_sens" pywrapper_CFD_AD_MeshDisp.cfg_file = "configAD_flow.cfg" pywrapper_CFD_AD_MeshDisp.test_iter = 1000 - pywrapper_CFD_AD_MeshDisp.test_vals = [30.000000, -2.520967, 1.375188, 0.000000] #last 4 columns - pywrapper_CFD_AD_MeshDisp.test_vals_aarch64 = [30.000000, -2.516536, 1.386443, 0.000000] + pywrapper_CFD_AD_MeshDisp.test_vals = [30.000000, -2.521399, 1.372319, 0.000000] #last 4 columns + pywrapper_CFD_AD_MeshDisp.test_vals_aarch64 = [30.000000, -2.521399, 1.372319, 0.000000] pywrapper_CFD_AD_MeshDisp.command = TestCase.Command(exec = "python", param = "run_adjoint.py --parallel -f") pywrapper_CFD_AD_MeshDisp.timeout = 1600 pywrapper_CFD_AD_MeshDisp.tol = 1e-4 diff --git a/TestCases/serial_regression.py b/TestCases/serial_regression.py index 15d9f544ab4..b6d107b6a1b 100644 --- a/TestCases/serial_regression.py +++ b/TestCases/serial_regression.py @@ -1066,7 +1066,7 @@ def main(): airfoilRBF.cfg_dir = "fea_fsi/Airfoil_RBF" airfoilRBF.cfg_file = "config.cfg" airfoilRBF.test_iter = 1 - airfoilRBF.test_vals = [ 1.000000, -2.786186, -4.977944] + airfoilRBF.test_vals = [1.000000, -2.786183, -4.977961] airfoilRBF.multizone = True test_list.append(airfoilRBF) diff --git a/externals/codi b/externals/codi index 0ad036f2c82..17232fed052 160000 --- a/externals/codi +++ b/externals/codi @@ -1 +1 @@ -Subproject commit 0ad036f2c8254fa7b77180a443d99248c047c877 +Subproject commit 17232fed05245dbb8f04a31e274a02d53458c75c diff --git a/externals/mel b/externals/mel index 46205ab019e..2484cd3258e 160000 --- a/externals/mel +++ b/externals/mel @@ -1 +1 @@ -Subproject commit 46205ab019e5224559091375a6d71aabae6bc5b9 +Subproject commit 2484cd3258ef800a10e361016cb341834ee7930b diff --git a/subprojects/CoolProp b/subprojects/CoolProp index bafdea1f39e..0ce42fcf3bb 160000 --- a/subprojects/CoolProp +++ b/subprojects/CoolProp @@ -1 +1 @@ -Subproject commit bafdea1f39ee873a6bb9833e3a21fe41f90b85e8 +Subproject commit 0ce42fcf3bb2c373512bc825a4f0c1973a78f307 From a009c2e271146fc47dfb5c764a226ed15bb79f43 Mon Sep 17 00:00:00 2001 From: Filip Hahs Date: Sun, 12 Nov 2023 16:15:00 +0100 Subject: [PATCH 12/48] Revert "more test changes" This reverts commit 4e36eee2f72714fb878ff3ae515a3c8ca7ea3c83. --- TestCases/hybrid_regression_AD.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/TestCases/hybrid_regression_AD.py b/TestCases/hybrid_regression_AD.py index 8185eaeba8f..cf419bde4e9 100644 --- a/TestCases/hybrid_regression_AD.py +++ b/TestCases/hybrid_regression_AD.py @@ -253,8 +253,8 @@ def main(): pywrapper_CFD_AD_MeshDisp.cfg_dir = "py_wrapper/disc_adj_flow/mesh_disp_sens" pywrapper_CFD_AD_MeshDisp.cfg_file = "configAD_flow.cfg" pywrapper_CFD_AD_MeshDisp.test_iter = 1000 - pywrapper_CFD_AD_MeshDisp.test_vals = [30.000000, -2.521399, 1.372319, 0.000000] #last 4 columns - pywrapper_CFD_AD_MeshDisp.test_vals_aarch64 = [30.000000, -2.521399, 1.372319, 0.000000] + pywrapper_CFD_AD_MeshDisp.test_vals = [30.000000, -2.520967, 1.375188, 0.000000] #last 4 columns + pywrapper_CFD_AD_MeshDisp.test_vals_aarch64 = [30.000000, -2.516536, 1.386443, 0.000000] pywrapper_CFD_AD_MeshDisp.command = TestCase.Command(exec = "python", param = "run_adjoint.py --parallel -f") pywrapper_CFD_AD_MeshDisp.timeout = 1600 pywrapper_CFD_AD_MeshDisp.tol = 1e-3 From d0a280ca768f99a0a2ecee74bb222f6e8cbe5f08 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johannes=20Bl=C3=BChdorn?= Date: Tue, 31 Oct 2023 12:39:57 +0100 Subject: [PATCH 13/48] Allow up to 255 colors. --- Common/include/toolboxes/graph_toolbox.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Common/include/toolboxes/graph_toolbox.hpp b/Common/include/toolboxes/graph_toolbox.hpp index c5929e8f8da..f1c0854ce27 100644 --- a/Common/include/toolboxes/graph_toolbox.hpp +++ b/Common/include/toolboxes/graph_toolbox.hpp @@ -484,7 +484,7 @@ T createNaturalColoring(Index_t numInnerIndexes) { * \param[out] indexColor - Optional, vector with colors given to the outer indices. * \return Coloring in the same type of the input pattern. */ -template +template T colorSparsePattern(const T& pattern, size_t groupSize = 1, bool balanceColors = false, std::vector* indexColor = nullptr) { static_assert(std::is_integral::value, ""); From 12c63c72133c13e14bf516443b27759ea73d31c8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johannes=20Bl=C3=BChdorn?= Date: Tue, 31 Oct 2023 12:49:58 +0100 Subject: [PATCH 14/48] Report on the number of colors and the efficiency. --- SU2_CFD/include/solvers/CFVMFlowSolverBase.inl | 3 +++ 1 file changed, 3 insertions(+) diff --git a/SU2_CFD/include/solvers/CFVMFlowSolverBase.inl b/SU2_CFD/include/solvers/CFVMFlowSolverBase.inl index 40af46827be..ccf939f1bf1 100644 --- a/SU2_CFD/include/solvers/CFVMFlowSolverBase.inl +++ b/SU2_CFD/include/solvers/CFVMFlowSolverBase.inl @@ -324,6 +324,9 @@ void CFVMFlowSolverBase::HybridParallelInitialization(const CConfig& confi << "\n The memory usage of the discrete adjoint solver is higher when using the fallback." #endif << endl; + } else { + cout << "Rank " << SU2_MPI::GetRank() << " uses " << coloring.getOuterSize() << " colors, " + << parallelEff << "efficiency." << endl; } } From 6d34de3428d8b703232d8a68397e71552010c53f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johannes=20Bl=C3=BChdorn?= Date: Tue, 31 Oct 2023 16:47:53 +0100 Subject: [PATCH 15/48] Add space. --- SU2_CFD/include/solvers/CFVMFlowSolverBase.inl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SU2_CFD/include/solvers/CFVMFlowSolverBase.inl b/SU2_CFD/include/solvers/CFVMFlowSolverBase.inl index ccf939f1bf1..bee63030f7d 100644 --- a/SU2_CFD/include/solvers/CFVMFlowSolverBase.inl +++ b/SU2_CFD/include/solvers/CFVMFlowSolverBase.inl @@ -326,7 +326,7 @@ void CFVMFlowSolverBase::HybridParallelInitialization(const CConfig& confi << endl; } else { cout << "Rank " << SU2_MPI::GetRank() << " uses " << coloring.getOuterSize() << " colors, " - << parallelEff << "efficiency." << endl; + << parallelEff << " efficiency." << endl; } } From 766d7b1426ec980f06f84de25989073b1b3aa62e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johannes=20Bl=C3=BChdorn?= Date: Fri, 27 Oct 2023 12:07:46 +0200 Subject: [PATCH 16/48] Maximize color group size per rank. --- Common/src/geometry/CGeometry.cpp | 36 +++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/Common/src/geometry/CGeometry.cpp b/Common/src/geometry/CGeometry.cpp index 9ed1804186a..e912c5aa68f 100644 --- a/Common/src/geometry/CGeometry.cpp +++ b/Common/src/geometry/CGeometry.cpp @@ -3637,6 +3637,42 @@ const CCompressedSparsePatternUL& CGeometry::GetEdgeColoring(su2double* efficien /*--- Color the edges. ---*/ constexpr bool balanceColors = true; + + /* find an efficient coloring with maximum possible color group size */ + auto upperEdgeColorGroupSize = edgeColorGroupSize + 1; /* upper bound that does not work */ + auto nextEdgeColorGroupSize = edgeColorGroupSize; /* next value that we are going to try */ + auto lowerEdgeColorGroupSize = 1; /* lower bound that is known to work */ + + while (true) { + auto currentEdgeColoring = colorSparsePattern(pattern, nextEdgeColorGroupSize, balanceColors); + + /* if the coloring fails, reduce the color group size */ + if (currentEdgeColoring.empty()) { + upperEdgeColorGroupSize = nextEdgeColorGroupSize; + nextEdgeColorGroupSize = lowerEdgeColorGroupSize + (upperEdgeColorGroupSize - lowerEdgeColorGroupSize) / 2; + continue; + } + + auto currentEfficiency = coloringEfficiency(currentEdgeColoring, omp_get_max_threads(), nextEdgeColorGroupSize); + + /* if the coloring is not efficient, reduce the color group size */ + if (currentEfficiency < COLORING_EFF_THRESH) { + upperEdgeColorGroupSize = nextEdgeColorGroupSize; + } + /* otherwise, try to enlarge the color group size */ + else { + lowerEdgeColorGroupSize = nextEdgeColorGroupSize; + } + auto increment = (upperEdgeColorGroupSize - lowerEdgeColorGroupSize) / 2; + + if (increment == 0) { + break; + } + + nextEdgeColorGroupSize = lowerEdgeColorGroupSize + increment; + } + + edgeColorGroupSize = lowerEdgeColorGroupSize; edgeColoring = colorSparsePattern(pattern, edgeColorGroupSize, balanceColors); /*--- If the coloring fails use the natural coloring. This is a From c454bd84eedbb7101de50fdf8bfd62f4c59b7119 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johannes=20Bl=C3=BChdorn?= Date: Tue, 31 Oct 2023 19:27:12 +0100 Subject: [PATCH 17/48] Add output about chosen color group size. --- SU2_CFD/include/solvers/CFVMFlowSolverBase.inl | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/SU2_CFD/include/solvers/CFVMFlowSolverBase.inl b/SU2_CFD/include/solvers/CFVMFlowSolverBase.inl index bee63030f7d..83eda476613 100644 --- a/SU2_CFD/include/solvers/CFVMFlowSolverBase.inl +++ b/SU2_CFD/include/solvers/CFVMFlowSolverBase.inl @@ -325,8 +325,10 @@ void CFVMFlowSolverBase::HybridParallelInitialization(const CConfig& confi #endif << endl; } else { - cout << "Rank " << SU2_MPI::GetRank() << " uses " << coloring.getOuterSize() << " colors, " - << parallelEff << " efficiency." << endl; + cout << "Rank " << SU2_MPI::GetRank() << endl + << "\tnumber of colors " << coloring.getOuterSize() << endl + << "\tcolor group size " << geometry.GetEdgeColorGroupSize() << endl + << "\tefficiency " << parallelEff << endl; } } From 70bf19f28a541374563b0d72d67345f9ef995c00 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johannes=20Bl=C3=BChdorn?= Date: Mon, 13 Nov 2023 17:04:43 +0100 Subject: [PATCH 18/48] Aggregated output of coloring properties on master rank. --- .../include/solvers/CFVMFlowSolverBase.inl | 26 ++++++++++++++++--- 1 file changed, 22 insertions(+), 4 deletions(-) diff --git a/SU2_CFD/include/solvers/CFVMFlowSolverBase.inl b/SU2_CFD/include/solvers/CFVMFlowSolverBase.inl index 83eda476613..14368a547d6 100644 --- a/SU2_CFD/include/solvers/CFVMFlowSolverBase.inl +++ b/SU2_CFD/include/solvers/CFVMFlowSolverBase.inl @@ -325,10 +325,28 @@ void CFVMFlowSolverBase::HybridParallelInitialization(const CConfig& confi #endif << endl; } else { - cout << "Rank " << SU2_MPI::GetRank() << endl - << "\tnumber of colors " << coloring.getOuterSize() << endl - << "\tcolor group size " << geometry.GetEdgeColorGroupSize() << endl - << "\tefficiency " << parallelEff << endl; + if (SU2_MPI::GetRank() == MASTER_NODE) { + cout << "All ranks use edge coloring." << endl; + } + } + + su2double coloredParallelEff = ReducerStrategy ? 1.0 : parallelEff; + su2double minColoredParallelEff = 1.0; + SU2_MPI::Reduce(&coloredParallelEff, &minColoredParallelEff, 1, MPI_DOUBLE, MPI_MIN, MASTER_NODE, SU2_MPI::GetComm()); + + unsigned long coloredNumColors = ReducerStrategy ? 0 : coloring.getOuterSize(); + unsigned long maxColoredNumColors = 0; + SU2_MPI::Reduce(&coloredNumColors, &maxColoredNumColors, 1, MPI_UNSIGNED_LONG, MPI_MAX, MASTER_NODE, SU2_MPI::GetComm()); + + unsigned long coloredEdgeColorGroupSize = ReducerStrategy ? 1 << 30 : geometry.GetEdgeColorGroupSize(); + unsigned long minColoredEdgeColorGroupSize = 1 << 30; + SU2_MPI::Reduce(&coloredEdgeColorGroupSize, &minColoredEdgeColorGroupSize, 1, MPI_UNSIGNED_LONG, MPI_MIN, MASTER_NODE, SU2_MPI::GetComm()); + + if (SU2_MPI::GetRank() == MASTER_NODE) { + cout << "Among the ranks that use edge coloring,\n" + << " the minimum efficiency is " << minColoredParallelEff << ",\n" + << " the maximum number of colors is " << maxColoredNumColors << ",\n" + << " the minimum edge color group size is " << minColoredEdgeColorGroupSize << "." << endl; } } From 8a155914c7065efc8cf70c84284b63f92213db91 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johannes=20Bl=C3=BChdorn?= Date: Tue, 14 Nov 2023 13:32:13 +0100 Subject: [PATCH 19/48] Make adaptive edge color group sizes optional. --- Common/include/geometry/CGeometry.hpp | 6 ++- Common/src/geometry/CGeometry.cpp | 58 ++++++++++++++------------- 2 files changed, 36 insertions(+), 28 deletions(-) diff --git a/Common/include/geometry/CGeometry.hpp b/Common/include/geometry/CGeometry.hpp index f8111060725..4af65411cc2 100644 --- a/Common/include/geometry/CGeometry.hpp +++ b/Common/include/geometry/CGeometry.hpp @@ -1720,10 +1720,14 @@ class CGeometry { /*! * \brief Get the edge coloring. * \note This method computes the coloring if that has not been done yet. + * \note Can be instructed to determine and use the maximum edge color group size between 1 and + * CGeometry::edgeColorGroupSize that yields a coloring that is at least as efficient as #COLORING_EFF_THRESH. * \param[out] efficiency - optional output of the coloring efficiency. + * \param[in] maximizeEdgeColorGroupSize - use the maximum edge color group size that gives an efficient coloring. * \return Reference to the coloring. */ - const CCompressedSparsePatternUL& GetEdgeColoring(su2double* efficiency = nullptr); + const CCompressedSparsePatternUL& GetEdgeColoring(su2double* efficiency = nullptr, + bool maximizeEdgeColorGroupSize = false); /*! * \brief Force the natural (sequential) edge coloring. diff --git a/Common/src/geometry/CGeometry.cpp b/Common/src/geometry/CGeometry.cpp index e912c5aa68f..ffa6a37585c 100644 --- a/Common/src/geometry/CGeometry.cpp +++ b/Common/src/geometry/CGeometry.cpp @@ -3609,7 +3609,7 @@ const su2vector& CGeometry::GetTransposeSparsePatternMap(Connecti return pattern.transposePtr(); } -const CCompressedSparsePatternUL& CGeometry::GetEdgeColoring(su2double* efficiency) { +const CCompressedSparsePatternUL& CGeometry::GetEdgeColoring(su2double* efficiency, bool maximizeEdgeColorGroupSize) { /*--- Check for dry run mode with dummy geometry. ---*/ if (nEdge == 0) return edgeColoring; @@ -3638,41 +3638,45 @@ const CCompressedSparsePatternUL& CGeometry::GetEdgeColoring(su2double* efficien /*--- Color the edges. ---*/ constexpr bool balanceColors = true; - /* find an efficient coloring with maximum possible color group size */ - auto upperEdgeColorGroupSize = edgeColorGroupSize + 1; /* upper bound that does not work */ - auto nextEdgeColorGroupSize = edgeColorGroupSize; /* next value that we are going to try */ - auto lowerEdgeColorGroupSize = 1; /* lower bound that is known to work */ + /*--- if requested, find an efficient coloring with maximum color group size (up to edgeColorGroupSize) ---*/ + if (maximizeEdgeColorGroupSize) { + auto upperEdgeColorGroupSize = edgeColorGroupSize + 1; /* upper bound that is deemed too large */ + auto nextEdgeColorGroupSize = edgeColorGroupSize; /* next value that we are going to try */ + auto lowerEdgeColorGroupSize = 1ul; /* lower bound that is known to work */ - while (true) { - auto currentEdgeColoring = colorSparsePattern(pattern, nextEdgeColorGroupSize, balanceColors); + while (true) { + auto currentEdgeColoring = colorSparsePattern(pattern, nextEdgeColorGroupSize, balanceColors); - /* if the coloring fails, reduce the color group size */ - if (currentEdgeColoring.empty()) { - upperEdgeColorGroupSize = nextEdgeColorGroupSize; - nextEdgeColorGroupSize = lowerEdgeColorGroupSize + (upperEdgeColorGroupSize - lowerEdgeColorGroupSize) / 2; - continue; - } + /*--- if the coloring fails, reduce the color group size ---*/ + if (currentEdgeColoring.empty()) { + upperEdgeColorGroupSize = nextEdgeColorGroupSize; + nextEdgeColorGroupSize = lowerEdgeColorGroupSize + (upperEdgeColorGroupSize - lowerEdgeColorGroupSize) / 2; + continue; + } - auto currentEfficiency = coloringEfficiency(currentEdgeColoring, omp_get_max_threads(), nextEdgeColorGroupSize); + su2double currentEfficiency = + coloringEfficiency(currentEdgeColoring, omp_get_max_threads(), nextEdgeColorGroupSize); - /* if the coloring is not efficient, reduce the color group size */ - if (currentEfficiency < COLORING_EFF_THRESH) { - upperEdgeColorGroupSize = nextEdgeColorGroupSize; - } - /* otherwise, try to enlarge the color group size */ - else { - lowerEdgeColorGroupSize = nextEdgeColorGroupSize; - } - auto increment = (upperEdgeColorGroupSize - lowerEdgeColorGroupSize) / 2; + /*--- if the coloring is not efficient, reduce the color group size ---*/ + if (currentEfficiency < COLORING_EFF_THRESH) { + upperEdgeColorGroupSize = nextEdgeColorGroupSize; + } + /*--- otherwise, try to enlarge the color group size ---*/ + else { + lowerEdgeColorGroupSize = nextEdgeColorGroupSize; + } + auto increment = (upperEdgeColorGroupSize - lowerEdgeColorGroupSize) / 2; - if (increment == 0) { - break; + nextEdgeColorGroupSize = lowerEdgeColorGroupSize + increment; + + if (increment == 0) { + break; + } } - nextEdgeColorGroupSize = lowerEdgeColorGroupSize + increment; + edgeColorGroupSize = nextEdgeColorGroupSize; } - edgeColorGroupSize = lowerEdgeColorGroupSize; edgeColoring = colorSparsePattern(pattern, edgeColorGroupSize, balanceColors); /*--- If the coloring fails use the natural coloring. This is a From 21a0e4a52d399b7ae43b6eaf8d05b401eeb63cea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johannes=20Bl=C3=BChdorn?= Date: Tue, 14 Nov 2023 13:54:38 +0100 Subject: [PATCH 20/48] Use adaptive edge color group sizes for the discrete adjoint. --- SU2_CFD/include/solvers/CFVMFlowSolverBase.inl | 7 +++++++ SU2_CFD/include/solvers/CScalarSolver.inl | 6 ++++++ 2 files changed, 13 insertions(+) diff --git a/SU2_CFD/include/solvers/CFVMFlowSolverBase.inl b/SU2_CFD/include/solvers/CFVMFlowSolverBase.inl index 14368a547d6..9d701789afc 100644 --- a/SU2_CFD/include/solvers/CFVMFlowSolverBase.inl +++ b/SU2_CFD/include/solvers/CFVMFlowSolverBase.inl @@ -288,7 +288,14 @@ void CFVMFlowSolverBase::HybridParallelInitialization(const CConfig& confi * sum the fluxes for each cell and set the diagonal of the system matrix. ---*/ su2double parallelEff = 1.0; + +#ifdef CODI_REVERSE_TYPE + /*--- For the discrete adjoint, the reducer strategy is costly. Prefer coloring, possibly with reduced edge color + * group size. Find the maximum edge color group size that yields an efficient coloring. ---*/ + const auto& coloring = geometry.GetEdgeColoring(¶llelEff, true); +#else const auto& coloring = geometry.GetEdgeColoring(¶llelEff); +#endif /*--- The decision to use the strategy is local to each rank. ---*/ ReducerStrategy = parallelEff < COLORING_EFF_THRESH; diff --git a/SU2_CFD/include/solvers/CScalarSolver.inl b/SU2_CFD/include/solvers/CScalarSolver.inl index 5b6415d65b0..21eac22ead8 100644 --- a/SU2_CFD/include/solvers/CScalarSolver.inl +++ b/SU2_CFD/include/solvers/CScalarSolver.inl @@ -46,7 +46,13 @@ CScalarSolver::CScalarSolver(CGeometry* geometry, CConfig* config, #ifdef HAVE_OMP /*--- Get the edge coloring, see notes in CEulerSolver's constructor. ---*/ su2double parallelEff = 1.0; +#ifdef CODI_REVERSE_TYPE + /*--- For the discrete adjoint, the reducer strategy is costly. Prefer coloring, possibly with reduced edge color + * group size. Find the maximum edge color group size that yields an efficient coloring. ---*/ + const auto& coloring = geometry->GetEdgeColoring(¶llelEff, true); +#else const auto& coloring = geometry->GetEdgeColoring(¶llelEff); +#endif ReducerStrategy = parallelEff < COLORING_EFF_THRESH; From d45447ada250c23ef700cf62c920c5e91c031f2f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johannes=20Bl=C3=BChdorn?= Date: Tue, 14 Nov 2023 13:56:19 +0100 Subject: [PATCH 21/48] Larger number of colors for the discrete adjoint. --- Common/include/toolboxes/graph_toolbox.hpp | 2 +- SU2_CFD/include/solvers/CFVMFlowSolverBase.inl | 5 +++-- SU2_CFD/include/solvers/CScalarSolver.inl | 5 +++-- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/Common/include/toolboxes/graph_toolbox.hpp b/Common/include/toolboxes/graph_toolbox.hpp index f1c0854ce27..c5929e8f8da 100644 --- a/Common/include/toolboxes/graph_toolbox.hpp +++ b/Common/include/toolboxes/graph_toolbox.hpp @@ -484,7 +484,7 @@ T createNaturalColoring(Index_t numInnerIndexes) { * \param[out] indexColor - Optional, vector with colors given to the outer indices. * \return Coloring in the same type of the input pattern. */ -template +template T colorSparsePattern(const T& pattern, size_t groupSize = 1, bool balanceColors = false, std::vector* indexColor = nullptr) { static_assert(std::is_integral::value, ""); diff --git a/SU2_CFD/include/solvers/CFVMFlowSolverBase.inl b/SU2_CFD/include/solvers/CFVMFlowSolverBase.inl index 9d701789afc..6d6a76f4ba4 100644 --- a/SU2_CFD/include/solvers/CFVMFlowSolverBase.inl +++ b/SU2_CFD/include/solvers/CFVMFlowSolverBase.inl @@ -291,8 +291,9 @@ void CFVMFlowSolverBase::HybridParallelInitialization(const CConfig& confi #ifdef CODI_REVERSE_TYPE /*--- For the discrete adjoint, the reducer strategy is costly. Prefer coloring, possibly with reduced edge color - * group size. Find the maximum edge color group size that yields an efficient coloring. ---*/ - const auto& coloring = geometry.GetEdgeColoring(¶llelEff, true); + * group size. Find the maximum edge color group size that yields an efficient coloring. Also, allow larger numbers + * of colors. ---*/ + const auto& coloring = geometry.GetEdgeColoring(¶llelEff, true); #else const auto& coloring = geometry.GetEdgeColoring(¶llelEff); #endif diff --git a/SU2_CFD/include/solvers/CScalarSolver.inl b/SU2_CFD/include/solvers/CScalarSolver.inl index 21eac22ead8..3f68ff8d793 100644 --- a/SU2_CFD/include/solvers/CScalarSolver.inl +++ b/SU2_CFD/include/solvers/CScalarSolver.inl @@ -48,8 +48,9 @@ CScalarSolver::CScalarSolver(CGeometry* geometry, CConfig* config, su2double parallelEff = 1.0; #ifdef CODI_REVERSE_TYPE /*--- For the discrete adjoint, the reducer strategy is costly. Prefer coloring, possibly with reduced edge color - * group size. Find the maximum edge color group size that yields an efficient coloring. ---*/ - const auto& coloring = geometry->GetEdgeColoring(¶llelEff, true); + * group size. Find the maximum edge color group size that yields an efficient coloring. Also, allow larger numbers + * of colors. ---*/ + const auto& coloring = geometry->GetEdgeColoring(¶llelEff, true); #else const auto& coloring = geometry->GetEdgeColoring(¶llelEff); #endif From f73946b4d7f91d919087f046e95bda933265520c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johannes=20Bl=C3=BChdorn?= Date: Wed, 15 Nov 2023 14:27:50 +0100 Subject: [PATCH 22/48] Switch between different numbers of colors. --- Common/include/geometry/CGeometry.hpp | 4 +++- Common/src/geometry/CGeometry.cpp | 16 +++++++++++++--- SU2_CFD/include/solvers/CFVMFlowSolverBase.inl | 2 +- SU2_CFD/include/solvers/CScalarSolver.inl | 2 +- 4 files changed, 18 insertions(+), 6 deletions(-) diff --git a/Common/include/geometry/CGeometry.hpp b/Common/include/geometry/CGeometry.hpp index 4af65411cc2..fc5c2931075 100644 --- a/Common/include/geometry/CGeometry.hpp +++ b/Common/include/geometry/CGeometry.hpp @@ -1724,10 +1724,12 @@ class CGeometry { * CGeometry::edgeColorGroupSize that yields a coloring that is at least as efficient as #COLORING_EFF_THRESH. * \param[out] efficiency - optional output of the coloring efficiency. * \param[in] maximizeEdgeColorGroupSize - use the maximum edge color group size that gives an efficient coloring. + * \param[in] largeNumberOfColors - allow up to 255 colors instead of 64 (default) * \return Reference to the coloring. */ const CCompressedSparsePatternUL& GetEdgeColoring(su2double* efficiency = nullptr, - bool maximizeEdgeColorGroupSize = false); + bool maximizeEdgeColorGroupSize = false, + bool largeNumberOfColors = false); /*! * \brief Force the natural (sequential) edge coloring. diff --git a/Common/src/geometry/CGeometry.cpp b/Common/src/geometry/CGeometry.cpp index ffa6a37585c..b88ef3d2198 100644 --- a/Common/src/geometry/CGeometry.cpp +++ b/Common/src/geometry/CGeometry.cpp @@ -3609,7 +3609,8 @@ const su2vector& CGeometry::GetTransposeSparsePatternMap(Connecti return pattern.transposePtr(); } -const CCompressedSparsePatternUL& CGeometry::GetEdgeColoring(su2double* efficiency, bool maximizeEdgeColorGroupSize) { +const CCompressedSparsePatternUL& CGeometry::GetEdgeColoring(su2double* efficiency, bool maximizeEdgeColorGroupSize, + bool largeNumberOfColors) { /*--- Check for dry run mode with dummy geometry. ---*/ if (nEdge == 0) return edgeColoring; @@ -3638,6 +3639,15 @@ const CCompressedSparsePatternUL& CGeometry::GetEdgeColoring(su2double* efficien /*--- Color the edges. ---*/ constexpr bool balanceColors = true; + /*--- lambda to account for different numbers of colors ---*/ + auto getColorSparsePattern = [&](unsigned long edgeColorGroupSize) { + if (largeNumberOfColors) { + return colorSparsePattern(pattern, edgeColorGroupSize, balanceColors); + } else { + return colorSparsePattern(pattern, edgeColorGroupSize, balanceColors); + } + }; + /*--- if requested, find an efficient coloring with maximum color group size (up to edgeColorGroupSize) ---*/ if (maximizeEdgeColorGroupSize) { auto upperEdgeColorGroupSize = edgeColorGroupSize + 1; /* upper bound that is deemed too large */ @@ -3645,7 +3655,7 @@ const CCompressedSparsePatternUL& CGeometry::GetEdgeColoring(su2double* efficien auto lowerEdgeColorGroupSize = 1ul; /* lower bound that is known to work */ while (true) { - auto currentEdgeColoring = colorSparsePattern(pattern, nextEdgeColorGroupSize, balanceColors); + auto currentEdgeColoring = getColorSparsePattern(nextEdgeColorGroupSize); /*--- if the coloring fails, reduce the color group size ---*/ if (currentEdgeColoring.empty()) { @@ -3677,7 +3687,7 @@ const CCompressedSparsePatternUL& CGeometry::GetEdgeColoring(su2double* efficien edgeColorGroupSize = nextEdgeColorGroupSize; } - edgeColoring = colorSparsePattern(pattern, edgeColorGroupSize, balanceColors); + edgeColoring = getColorSparsePattern(edgeColorGroupSize); /*--- If the coloring fails use the natural coloring. This is a * "soft" failure as this "bad" coloring should be detected diff --git a/SU2_CFD/include/solvers/CFVMFlowSolverBase.inl b/SU2_CFD/include/solvers/CFVMFlowSolverBase.inl index 6d6a76f4ba4..3710340d0a7 100644 --- a/SU2_CFD/include/solvers/CFVMFlowSolverBase.inl +++ b/SU2_CFD/include/solvers/CFVMFlowSolverBase.inl @@ -293,7 +293,7 @@ void CFVMFlowSolverBase::HybridParallelInitialization(const CConfig& confi /*--- For the discrete adjoint, the reducer strategy is costly. Prefer coloring, possibly with reduced edge color * group size. Find the maximum edge color group size that yields an efficient coloring. Also, allow larger numbers * of colors. ---*/ - const auto& coloring = geometry.GetEdgeColoring(¶llelEff, true); + const auto& coloring = geometry.GetEdgeColoring(¶llelEff, true, true); #else const auto& coloring = geometry.GetEdgeColoring(¶llelEff); #endif diff --git a/SU2_CFD/include/solvers/CScalarSolver.inl b/SU2_CFD/include/solvers/CScalarSolver.inl index 3f68ff8d793..ea2d6925066 100644 --- a/SU2_CFD/include/solvers/CScalarSolver.inl +++ b/SU2_CFD/include/solvers/CScalarSolver.inl @@ -50,7 +50,7 @@ CScalarSolver::CScalarSolver(CGeometry* geometry, CConfig* config, /*--- For the discrete adjoint, the reducer strategy is costly. Prefer coloring, possibly with reduced edge color * group size. Find the maximum edge color group size that yields an efficient coloring. Also, allow larger numbers * of colors. ---*/ - const auto& coloring = geometry->GetEdgeColoring(¶llelEff, true); + const auto& coloring = geometry->GetEdgeColoring(¶llelEff, true, true); #else const auto& coloring = geometry->GetEdgeColoring(¶llelEff); #endif From 3cc21215140d4be6d29d472101c82940e4acabaf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johannes=20Bl=C3=BChdorn?= Date: Wed, 15 Nov 2023 16:21:56 +0100 Subject: [PATCH 23/48] Further relax hybrid AD python wrapper test tolerances. --- TestCases/hybrid_regression_AD.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/TestCases/hybrid_regression_AD.py b/TestCases/hybrid_regression_AD.py index cf419bde4e9..5ffeb5d71f0 100644 --- a/TestCases/hybrid_regression_AD.py +++ b/TestCases/hybrid_regression_AD.py @@ -242,7 +242,7 @@ def main(): pywrapper_FEA_AD_FlowLoad.test_vals_aarch64 = [-0.131745, -0.553214, -0.000364, -0.003101] pywrapper_FEA_AD_FlowLoad.command = TestCase.Command(exec = "python", param = "run_adjoint.py --parallel -f") pywrapper_FEA_AD_FlowLoad.timeout = 1600 - pywrapper_FEA_AD_FlowLoad.tol = 1e-3 + pywrapper_FEA_AD_FlowLoad.tol = 1e-2 pywrapper_FEA_AD_FlowLoad.new_output = False pywrapper_FEA_AD_FlowLoad.enabled_with_tsan = False test_list.append(pywrapper_FEA_AD_FlowLoad) @@ -257,7 +257,7 @@ def main(): pywrapper_CFD_AD_MeshDisp.test_vals_aarch64 = [30.000000, -2.516536, 1.386443, 0.000000] pywrapper_CFD_AD_MeshDisp.command = TestCase.Command(exec = "python", param = "run_adjoint.py --parallel -f") pywrapper_CFD_AD_MeshDisp.timeout = 1600 - pywrapper_CFD_AD_MeshDisp.tol = 1e-3 + pywrapper_CFD_AD_MeshDisp.tol = 1e-2 pywrapper_CFD_AD_MeshDisp.new_output = False pywrapper_CFD_AD_MeshDisp.enabled_with_tsan = False test_list.append(pywrapper_CFD_AD_MeshDisp) From db1ef8bd4c917ca29305219cc4a647671c4ac46a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johannes=20Bl=C3=BChdorn?= Date: Thu, 16 Nov 2023 15:46:25 +0100 Subject: [PATCH 24/48] Add config option for discrete adjoint coloring relaxation. --- Common/include/CConfig.hpp | 6 ++++++ Common/src/CConfig.cpp | 3 +++ SU2_CFD/include/solvers/CFVMFlowSolverBase.inl | 3 ++- SU2_CFD/include/solvers/CScalarSolver.inl | 3 ++- config_template.cfg | 8 ++++++++ 5 files changed, 21 insertions(+), 2 deletions(-) diff --git a/Common/include/CConfig.hpp b/Common/include/CConfig.hpp index da11f902606..c5999023515 100644 --- a/Common/include/CConfig.hpp +++ b/Common/include/CConfig.hpp @@ -1188,6 +1188,7 @@ class CConfig { string caseName; /*!< \brief Name of the current case */ unsigned long edgeColorGroupSize; /*!< \brief Size of the edge groups colored for OpenMP parallelization of edge loops. */ + bool edgeColoringRelaxDiscAdj; /*!< \brief Allow fallback to smaller edge color group sizes and use more colors for the discrete adjoint. */ INLET_SPANWISE_INTERP Kind_InletInterpolationFunction; /*!brief type of spanwise interpolation function to use for the inlet face. */ INLET_INTERP_TYPE Kind_Inlet_InterpolationType; /*!brief type of spanwise interpolation data to use for the inlet face. */ @@ -9738,6 +9739,11 @@ class CConfig { */ unsigned long GetEdgeColoringGroupSize(void) const { return edgeColorGroupSize; } + /*! + * \brief Check if the discrete adjoint is allowed to relax the coloring, that is, allow smaller edge color group sizes and allow more colors. + */ + bool GetEdgeColoringRelaxDiscAdj(void) const { return edgeColoringRelaxDiscAdj; } + /*! * \brief Get the ParMETIS load balancing tolerance. */ diff --git a/Common/src/CConfig.cpp b/Common/src/CConfig.cpp index a34902142cf..2a82d959af7 100644 --- a/Common/src/CConfig.cpp +++ b/Common/src/CConfig.cpp @@ -2952,6 +2952,9 @@ void CConfig::SetConfig_Options() { /* DESCRIPTION: Size of the edge groups colored for thread parallel edge loops (0 forces the reducer strategy). */ addUnsignedLongOption("EDGE_COLORING_GROUP_SIZE", edgeColorGroupSize, 512); + /* DESCRIPTION: Allow fallback to smaller edge color group sizes for the discrete adjoint and allow more colors. */ + addBoolOption("EDGE_COLORING_RELAX_DISC_ADJ", edgeColoringRelaxDiscAdj, true); + /*--- options that are used for libROM ---*/ /*!\par CONFIG_CATEGORY:libROM options \ingroup Config*/ diff --git a/SU2_CFD/include/solvers/CFVMFlowSolverBase.inl b/SU2_CFD/include/solvers/CFVMFlowSolverBase.inl index 3710340d0a7..db39cde78c0 100644 --- a/SU2_CFD/include/solvers/CFVMFlowSolverBase.inl +++ b/SU2_CFD/include/solvers/CFVMFlowSolverBase.inl @@ -293,7 +293,8 @@ void CFVMFlowSolverBase::HybridParallelInitialization(const CConfig& confi /*--- For the discrete adjoint, the reducer strategy is costly. Prefer coloring, possibly with reduced edge color * group size. Find the maximum edge color group size that yields an efficient coloring. Also, allow larger numbers * of colors. ---*/ - const auto& coloring = geometry.GetEdgeColoring(¶llelEff, true, true); + const bool relax = config.GetEdgeColoringRelaxDiscAdj(); + const auto& coloring = geometry.GetEdgeColoring(¶llelEff, relax, relax); #else const auto& coloring = geometry.GetEdgeColoring(¶llelEff); #endif diff --git a/SU2_CFD/include/solvers/CScalarSolver.inl b/SU2_CFD/include/solvers/CScalarSolver.inl index ea2d6925066..d9f17d17e7b 100644 --- a/SU2_CFD/include/solvers/CScalarSolver.inl +++ b/SU2_CFD/include/solvers/CScalarSolver.inl @@ -50,7 +50,8 @@ CScalarSolver::CScalarSolver(CGeometry* geometry, CConfig* config, /*--- For the discrete adjoint, the reducer strategy is costly. Prefer coloring, possibly with reduced edge color * group size. Find the maximum edge color group size that yields an efficient coloring. Also, allow larger numbers * of colors. ---*/ - const auto& coloring = geometry->GetEdgeColoring(¶llelEff, true, true); + const bool relax = config->GetEdgeColoringRelaxDiscAdj(); + const auto& coloring = geometry->GetEdgeColoring(¶llelEff, relax, relax); #else const auto& coloring = geometry->GetEdgeColoring(¶llelEff); #endif diff --git a/config_template.cfg b/config_template.cfg index 774d55875e8..ff2862f3924 100644 --- a/config_template.cfg +++ b/config_template.cfg @@ -1680,6 +1680,14 @@ UQ_DELTA_B= 1.0 % The optimum value/strategy is case-dependent. EDGE_COLORING_GROUP_SIZE= 512 % +% Coloring tends to perform better for the discrete adjoint than reductions because +% it uses less memory and enables the shared reading optimization for color loops. +% This option allows an automatic fallback to smaller edge color group sizes on ranks +% where the requested edge color group size is not efficient. Specifically, the largest +% edge color group size up to EDGE_COLORING_GROUP_SIZE is chosen that is at least +% 0.875 efficient. Also, this option allows using more colors, up to 255 instead of up to 64. +EDGE_COLORING_RELAX_DISC_ADJ= yes +% % Independent "threads per MPI rank" setting for LU-SGS and ILU preconditioners. % For problems where time is spend mostly in the solution of linear systems (e.g. elasticity, % very high CFL central schemes), AND, if the memory bandwidth of the machine is saturated From 88b127224064d6578d17b456a6f98aa2337ea9f6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johannes=20Bl=C3=BChdorn?= Date: Fri, 17 Nov 2023 13:43:15 +0100 Subject: [PATCH 25/48] Avoid void. --- Common/include/CConfig.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Common/include/CConfig.hpp b/Common/include/CConfig.hpp index c5999023515..2cb959fc3fc 100644 --- a/Common/include/CConfig.hpp +++ b/Common/include/CConfig.hpp @@ -9742,7 +9742,7 @@ class CConfig { /*! * \brief Check if the discrete adjoint is allowed to relax the coloring, that is, allow smaller edge color group sizes and allow more colors. */ - bool GetEdgeColoringRelaxDiscAdj(void) const { return edgeColoringRelaxDiscAdj; } + bool GetEdgeColoringRelaxDiscAdj() const { return edgeColoringRelaxDiscAdj; } /*! * \brief Get the ParMETIS load balancing tolerance. From c6681e4e4a2cdfe9186916e2750dae65fa797dc6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johannes=20Bl=C3=BChdorn?= Date: Wed, 22 Nov 2023 14:10:22 +0100 Subject: [PATCH 26/48] Capitalization. --- config_template.cfg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config_template.cfg b/config_template.cfg index de4cf72416e..ea621b85e7e 100644 --- a/config_template.cfg +++ b/config_template.cfg @@ -2146,7 +2146,7 @@ EDGE_COLORING_GROUP_SIZE= 512 % where the requested edge color group size is not efficient. Specifically, the largest % edge color group size up to EDGE_COLORING_GROUP_SIZE is chosen that is at least % 0.875 efficient. Also, this option allows using more colors, up to 255 instead of up to 64. -EDGE_COLORING_RELAX_DISC_ADJ= yes +EDGE_COLORING_RELAX_DISC_ADJ= YES % % Independent "threads per MPI rank" setting for LU-SGS and ILU preconditioners. % For problems where time is spend mostly in the solution of linear systems (e.g. elasticity, From 2fd31fce9c8e7fdd655b0305a2b218296ca731c4 Mon Sep 17 00:00:00 2001 From: rois1995 Date: Thu, 30 Nov 2023 18:08:29 +0100 Subject: [PATCH 27/48] - Fixed CGNS writing --- .../src/output/filewriter/CCGNSFileWriter.cpp | 21 ++++++++++--------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/SU2_CFD/src/output/filewriter/CCGNSFileWriter.cpp b/SU2_CFD/src/output/filewriter/CCGNSFileWriter.cpp index 34f75473b61..6e370d02a68 100644 --- a/SU2_CFD/src/output/filewriter/CCGNSFileWriter.cpp +++ b/SU2_CFD/src/output/filewriter/CCGNSFileWriter.cpp @@ -38,7 +38,7 @@ void CCGNSFileWriter::WriteData(string val_filename) { /*--- We append the pre-defined suffix (extension) to the filename (prefix) ---*/ val_filename.append(fileExt); - + /*--- Open the CGNS file for writing. ---*/ InitializeMeshFile(val_filename); @@ -132,15 +132,16 @@ void CCGNSFileWriter::WriteField(int iField, const string& FieldName) { /*--- Coordinate vector is written in blocks, one for each process. ---*/ cgsize_t nodeBegin = 1; auto nodeEnd = static_cast(nLocalPoints); - - if (isCoord) { - int CoordinateNumber; - CallCGNS(cg_coord_partial_write(cgnsFileID, cgnsBase, cgnsZone, dataType, FieldName.c_str(), &nodeBegin, &nodeEnd, - sendBufferField.data(), &CoordinateNumber)); - } else { - int fieldNumber; - CallCGNS(cg_field_partial_write(cgnsFileID, cgnsBase, cgnsZone, cgnsFields, dataType, FieldName.c_str(), &nodeBegin, - &nodeEnd, sendBufferField.data(), &fieldNumber)); + if(nLocalPoints > 0){ + if (isCoord) { + int CoordinateNumber; + CallCGNS(cg_coord_partial_write(cgnsFileID, cgnsBase, cgnsZone, dataType, FieldName.c_str(), &nodeBegin, &nodeEnd, + sendBufferField.data(), &CoordinateNumber)); + } else { + int fieldNumber; + CallCGNS(cg_field_partial_write(cgnsFileID, cgnsBase, cgnsZone, cgnsFields, dataType, FieldName.c_str(), &nodeBegin, + &nodeEnd, sendBufferField.data(), &fieldNumber)); + } } for (int i = 0; i < size; ++i) { From 35fb9d2f9ee6dfc06c4a06d782a5cade1c954ace Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johannes=20Bl=C3=BChdorn?= Date: Thu, 30 Nov 2023 19:22:27 +0100 Subject: [PATCH 28/48] No output if all ranks use the reducer strategy. --- SU2_CFD/include/solvers/CFVMFlowSolverBase.inl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SU2_CFD/include/solvers/CFVMFlowSolverBase.inl b/SU2_CFD/include/solvers/CFVMFlowSolverBase.inl index db39cde78c0..fd2eb13328f 100644 --- a/SU2_CFD/include/solvers/CFVMFlowSolverBase.inl +++ b/SU2_CFD/include/solvers/CFVMFlowSolverBase.inl @@ -351,7 +351,7 @@ void CFVMFlowSolverBase::HybridParallelInitialization(const CConfig& confi unsigned long minColoredEdgeColorGroupSize = 1 << 30; SU2_MPI::Reduce(&coloredEdgeColorGroupSize, &minColoredEdgeColorGroupSize, 1, MPI_UNSIGNED_LONG, MPI_MIN, MASTER_NODE, SU2_MPI::GetComm()); - if (SU2_MPI::GetRank() == MASTER_NODE) { + if (SU2_MPI::GetRank() == MASTER_NODE && numRanksUsingReducer != SU2_MPI::GetSize()) { cout << "Among the ranks that use edge coloring,\n" << " the minimum efficiency is " << minColoredParallelEff << ",\n" << " the maximum number of colors is " << maxColoredNumColors << ",\n" From a84f9caa435882e8382a6251b3302df92d1613a9 Mon Sep 17 00:00:00 2001 From: Nijso Date: Thu, 30 Nov 2023 21:05:24 +0100 Subject: [PATCH 29/48] Update SU2_CFD/src/output/filewriter/CCGNSFileWriter.cpp --- SU2_CFD/src/output/filewriter/CCGNSFileWriter.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/SU2_CFD/src/output/filewriter/CCGNSFileWriter.cpp b/SU2_CFD/src/output/filewriter/CCGNSFileWriter.cpp index 6e370d02a68..4399586c86b 100644 --- a/SU2_CFD/src/output/filewriter/CCGNSFileWriter.cpp +++ b/SU2_CFD/src/output/filewriter/CCGNSFileWriter.cpp @@ -38,7 +38,6 @@ void CCGNSFileWriter::WriteData(string val_filename) { /*--- We append the pre-defined suffix (extension) to the filename (prefix) ---*/ val_filename.append(fileExt); - /*--- Open the CGNS file for writing. ---*/ InitializeMeshFile(val_filename); From f25a4f2c86329b36ffa16ffb1dfe5f9377892f8a Mon Sep 17 00:00:00 2001 From: Nijso Date: Thu, 30 Nov 2023 21:07:12 +0100 Subject: [PATCH 30/48] Update SU2_CFD/src/output/filewriter/CCGNSFileWriter.cpp --- SU2_CFD/src/output/filewriter/CCGNSFileWriter.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SU2_CFD/src/output/filewriter/CCGNSFileWriter.cpp b/SU2_CFD/src/output/filewriter/CCGNSFileWriter.cpp index 4399586c86b..a4b89f39551 100644 --- a/SU2_CFD/src/output/filewriter/CCGNSFileWriter.cpp +++ b/SU2_CFD/src/output/filewriter/CCGNSFileWriter.cpp @@ -131,7 +131,7 @@ void CCGNSFileWriter::WriteField(int iField, const string& FieldName) { /*--- Coordinate vector is written in blocks, one for each process. ---*/ cgsize_t nodeBegin = 1; auto nodeEnd = static_cast(nLocalPoints); - if(nLocalPoints > 0){ + if (nLocalPoints > 0) { if (isCoord) { int CoordinateNumber; CallCGNS(cg_coord_partial_write(cgnsFileID, cgnsBase, cgnsZone, dataType, FieldName.c_str(), &nodeBegin, &nodeEnd, From 619b21c8f2712759039b31ee7a95f284674c2c32 Mon Sep 17 00:00:00 2001 From: rois1995 Date: Fri, 1 Dec 2023 11:40:34 +0100 Subject: [PATCH 31/48] - Added regression test for CGNS writer --- TestCases/CGNSWrite/config.cfg | 187 +++++++++++++++++++++++++++++++ TestCases/parallel_regression.py | 14 +++ 2 files changed, 201 insertions(+) create mode 100644 TestCases/CGNSWrite/config.cfg diff --git a/TestCases/CGNSWrite/config.cfg b/TestCases/CGNSWrite/config.cfg new file mode 100644 index 00000000000..faeeea3f4f8 --- /dev/null +++ b/TestCases/CGNSWrite/config.cfg @@ -0,0 +1,187 @@ +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% % +% SU2 configuration file % +% Case description: Transonic simulation RAE2822 (RANS) % +% Author: Francisco Palacios % +% Institution: Stanford University % +% Date: 5/15/2013 % +% File Version 7.4.0 "Blackbird" % +% % +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +% ------------- DIRECT, ADJOINT, AND LINEARIZED PROBLEM DEFINITION ------------% +% +% Physical governing equations (EULER, NAVIER_STOKES, +% WAVE_EQUATION, HEAT_EQUATION, FEM_ELASTICITY, +% POISSON_EQUATION) +SOLVER= RANS +% +% Specify turbulent model (NONE, SA, SA_NEG, SST) +KIND_TURB_MODEL= SST +% +% Mathematical problem (DIRECT, CONTINUOUS_ADJOINT) +MATH_PROBLEM= DIRECT +% +% Restart solution (NO, YES) +RESTART_SOL= NO + +% -------------------- COMPRESSIBLE FREE-STREAM DEFINITION --------------------% +% +% Mach number (non-dimensional, based on the free-stream values) +MACH_NUMBER= 0.2 +% AirSpeed = 279.9663 +% Density = 1.225 +% +% Angle of attack (degrees, only for compressible flows) +AOA= 0.0 +% Free-stream temperature (288.15 K by default) +FREESTREAM_TEMPERATURE= 270.0 +% +% Reynolds number (non-dimensional, based on the free-stream values) +REYNOLDS_NUMBER= 3.28E6 +% +% Reynolds length (1 m by default) +REYNOLDS_LENGTH= 1 +REF_DIMENSIONALIZATION= FREESTREAM_VEL_EQ_MACH + +% ---------------------- REFERENCE VALUE DEFINITION ---------------------------% +% +% Reference origin for moment computation +REF_ORIGIN_MOMENT_X = -0.2473 +REF_ORIGIN_MOMENT_Y = 0.00 +REF_ORIGIN_MOMENT_Z = 0.00 +% +% Reference length for pitching, rolling, and yawing non-dimensional moment +REF_LENGTH= 1 +% +% Reference area for force coefficients (0 implies automatic calculation) +% Body tube cross-area +REF_AREA= 1 + +% -------------------- BOUNDARY CONDITION DEFINITION --------------------------% +% +% Navier-Stokes wall boundary marker(s) (NONE = no marker) +MARKER_HEATFLUX= ( OuterWall, 0.0, InnerWall, 0.0 ) +% +% Farfield boundary marker(s) (NONE = no marker) +MARKER_FAR= ( Inlet, Outlet ) + +% +% +% Marker(s) of the surface to be plotted or designed +MARKER_PLOTTING= ( InnerWall ) +% +% Marker(s) of the surface where the functional (Cd, Cl, etc.) will be evaluated +MARKER_MONITORING= ( InnerWall ) + + +% ------------------------ LINEAR SOLVER DEFINITION ---------------------------% +% +LINEAR_SOLVER= FGMRES +LINEAR_SOLVER_PREC= ILU +LINEAR_SOLVER_ERROR= 1.0e-6 +% lower memory consumption: +LINEAR_SOLVER_ITER= 15 +% +% -------------------------- MULTIGRID PARAMETERS -----------------------------% +% + +NEWTON_KRYLOV= NO +NEWTON_KRYLOV_IPARAM= (10, 5, 2) % n0, np, ft +NEWTON_KRYLOV_DPARAM= (1.0, 0.01, -6, 1e-5) % r0, tp, rf, e +CFL_ADAPT= YES +CFL_NUMBER= 1 +CFL_REDUCTION_TURB= 1.0 +% +CFL_ADAPT_PARAM= ( 0.5, 1.01, 1.0, 5, 0.0001) + +ITER= 1 + +MGLEVEL= 0 +% +MGCYCLE= V_CYCLE +MG_PRE_SMOOTH= ( 1, 2, 3, 3 ) +MG_POST_SMOOTH= ( 1, 1, 1, 1 ) +MG_CORRECTION_SMOOTH= ( 1, 1, 1, 1 ) +MG_DAMP_RESTRICTION= 0.5 +MG_DAMP_PROLONGATION= 0.5 + +% -------------------- FLOW NUMERICAL METHOD DEFINITION -----------------------% +% +% Convective numerical method (JST, LAX-FRIEDRICH, CUSP, ROE, AUSM, HLLC, +% TURKEL_PREC, MSW) +CONV_NUM_METHOD_FLOW= ROE +USE_VECTORIZATION= YES +% +% Monotonic Upwind Scheme for Conservation Laws (TVD) in the flow equations. +% Required for 2nd order upwind schemes (NO, YES) +MUSCL_FLOW= NO +% +% Slope limiter (VENKATAKRISHNAN, MINMOD) +SLOPE_LIMITER_FLOW= VENKATAKRISHNAN +% +% Coefficient for the limiter (smooth regions) +VENKAT_LIMITER_COEFF= 0.03 +% +% 2nd and 4th order artificial dissipation coefficients +JST_SENSOR_COEFF= ( 0.5, 0.02 ) +% +% Time discretization (RUNGE-KUTTA_EXPLICIT, EULER_IMPLICIT, EULER_EXPLICIT) +TIME_DISCRE_FLOW= EULER_IMPLICIT + +% -------------------- TURBULENT NUMERICAL METHOD DEFINITION ------------------% +% +% Convective numerical method (SCALAR_UPWIND) +CONV_NUM_METHOD_TURB= SCALAR_UPWIND +% +% Monotonic Upwind Scheme for Conservation Laws (TVD) in the turbulence equations. +% Required for 2nd order upwind schemes (NO, YES) +MUSCL_TURB= NO +% +% Time discretization (EULER_IMPLICIT) +TIME_DISCRE_TURB= EULER_IMPLICIT + + +% --------------------------- CONVERGENCE PARAMETERS --------------------------% +% +CONV_FIELD= MOMENT_X +CONV_STARTITER= 10 +CONV_CAUCHY_ELEMS= 100 +CONV_CAUCHY_EPS= 1E-6 +% + +% ------------------------- INPUT/OUTPUT INFORMATION --------------------------% +% +% Mesh input file +MESH_FILENAME= mesh.cgns +% +% Mesh input file format (SU2, CGNS, NETCDF_ASCII) +MESH_FORMAT= CGNS +% +% Restart flow input file +SOLUTION_FILENAME= restart_flow +% +TABULAR_FORMAT= CSV +% +% Output file convergence history (w/o extension) +CONV_FILENAME= history_First +% +% Output file restart flow +RESTART_FILENAME= restart_flow +% +% Output file flow (w/o extension) variables +VOLUME_FILENAME= flow +% +% Output file surface flow coefficient (w/o extension) +SURFACE_FILENAME= surface_flow +% +% Writing solution file frequency +OUTPUT_WRT_FREQ= 100 +% +% +% Screen output fields +SCREEN_OUTPUT= (INNER_ITER, WALL_TIME, RMS_DENSITY, LIFT, DRAG, MOMENT_Z) +OUTPUT_FILES= (SURFACE_CGNS) +WRT_FORCES_BREAKDOWN= NO +VOLUME_OUTPUT= (COORDINATES) +HISTORY_OUTPUT= (ITER) diff --git a/TestCases/parallel_regression.py b/TestCases/parallel_regression.py index 3278b46e737..481f355e9eb 100644 --- a/TestCases/parallel_regression.py +++ b/TestCases/parallel_regression.py @@ -1555,6 +1555,20 @@ def main(): species3_multizone_restart.multizone = True test_list.append(species3_multizone_restart) + ##################### + ## CGNS writer ### + ##################### + + # CGNS writer + CGNSWrite = TestCase('CGNSWrite') + CGNSWrite.cfg_dir = "CGNSWrite" + CGNSWrite.cfg_file = "config.cfg" + CGNSWrite.test_iter = 1 + CGNSWrite.test_vals = [-2.974473, 0.665204, 5.068846, -7.003873] + CGNSWrite.command = TestCase.Command("mpirun -n 2", "SU2_CFD") + CGNSWrite.new_output = True + test_list.append(CGNSWrite) + ###################################### ### RUN TESTS ### ###################################### From 6124e0fe836f8257df94881d1de24707ccacd970 Mon Sep 17 00:00:00 2001 From: rois1995 Date: Fri, 1 Dec 2023 12:47:01 +0100 Subject: [PATCH 32/48] - changed mesh for regression case --- TestCases/CGNSWrite/config.cfg | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/TestCases/CGNSWrite/config.cfg b/TestCases/CGNSWrite/config.cfg index faeeea3f4f8..bfad06bafd9 100644 --- a/TestCases/CGNSWrite/config.cfg +++ b/TestCases/CGNSWrite/config.cfg @@ -153,10 +153,10 @@ CONV_CAUCHY_EPS= 1E-6 % ------------------------- INPUT/OUTPUT INFORMATION --------------------------% % % Mesh input file -MESH_FILENAME= mesh.cgns +MESH_FILENAME= mesh.su2 % % Mesh input file format (SU2, CGNS, NETCDF_ASCII) -MESH_FORMAT= CGNS +MESH_FORMAT= SU2 % % Restart flow input file SOLUTION_FILENAME= restart_flow From 90bc63b15fffa0b64903891d82fcdcdd8ec640d4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johannes=20Bl=C3=BChdorn?= <55186095+jblueh@users.noreply.github.com> Date: Fri, 1 Dec 2023 16:28:19 +0100 Subject: [PATCH 33/48] Update Common/src/geometry/CGeometry.cpp Co-authored-by: Pedro Gomes <38071223+pcarruscag@users.noreply.github.com> --- Common/src/geometry/CGeometry.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Common/src/geometry/CGeometry.cpp b/Common/src/geometry/CGeometry.cpp index b88ef3d2198..fd6b2c92bd4 100644 --- a/Common/src/geometry/CGeometry.cpp +++ b/Common/src/geometry/CGeometry.cpp @@ -3639,7 +3639,7 @@ const CCompressedSparsePatternUL& CGeometry::GetEdgeColoring(su2double* efficien /*--- Color the edges. ---*/ constexpr bool balanceColors = true; - /*--- lambda to account for different numbers of colors ---*/ + /*--- Lambda to account for different numbers of colors. ---*/ auto getColorSparsePattern = [&](unsigned long edgeColorGroupSize) { if (largeNumberOfColors) { return colorSparsePattern(pattern, edgeColorGroupSize, balanceColors); From 39168b58e021e25b29ff148762389d8af3913df7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johannes=20Bl=C3=BChdorn?= Date: Fri, 1 Dec 2023 16:36:33 +0100 Subject: [PATCH 34/48] Add const. --- SU2_CFD/include/solvers/CFVMFlowSolverBase.inl | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/SU2_CFD/include/solvers/CFVMFlowSolverBase.inl b/SU2_CFD/include/solvers/CFVMFlowSolverBase.inl index fd2eb13328f..2f86931ac2b 100644 --- a/SU2_CFD/include/solvers/CFVMFlowSolverBase.inl +++ b/SU2_CFD/include/solvers/CFVMFlowSolverBase.inl @@ -339,15 +339,15 @@ void CFVMFlowSolverBase::HybridParallelInitialization(const CConfig& confi } } - su2double coloredParallelEff = ReducerStrategy ? 1.0 : parallelEff; + const su2double coloredParallelEff = ReducerStrategy ? 1.0 : parallelEff; su2double minColoredParallelEff = 1.0; SU2_MPI::Reduce(&coloredParallelEff, &minColoredParallelEff, 1, MPI_DOUBLE, MPI_MIN, MASTER_NODE, SU2_MPI::GetComm()); - unsigned long coloredNumColors = ReducerStrategy ? 0 : coloring.getOuterSize(); + const unsigned long coloredNumColors = ReducerStrategy ? 0 : coloring.getOuterSize(); unsigned long maxColoredNumColors = 0; SU2_MPI::Reduce(&coloredNumColors, &maxColoredNumColors, 1, MPI_UNSIGNED_LONG, MPI_MAX, MASTER_NODE, SU2_MPI::GetComm()); - unsigned long coloredEdgeColorGroupSize = ReducerStrategy ? 1 << 30 : geometry.GetEdgeColorGroupSize(); + const unsigned long coloredEdgeColorGroupSize = ReducerStrategy ? 1 << 30 : geometry.GetEdgeColorGroupSize(); unsigned long minColoredEdgeColorGroupSize = 1 << 30; SU2_MPI::Reduce(&coloredEdgeColorGroupSize, &minColoredEdgeColorGroupSize, 1, MPI_UNSIGNED_LONG, MPI_MIN, MASTER_NODE, SU2_MPI::GetComm()); From e6ac3dbb06a6ca80ba81ef4f11be8f809b9b7e52 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johannes=20Bl=C3=BChdorn?= Date: Fri, 1 Dec 2023 16:43:52 +0100 Subject: [PATCH 35/48] More const. --- Common/src/geometry/CGeometry.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Common/src/geometry/CGeometry.cpp b/Common/src/geometry/CGeometry.cpp index fd6b2c92bd4..eaafe9d49b5 100644 --- a/Common/src/geometry/CGeometry.cpp +++ b/Common/src/geometry/CGeometry.cpp @@ -3664,7 +3664,7 @@ const CCompressedSparsePatternUL& CGeometry::GetEdgeColoring(su2double* efficien continue; } - su2double currentEfficiency = + const su2double currentEfficiency = coloringEfficiency(currentEdgeColoring, omp_get_max_threads(), nextEdgeColorGroupSize); /*--- if the coloring is not efficient, reduce the color group size ---*/ From 09efb1ae7614fd988ddc83e9c8dd8c6b3fc39863 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johannes=20Bl=C3=BChdorn?= Date: Fri, 1 Dec 2023 18:06:32 +0100 Subject: [PATCH 36/48] Increase the default number of colors. --- Common/include/geometry/CGeometry.hpp | 4 +--- Common/include/toolboxes/graph_toolbox.hpp | 2 +- Common/src/geometry/CGeometry.cpp | 18 ++++-------------- SU2_CFD/include/solvers/CFVMFlowSolverBase.inl | 2 +- SU2_CFD/include/solvers/CScalarSolver.inl | 2 +- 5 files changed, 8 insertions(+), 20 deletions(-) diff --git a/Common/include/geometry/CGeometry.hpp b/Common/include/geometry/CGeometry.hpp index fc5c2931075..4af65411cc2 100644 --- a/Common/include/geometry/CGeometry.hpp +++ b/Common/include/geometry/CGeometry.hpp @@ -1724,12 +1724,10 @@ class CGeometry { * CGeometry::edgeColorGroupSize that yields a coloring that is at least as efficient as #COLORING_EFF_THRESH. * \param[out] efficiency - optional output of the coloring efficiency. * \param[in] maximizeEdgeColorGroupSize - use the maximum edge color group size that gives an efficient coloring. - * \param[in] largeNumberOfColors - allow up to 255 colors instead of 64 (default) * \return Reference to the coloring. */ const CCompressedSparsePatternUL& GetEdgeColoring(su2double* efficiency = nullptr, - bool maximizeEdgeColorGroupSize = false, - bool largeNumberOfColors = false); + bool maximizeEdgeColorGroupSize = false); /*! * \brief Force the natural (sequential) edge coloring. diff --git a/Common/include/toolboxes/graph_toolbox.hpp b/Common/include/toolboxes/graph_toolbox.hpp index c5929e8f8da..f1c0854ce27 100644 --- a/Common/include/toolboxes/graph_toolbox.hpp +++ b/Common/include/toolboxes/graph_toolbox.hpp @@ -484,7 +484,7 @@ T createNaturalColoring(Index_t numInnerIndexes) { * \param[out] indexColor - Optional, vector with colors given to the outer indices. * \return Coloring in the same type of the input pattern. */ -template +template T colorSparsePattern(const T& pattern, size_t groupSize = 1, bool balanceColors = false, std::vector* indexColor = nullptr) { static_assert(std::is_integral::value, ""); diff --git a/Common/src/geometry/CGeometry.cpp b/Common/src/geometry/CGeometry.cpp index eaafe9d49b5..08d81daf59f 100644 --- a/Common/src/geometry/CGeometry.cpp +++ b/Common/src/geometry/CGeometry.cpp @@ -3609,8 +3609,7 @@ const su2vector& CGeometry::GetTransposeSparsePatternMap(Connecti return pattern.transposePtr(); } -const CCompressedSparsePatternUL& CGeometry::GetEdgeColoring(su2double* efficiency, bool maximizeEdgeColorGroupSize, - bool largeNumberOfColors) { +const CCompressedSparsePatternUL& CGeometry::GetEdgeColoring(su2double* efficiency, bool maximizeEdgeColorGroupSize) { /*--- Check for dry run mode with dummy geometry. ---*/ if (nEdge == 0) return edgeColoring; @@ -3639,15 +3638,6 @@ const CCompressedSparsePatternUL& CGeometry::GetEdgeColoring(su2double* efficien /*--- Color the edges. ---*/ constexpr bool balanceColors = true; - /*--- Lambda to account for different numbers of colors. ---*/ - auto getColorSparsePattern = [&](unsigned long edgeColorGroupSize) { - if (largeNumberOfColors) { - return colorSparsePattern(pattern, edgeColorGroupSize, balanceColors); - } else { - return colorSparsePattern(pattern, edgeColorGroupSize, balanceColors); - } - }; - /*--- if requested, find an efficient coloring with maximum color group size (up to edgeColorGroupSize) ---*/ if (maximizeEdgeColorGroupSize) { auto upperEdgeColorGroupSize = edgeColorGroupSize + 1; /* upper bound that is deemed too large */ @@ -3655,7 +3645,7 @@ const CCompressedSparsePatternUL& CGeometry::GetEdgeColoring(su2double* efficien auto lowerEdgeColorGroupSize = 1ul; /* lower bound that is known to work */ while (true) { - auto currentEdgeColoring = getColorSparsePattern(nextEdgeColorGroupSize); + const auto currentEdgeColoring = colorSparsePattern(pattern, edgeColorGroupSize, balanceColors); /*--- if the coloring fails, reduce the color group size ---*/ if (currentEdgeColoring.empty()) { @@ -3675,7 +3665,7 @@ const CCompressedSparsePatternUL& CGeometry::GetEdgeColoring(su2double* efficien else { lowerEdgeColorGroupSize = nextEdgeColorGroupSize; } - auto increment = (upperEdgeColorGroupSize - lowerEdgeColorGroupSize) / 2; + const auto increment = (upperEdgeColorGroupSize - lowerEdgeColorGroupSize) / 2; nextEdgeColorGroupSize = lowerEdgeColorGroupSize + increment; @@ -3687,7 +3677,7 @@ const CCompressedSparsePatternUL& CGeometry::GetEdgeColoring(su2double* efficien edgeColorGroupSize = nextEdgeColorGroupSize; } - edgeColoring = getColorSparsePattern(edgeColorGroupSize); + edgeColoring = colorSparsePattern(pattern, edgeColorGroupSize, balanceColors); /*--- If the coloring fails use the natural coloring. This is a * "soft" failure as this "bad" coloring should be detected diff --git a/SU2_CFD/include/solvers/CFVMFlowSolverBase.inl b/SU2_CFD/include/solvers/CFVMFlowSolverBase.inl index 2f86931ac2b..c2af5a18d82 100644 --- a/SU2_CFD/include/solvers/CFVMFlowSolverBase.inl +++ b/SU2_CFD/include/solvers/CFVMFlowSolverBase.inl @@ -294,7 +294,7 @@ void CFVMFlowSolverBase::HybridParallelInitialization(const CConfig& confi * group size. Find the maximum edge color group size that yields an efficient coloring. Also, allow larger numbers * of colors. ---*/ const bool relax = config.GetEdgeColoringRelaxDiscAdj(); - const auto& coloring = geometry.GetEdgeColoring(¶llelEff, relax, relax); + const auto& coloring = geometry.GetEdgeColoring(¶llelEff, relax); #else const auto& coloring = geometry.GetEdgeColoring(¶llelEff); #endif diff --git a/SU2_CFD/include/solvers/CScalarSolver.inl b/SU2_CFD/include/solvers/CScalarSolver.inl index d9f17d17e7b..343944ebd6c 100644 --- a/SU2_CFD/include/solvers/CScalarSolver.inl +++ b/SU2_CFD/include/solvers/CScalarSolver.inl @@ -51,7 +51,7 @@ CScalarSolver::CScalarSolver(CGeometry* geometry, CConfig* config, * group size. Find the maximum edge color group size that yields an efficient coloring. Also, allow larger numbers * of colors. ---*/ const bool relax = config->GetEdgeColoringRelaxDiscAdj(); - const auto& coloring = geometry->GetEdgeColoring(¶llelEff, relax, relax); + const auto& coloring = geometry->GetEdgeColoring(¶llelEff, relax); #else const auto& coloring = geometry->GetEdgeColoring(¶llelEff); #endif From 87554b3d33407949fabfa2ed0c3ab9f19678b325 Mon Sep 17 00:00:00 2001 From: rois1995 <43813346+rois1995@users.noreply.github.com> Date: Mon, 4 Dec 2023 15:15:23 +0100 Subject: [PATCH 37/48] Update TestCases/parallel_regression.py Co-authored-by: Mickael PHILIT --- TestCases/parallel_regression.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/TestCases/parallel_regression.py b/TestCases/parallel_regression.py index 481f355e9eb..80591acdf91 100644 --- a/TestCases/parallel_regression.py +++ b/TestCases/parallel_regression.py @@ -1560,14 +1560,14 @@ def main(): ##################### # CGNS writer - CGNSWrite = TestCase('CGNSWrite') - CGNSWrite.cfg_dir = "CGNSWrite" - CGNSWrite.cfg_file = "config.cfg" - CGNSWrite.test_iter = 1 - CGNSWrite.test_vals = [-2.974473, 0.665204, 5.068846, -7.003873] - CGNSWrite.command = TestCase.Command("mpirun -n 2", "SU2_CFD") - CGNSWrite.new_output = True - test_list.append(CGNSWrite) + cgns_writer = TestCase('CGNSWrite') + cgns_writer.cfg_dir = "CGNSWrite" + cgns_writer.cfg_file = "config.cfg" + cgns_writer.test_iter = 1 + cgns_writer.test_vals = [-2.974473, 0.665204, 5.068846, -7.003873] + cgns_writer.command = TestCase.Command("mpirun -n 2", "SU2_CFD") + cgns_writer.new_output = True + test_list.append(cgns_writer) ###################################### ### RUN TESTS ### From 1b4091ddc176d74b6dd8924326dddf358dd9a23a Mon Sep 17 00:00:00 2001 From: rois1995 Date: Mon, 4 Dec 2023 15:25:04 +0100 Subject: [PATCH 38/48] - Changed name to regression case --- TestCases/{CGNSWrite => cgns_writer}/config.cfg | 0 TestCases/parallel_regression.py | 4 ++-- 2 files changed, 2 insertions(+), 2 deletions(-) rename TestCases/{CGNSWrite => cgns_writer}/config.cfg (100%) diff --git a/TestCases/CGNSWrite/config.cfg b/TestCases/cgns_writer/config.cfg similarity index 100% rename from TestCases/CGNSWrite/config.cfg rename to TestCases/cgns_writer/config.cfg diff --git a/TestCases/parallel_regression.py b/TestCases/parallel_regression.py index 80591acdf91..e1acb128581 100644 --- a/TestCases/parallel_regression.py +++ b/TestCases/parallel_regression.py @@ -1560,8 +1560,8 @@ def main(): ##################### # CGNS writer - cgns_writer = TestCase('CGNSWrite') - cgns_writer.cfg_dir = "CGNSWrite" + cgns_writer = TestCase('cgns_writer') + cgns_writer.cfg_dir = "cgns_writer" cgns_writer.cfg_file = "config.cfg" cgns_writer.test_iter = 1 cgns_writer.test_vals = [-2.974473, 0.665204, 5.068846, -7.003873] From 87f99447b48bfd449225b6d12b2d1df43fffa889 Mon Sep 17 00:00:00 2001 From: rois1995 Date: Tue, 5 Dec 2023 08:49:16 +0100 Subject: [PATCH 39/48] - Removed comments from regression config --- TestCases/cgns_writer/config.cfg | 103 ++----------------------------- 1 file changed, 6 insertions(+), 97 deletions(-) diff --git a/TestCases/cgns_writer/config.cfg b/TestCases/cgns_writer/config.cfg index bfad06bafd9..12930ef75c9 100644 --- a/TestCases/cgns_writer/config.cfg +++ b/TestCases/cgns_writer/config.cfg @@ -1,144 +1,73 @@ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % % SU2 configuration file % -% Case description: Transonic simulation RAE2822 (RANS) % -% Author: Francisco Palacios % -% Institution: Stanford University % -% Date: 5/15/2013 % -% File Version 7.4.0 "Blackbird" % +% Case description: Subsonic U-Turn % +% Author: Andrea Rausa % +% Institution: Politecnico di Milano % +% Date: 12/2/2023 % +% File Version 8.0.0 "Harrier" % % % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % ------------- DIRECT, ADJOINT, AND LINEARIZED PROBLEM DEFINITION ------------% % -% Physical governing equations (EULER, NAVIER_STOKES, -% WAVE_EQUATION, HEAT_EQUATION, FEM_ELASTICITY, -% POISSON_EQUATION) SOLVER= RANS -% -% Specify turbulent model (NONE, SA, SA_NEG, SST) KIND_TURB_MODEL= SST -% -% Mathematical problem (DIRECT, CONTINUOUS_ADJOINT) MATH_PROBLEM= DIRECT -% -% Restart solution (NO, YES) RESTART_SOL= NO % -------------------- COMPRESSIBLE FREE-STREAM DEFINITION --------------------% % -% Mach number (non-dimensional, based on the free-stream values) MACH_NUMBER= 0.2 -% AirSpeed = 279.9663 -% Density = 1.225 -% -% Angle of attack (degrees, only for compressible flows) AOA= 0.0 -% Free-stream temperature (288.15 K by default) FREESTREAM_TEMPERATURE= 270.0 -% -% Reynolds number (non-dimensional, based on the free-stream values) REYNOLDS_NUMBER= 3.28E6 -% -% Reynolds length (1 m by default) REYNOLDS_LENGTH= 1 REF_DIMENSIONALIZATION= FREESTREAM_VEL_EQ_MACH % ---------------------- REFERENCE VALUE DEFINITION ---------------------------% % -% Reference origin for moment computation REF_ORIGIN_MOMENT_X = -0.2473 REF_ORIGIN_MOMENT_Y = 0.00 REF_ORIGIN_MOMENT_Z = 0.00 -% -% Reference length for pitching, rolling, and yawing non-dimensional moment REF_LENGTH= 1 -% -% Reference area for force coefficients (0 implies automatic calculation) -% Body tube cross-area REF_AREA= 1 % -------------------- BOUNDARY CONDITION DEFINITION --------------------------% % -% Navier-Stokes wall boundary marker(s) (NONE = no marker) MARKER_HEATFLUX= ( OuterWall, 0.0, InnerWall, 0.0 ) -% -% Farfield boundary marker(s) (NONE = no marker) MARKER_FAR= ( Inlet, Outlet ) - -% -% -% Marker(s) of the surface to be plotted or designed MARKER_PLOTTING= ( InnerWall ) -% -% Marker(s) of the surface where the functional (Cd, Cl, etc.) will be evaluated MARKER_MONITORING= ( InnerWall ) - % ------------------------ LINEAR SOLVER DEFINITION ---------------------------% % LINEAR_SOLVER= FGMRES LINEAR_SOLVER_PREC= ILU LINEAR_SOLVER_ERROR= 1.0e-6 -% lower memory consumption: LINEAR_SOLVER_ITER= 15 -% + % -------------------------- MULTIGRID PARAMETERS -----------------------------% % - -NEWTON_KRYLOV= NO -NEWTON_KRYLOV_IPARAM= (10, 5, 2) % n0, np, ft -NEWTON_KRYLOV_DPARAM= (1.0, 0.01, -6, 1e-5) % r0, tp, rf, e CFL_ADAPT= YES CFL_NUMBER= 1 CFL_REDUCTION_TURB= 1.0 -% CFL_ADAPT_PARAM= ( 0.5, 1.01, 1.0, 5, 0.0001) - ITER= 1 -MGLEVEL= 0 -% -MGCYCLE= V_CYCLE -MG_PRE_SMOOTH= ( 1, 2, 3, 3 ) -MG_POST_SMOOTH= ( 1, 1, 1, 1 ) -MG_CORRECTION_SMOOTH= ( 1, 1, 1, 1 ) -MG_DAMP_RESTRICTION= 0.5 -MG_DAMP_PROLONGATION= 0.5 - % -------------------- FLOW NUMERICAL METHOD DEFINITION -----------------------% % -% Convective numerical method (JST, LAX-FRIEDRICH, CUSP, ROE, AUSM, HLLC, -% TURKEL_PREC, MSW) CONV_NUM_METHOD_FLOW= ROE USE_VECTORIZATION= YES -% -% Monotonic Upwind Scheme for Conservation Laws (TVD) in the flow equations. -% Required for 2nd order upwind schemes (NO, YES) MUSCL_FLOW= NO -% -% Slope limiter (VENKATAKRISHNAN, MINMOD) SLOPE_LIMITER_FLOW= VENKATAKRISHNAN -% -% Coefficient for the limiter (smooth regions) VENKAT_LIMITER_COEFF= 0.03 -% -% 2nd and 4th order artificial dissipation coefficients -JST_SENSOR_COEFF= ( 0.5, 0.02 ) -% -% Time discretization (RUNGE-KUTTA_EXPLICIT, EULER_IMPLICIT, EULER_EXPLICIT) TIME_DISCRE_FLOW= EULER_IMPLICIT % -------------------- TURBULENT NUMERICAL METHOD DEFINITION ------------------% % -% Convective numerical method (SCALAR_UPWIND) CONV_NUM_METHOD_TURB= SCALAR_UPWIND -% -% Monotonic Upwind Scheme for Conservation Laws (TVD) in the turbulence equations. -% Required for 2nd order upwind schemes (NO, YES) MUSCL_TURB= NO -% -% Time discretization (EULER_IMPLICIT) TIME_DISCRE_TURB= EULER_IMPLICIT @@ -148,38 +77,18 @@ CONV_FIELD= MOMENT_X CONV_STARTITER= 10 CONV_CAUCHY_ELEMS= 100 CONV_CAUCHY_EPS= 1E-6 -% % ------------------------- INPUT/OUTPUT INFORMATION --------------------------% % -% Mesh input file MESH_FILENAME= mesh.su2 -% -% Mesh input file format (SU2, CGNS, NETCDF_ASCII) MESH_FORMAT= SU2 -% -% Restart flow input file SOLUTION_FILENAME= restart_flow -% TABULAR_FORMAT= CSV -% -% Output file convergence history (w/o extension) CONV_FILENAME= history_First -% -% Output file restart flow RESTART_FILENAME= restart_flow -% -% Output file flow (w/o extension) variables VOLUME_FILENAME= flow -% -% Output file surface flow coefficient (w/o extension) SURFACE_FILENAME= surface_flow -% -% Writing solution file frequency OUTPUT_WRT_FREQ= 100 -% -% -% Screen output fields SCREEN_OUTPUT= (INNER_ITER, WALL_TIME, RMS_DENSITY, LIFT, DRAG, MOMENT_Z) OUTPUT_FILES= (SURFACE_CGNS) WRT_FORCES_BREAKDOWN= NO From f457da5e0e04f0eca60a8e7b9b1a86487694b4f5 Mon Sep 17 00:00:00 2001 From: rois1995 Date: Tue, 5 Dec 2023 15:00:42 +0100 Subject: [PATCH 40/48] - Format spaces in parallel_regression.py --- TestCases/parallel_regression.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/TestCases/parallel_regression.py b/TestCases/parallel_regression.py index e1acb128581..f11842ae25c 100644 --- a/TestCases/parallel_regression.py +++ b/TestCases/parallel_regression.py @@ -1560,13 +1560,13 @@ def main(): ##################### # CGNS writer - cgns_writer = TestCase('cgns_writer') - cgns_writer.cfg_dir = "cgns_writer" - cgns_writer.cfg_file = "config.cfg" - cgns_writer.test_iter = 1 - cgns_writer.test_vals = [-2.974473, 0.665204, 5.068846, -7.003873] - cgns_writer.command = TestCase.Command("mpirun -n 2", "SU2_CFD") - cgns_writer.new_output = True + cgns_writer = TestCase('cgns_writer') + cgns_writer.cfg_dir = "cgns_writer" + cgns_writer.cfg_file = "config.cfg" + cgns_writer.test_iter = 1 + cgns_writer.test_vals = [-2.974473, 0.665204, 5.068846, -7.003873] + cgns_writer.command = TestCase.Command("mpirun -n 2", "SU2_CFD") + cgns_writer.new_output = True test_list.append(cgns_writer) ###################################### From 224c5017cf3272f2121c7719d7973cb0bde1f856 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johannes=20Bl=C3=BChdorn?= Date: Tue, 5 Dec 2023 18:11:58 +0100 Subject: [PATCH 41/48] Avoid recomputation of final coloring. --- Common/src/geometry/CGeometry.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Common/src/geometry/CGeometry.cpp b/Common/src/geometry/CGeometry.cpp index 08d81daf59f..a3e92cf7045 100644 --- a/Common/src/geometry/CGeometry.cpp +++ b/Common/src/geometry/CGeometry.cpp @@ -3645,17 +3645,17 @@ const CCompressedSparsePatternUL& CGeometry::GetEdgeColoring(su2double* efficien auto lowerEdgeColorGroupSize = 1ul; /* lower bound that is known to work */ while (true) { - const auto currentEdgeColoring = colorSparsePattern(pattern, edgeColorGroupSize, balanceColors); + const auto edgeColoring = colorSparsePattern(pattern, edgeColorGroupSize, balanceColors); /*--- if the coloring fails, reduce the color group size ---*/ - if (currentEdgeColoring.empty()) { + if (edgeColoring.empty()) { upperEdgeColorGroupSize = nextEdgeColorGroupSize; nextEdgeColorGroupSize = lowerEdgeColorGroupSize + (upperEdgeColorGroupSize - lowerEdgeColorGroupSize) / 2; continue; } const su2double currentEfficiency = - coloringEfficiency(currentEdgeColoring, omp_get_max_threads(), nextEdgeColorGroupSize); + coloringEfficiency(edgeColoring, omp_get_max_threads(), nextEdgeColorGroupSize); /*--- if the coloring is not efficient, reduce the color group size ---*/ if (currentEfficiency < COLORING_EFF_THRESH) { @@ -3675,10 +3675,10 @@ const CCompressedSparsePatternUL& CGeometry::GetEdgeColoring(su2double* efficien } edgeColorGroupSize = nextEdgeColorGroupSize; + } else { + edgeColoring = colorSparsePattern(pattern, edgeColorGroupSize, balanceColors); } - edgeColoring = colorSparsePattern(pattern, edgeColorGroupSize, balanceColors); - /*--- If the coloring fails use the natural coloring. This is a * "soft" failure as this "bad" coloring should be detected * downstream and a fallback strategy put in place. ---*/ From df30b2f0fc6dd7461cfedab7bcb27e0ad71da30b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johannes=20Bl=C3=BChdorn?= Date: Tue, 5 Dec 2023 18:12:52 +0100 Subject: [PATCH 42/48] Fix edge color group size. --- Common/src/geometry/CGeometry.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Common/src/geometry/CGeometry.cpp b/Common/src/geometry/CGeometry.cpp index a3e92cf7045..b603786dcaf 100644 --- a/Common/src/geometry/CGeometry.cpp +++ b/Common/src/geometry/CGeometry.cpp @@ -3645,7 +3645,7 @@ const CCompressedSparsePatternUL& CGeometry::GetEdgeColoring(su2double* efficien auto lowerEdgeColorGroupSize = 1ul; /* lower bound that is known to work */ while (true) { - const auto edgeColoring = colorSparsePattern(pattern, edgeColorGroupSize, balanceColors); + const auto edgeColoring = colorSparsePattern(pattern, nextEdgeColorGroupSize, balanceColors); /*--- if the coloring fails, reduce the color group size ---*/ if (edgeColoring.empty()) { From 81f834b2ddd708d655a8b0f6598797458e28c23f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johannes=20Bl=C3=BChdorn?= Date: Tue, 5 Dec 2023 18:55:02 +0100 Subject: [PATCH 43/48] Comment formatting. --- Common/src/geometry/CGeometry.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Common/src/geometry/CGeometry.cpp b/Common/src/geometry/CGeometry.cpp index b603786dcaf..58fbfc42da6 100644 --- a/Common/src/geometry/CGeometry.cpp +++ b/Common/src/geometry/CGeometry.cpp @@ -3638,7 +3638,7 @@ const CCompressedSparsePatternUL& CGeometry::GetEdgeColoring(su2double* efficien /*--- Color the edges. ---*/ constexpr bool balanceColors = true; - /*--- if requested, find an efficient coloring with maximum color group size (up to edgeColorGroupSize) ---*/ + /*--- If requested, find an efficient coloring with maximum color group size (up to edgeColorGroupSize). ---*/ if (maximizeEdgeColorGroupSize) { auto upperEdgeColorGroupSize = edgeColorGroupSize + 1; /* upper bound that is deemed too large */ auto nextEdgeColorGroupSize = edgeColorGroupSize; /* next value that we are going to try */ @@ -3647,7 +3647,7 @@ const CCompressedSparsePatternUL& CGeometry::GetEdgeColoring(su2double* efficien while (true) { const auto edgeColoring = colorSparsePattern(pattern, nextEdgeColorGroupSize, balanceColors); - /*--- if the coloring fails, reduce the color group size ---*/ + /*--- If the coloring fails, reduce the color group size. ---*/ if (edgeColoring.empty()) { upperEdgeColorGroupSize = nextEdgeColorGroupSize; nextEdgeColorGroupSize = lowerEdgeColorGroupSize + (upperEdgeColorGroupSize - lowerEdgeColorGroupSize) / 2; @@ -3657,11 +3657,11 @@ const CCompressedSparsePatternUL& CGeometry::GetEdgeColoring(su2double* efficien const su2double currentEfficiency = coloringEfficiency(edgeColoring, omp_get_max_threads(), nextEdgeColorGroupSize); - /*--- if the coloring is not efficient, reduce the color group size ---*/ + /*--- If the coloring is not efficient, reduce the color group size. ---*/ if (currentEfficiency < COLORING_EFF_THRESH) { upperEdgeColorGroupSize = nextEdgeColorGroupSize; } - /*--- otherwise, try to enlarge the color group size ---*/ + /*--- Otherwise, enlarge the color group size. ---*/ else { lowerEdgeColorGroupSize = nextEdgeColorGroupSize; } From 799c9bb5555928091182f381d78b39799c5fc0b5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johannes=20Bl=C3=BChdorn?= Date: Tue, 5 Dec 2023 19:00:20 +0100 Subject: [PATCH 44/48] Ensure that failed colorings reach the terminating condition. --- Common/src/geometry/CGeometry.cpp | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/Common/src/geometry/CGeometry.cpp b/Common/src/geometry/CGeometry.cpp index 58fbfc42da6..a2b02ac27f9 100644 --- a/Common/src/geometry/CGeometry.cpp +++ b/Common/src/geometry/CGeometry.cpp @@ -3650,23 +3650,23 @@ const CCompressedSparsePatternUL& CGeometry::GetEdgeColoring(su2double* efficien /*--- If the coloring fails, reduce the color group size. ---*/ if (edgeColoring.empty()) { upperEdgeColorGroupSize = nextEdgeColorGroupSize; - nextEdgeColorGroupSize = lowerEdgeColorGroupSize + (upperEdgeColorGroupSize - lowerEdgeColorGroupSize) / 2; - continue; } - - const su2double currentEfficiency = - coloringEfficiency(edgeColoring, omp_get_max_threads(), nextEdgeColorGroupSize); - - /*--- If the coloring is not efficient, reduce the color group size. ---*/ - if (currentEfficiency < COLORING_EFF_THRESH) { - upperEdgeColorGroupSize = nextEdgeColorGroupSize; - } - /*--- Otherwise, enlarge the color group size. ---*/ + /*--- If the coloring succeeds, check the efficiency. ---*/ else { - lowerEdgeColorGroupSize = nextEdgeColorGroupSize; + const su2double currentEfficiency = + coloringEfficiency(edgeColoring, omp_get_max_threads(), nextEdgeColorGroupSize); + + /*--- If the coloring is not efficient, reduce the color group size. ---*/ + if (currentEfficiency < COLORING_EFF_THRESH) { + upperEdgeColorGroupSize = nextEdgeColorGroupSize; + } + /*--- Otherwise, enlarge the color group size. ---*/ + else { + lowerEdgeColorGroupSize = nextEdgeColorGroupSize; + } } - const auto increment = (upperEdgeColorGroupSize - lowerEdgeColorGroupSize) / 2; + const auto increment = (upperEdgeColorGroupSize - lowerEdgeColorGroupSize) / 2; nextEdgeColorGroupSize = lowerEdgeColorGroupSize + increment; if (increment == 0) { From de3b94e24b9c088067a47ae68454a80e133c41ac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johannes=20Bl=C3=BChdorn?= Date: Tue, 5 Dec 2023 19:03:17 +0100 Subject: [PATCH 45/48] Add comment. --- Common/src/geometry/CGeometry.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/Common/src/geometry/CGeometry.cpp b/Common/src/geometry/CGeometry.cpp index a2b02ac27f9..404ff102c56 100644 --- a/Common/src/geometry/CGeometry.cpp +++ b/Common/src/geometry/CGeometry.cpp @@ -3669,6 +3669,7 @@ const CCompressedSparsePatternUL& CGeometry::GetEdgeColoring(su2double* efficien const auto increment = (upperEdgeColorGroupSize - lowerEdgeColorGroupSize) / 2; nextEdgeColorGroupSize = lowerEdgeColorGroupSize + increment; + /*--- Terminating condition. ---*/ if (increment == 0) { break; } From de941f3f28ba084bd09aabce9bf580ab29dd921f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johannes=20Bl=C3=BChdorn?= Date: Tue, 5 Dec 2023 19:17:24 +0100 Subject: [PATCH 46/48] Use member variable directly. --- Common/src/geometry/CGeometry.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Common/src/geometry/CGeometry.cpp b/Common/src/geometry/CGeometry.cpp index 404ff102c56..5ce438a33a8 100644 --- a/Common/src/geometry/CGeometry.cpp +++ b/Common/src/geometry/CGeometry.cpp @@ -3645,7 +3645,7 @@ const CCompressedSparsePatternUL& CGeometry::GetEdgeColoring(su2double* efficien auto lowerEdgeColorGroupSize = 1ul; /* lower bound that is known to work */ while (true) { - const auto edgeColoring = colorSparsePattern(pattern, nextEdgeColorGroupSize, balanceColors); + edgeColoring = colorSparsePattern(pattern, nextEdgeColorGroupSize, balanceColors); /*--- If the coloring fails, reduce the color group size. ---*/ if (edgeColoring.empty()) { From aec3aabae4539192154ad2cd6c47932ea4c0e504 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johannes=20Bl=C3=BChdorn?= Date: Wed, 6 Dec 2023 16:46:10 +0100 Subject: [PATCH 47/48] Avoid recomputation if last coloring was admissible. --- Common/src/geometry/CGeometry.cpp | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/Common/src/geometry/CGeometry.cpp b/Common/src/geometry/CGeometry.cpp index 5ce438a33a8..aeca6421763 100644 --- a/Common/src/geometry/CGeometry.cpp +++ b/Common/src/geometry/CGeometry.cpp @@ -3644,12 +3644,15 @@ const CCompressedSparsePatternUL& CGeometry::GetEdgeColoring(su2double* efficien auto nextEdgeColorGroupSize = edgeColorGroupSize; /* next value that we are going to try */ auto lowerEdgeColorGroupSize = 1ul; /* lower bound that is known to work */ + bool admissibleColoring = false; /* keep track wether the last tested coloring is admissible */ + while (true) { edgeColoring = colorSparsePattern(pattern, nextEdgeColorGroupSize, balanceColors); /*--- If the coloring fails, reduce the color group size. ---*/ if (edgeColoring.empty()) { upperEdgeColorGroupSize = nextEdgeColorGroupSize; + admissibleColoring = false; } /*--- If the coloring succeeds, check the efficiency. ---*/ else { @@ -3659,10 +3662,12 @@ const CCompressedSparsePatternUL& CGeometry::GetEdgeColoring(su2double* efficien /*--- If the coloring is not efficient, reduce the color group size. ---*/ if (currentEfficiency < COLORING_EFF_THRESH) { upperEdgeColorGroupSize = nextEdgeColorGroupSize; + admissibleColoring = false; } /*--- Otherwise, enlarge the color group size. ---*/ else { lowerEdgeColorGroupSize = nextEdgeColorGroupSize; + admissibleColoring = true; } } @@ -3676,7 +3681,14 @@ const CCompressedSparsePatternUL& CGeometry::GetEdgeColoring(su2double* efficien } edgeColorGroupSize = nextEdgeColorGroupSize; - } else { + + /*--- If the last tested coloring was not admissible, recompute the final coloring. ---*/ + if (!admissibleColoring) { + edgeColoring = colorSparsePattern(pattern, edgeColorGroupSize, balanceColors); + } + } + /*--- No adaptivity. ---*/ + else { edgeColoring = colorSparsePattern(pattern, edgeColorGroupSize, balanceColors); } From 8b89e857ff72782b0caccc3f63385c03bc67f6f7 Mon Sep 17 00:00:00 2001 From: Pedro Gomes Date: Wed, 6 Dec 2023 15:01:13 -0800 Subject: [PATCH 48/48] fix submodules --- externals/codi | 2 +- externals/mel | 2 +- subprojects/CoolProp | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/externals/codi b/externals/codi index 17232fed052..0ad036f2c82 160000 --- a/externals/codi +++ b/externals/codi @@ -1 +1 @@ -Subproject commit 17232fed05245dbb8f04a31e274a02d53458c75c +Subproject commit 0ad036f2c8254fa7b77180a443d99248c047c877 diff --git a/externals/mel b/externals/mel index 2484cd3258e..46205ab019e 160000 --- a/externals/mel +++ b/externals/mel @@ -1 +1 @@ -Subproject commit 2484cd3258ef800a10e361016cb341834ee7930b +Subproject commit 46205ab019e5224559091375a6d71aabae6bc5b9 diff --git a/subprojects/CoolProp b/subprojects/CoolProp index 0ce42fcf3bb..bafdea1f39e 160000 --- a/subprojects/CoolProp +++ b/subprojects/CoolProp @@ -1 +1 @@ -Subproject commit 0ce42fcf3bb2c373512bc825a4f0c1973a78f307 +Subproject commit bafdea1f39ee873a6bb9833e3a21fe41f90b85e8