From d88647f0cebdefe35228d5e68621a936bffdc128 Mon Sep 17 00:00:00 2001 From: bigfooted Date: Sun, 15 Nov 2026 10:23:29 +0100 Subject: [PATCH 01/13] Couple passive periodic points to their masters in the implicit system With implicit periodicity, the PERIODIC_RESIDUAL comms delete the rows of the passive points (first marker of each pair) and add only their diagonal block to the master. The off-diagonal blocks of the passive rows, and the columns of other rows that refer to passive points, are lost. On a wedge one cell thick every point is periodic, so most of the Jacobian coupling disappears and the Newton step is useless above CFL ~25. CSolver::CouplePeriodicJacobian moves those blocks to the master rows and columns, rotated, before the comms. Only masters on the same rank and blocks that exist in the sparsity pattern are coupled. Blocks go through GetBlockView/SetBlock, so the quantized Q_LU_SGS storage works too. The edge between a point and its own periodic image is left out of the local time step. It only rotates the state, but it added the sound speed and the viscous term and made the time step ~60x too small on the axis of a wedge. New case TestCases/incomp_rans/morse_swirl_jet (Morse 1980 swirling jet, 5 deg one-cell wedge, SA) and regression test inc_turb_morse_swirl_jet (restart, 10 iterations); mesh and solution are in the TestCases branch fix_periodic_jacobian, which regression.yml points to until it is merged. Regression values of the periodic cases in parallel_regression.py and serial_regression.py are updated; hybrid and AD values are not. Co-Authored-By: Claude Opus 5.5 --- .github/workflows/regression.yml | 8 +- .../include/solvers/CFVMFlowSolverBase.hpp | 5 + .../include/solvers/CFVMFlowSolverBase.inl | 2 + SU2_CFD/include/solvers/CScalarSolver.inl | 2 + SU2_CFD/include/solvers/CSolver.hpp | 21 +++ SU2_CFD/src/solvers/CSolver.cpp | 146 ++++++++++++++++++ .../incomp_rans/morse_swirl_jet/inlet_jet.dat | 65 ++++++++ .../incomp_rans/morse_swirl_jet/morse_sa.cfg | 99 ++++++++++++ .../morse_swirl_jet/morse_wedge.geo | 100 ++++++++++++ TestCases/parallel_regression.py | 38 +++-- TestCases/serial_regression.py | 16 +- 11 files changed, 475 insertions(+), 27 deletions(-) create mode 100644 TestCases/incomp_rans/morse_swirl_jet/inlet_jet.dat create mode 100644 TestCases/incomp_rans/morse_swirl_jet/morse_sa.cfg create mode 100644 TestCases/incomp_rans/morse_swirl_jet/morse_wedge.geo diff --git a/.github/workflows/regression.yml b/.github/workflows/regression.yml index 323353274e5a..49b0773ff86b 100644 --- a/.github/workflows/regression.yml +++ b/.github/workflows/regression.yml @@ -235,7 +235,7 @@ jobs: uses: docker://ghcr.io/su2code/su2/test-su2:261011-1107 with: # -t -c - args: -b ${{github.ref}} -t develop -c develop -s ${{matrix.testscript}} + args: -b ${{github.ref}} -t develop -c fix_periodic_jacobian -s ${{matrix.testscript}} - name: Cleanup uses: docker://ghcr.io/su2code/su2/test-su2:261011-1107 with: @@ -284,7 +284,7 @@ jobs: uses: docker://ghcr.io/su2code/su2/test-su2:261011-1107 with: # -t -c - args: -b ${{github.ref}} -t develop -c develop -s ${{matrix.testscript}} -a "--tapetests" + args: -b ${{github.ref}} -t develop -c fix_periodic_jacobian -s ${{matrix.testscript}} -a "--tapetests" - name: Cleanup uses: docker://ghcr.io/su2code/su2/test-su2:261011-1107 with: @@ -334,7 +334,7 @@ jobs: PMIX_MCA_gds: hash with: # -t -c - args: -b ${{github.ref}} -t develop -c develop -s ${{matrix.testscript}} -a "--tsan" + args: -b ${{github.ref}} -t develop -c fix_periodic_jacobian -s ${{matrix.testscript}} -a "--tsan" - name: Cleanup uses: docker://ghcr.io/su2code/su2/test-su2-tsan:261011-1107 with: @@ -379,7 +379,7 @@ jobs: uses: docker://ghcr.io/su2code/su2/test-su2-asan:261011-1107 with: # -t -c - args: -b ${{github.ref}} -t develop -c develop -s ${{matrix.testscript}} -a "--asan" + args: -b ${{github.ref}} -t develop -c fix_periodic_jacobian -s ${{matrix.testscript}} -a "--asan" - name: Cleanup uses: docker://ghcr.io/su2code/su2/test-su2-asan:261011-1107 with: diff --git a/SU2_CFD/include/solvers/CFVMFlowSolverBase.hpp b/SU2_CFD/include/solvers/CFVMFlowSolverBase.hpp index e0c24506a5e5..23e9d8c1a639 100644 --- a/SU2_CFD/include/solvers/CFVMFlowSolverBase.hpp +++ b/SU2_CFD/include/solvers/CFVMFlowSolverBase.hpp @@ -444,6 +444,10 @@ class CFVMFlowSolverBase : public CSolver { ompMasterAssignBarrier(Min_Delta_Time,1e30, Max_Delta_Time,0.0, Global_Delta_UnstTimeND,1e30); + /*--- Edges between a point and its own periodic image carry only the rotation of the state. ---*/ + const bool skipImages = implicit_periodic; + if (skipImages) SetPeriodicMaster(geometry, config); + /*--- Loop domain points. ---*/ SU2_OMP_FOR_DYN(omp_chunk_size) @@ -461,6 +465,7 @@ class CFVMFlowSolverBase : public CSolver { for (unsigned short iNeigh = 0; iNeigh < geometry->nodes->GetnPoint(iPoint); ++iNeigh) { auto jPoint = geometry->nodes->GetPoint(iPoint,iNeigh); + if (skipImages && ArePeriodicImages(iPoint, jPoint)) continue; auto iEdge = geometry->nodes->GetEdge(iPoint,iNeigh); auto Normal = geometry->edges->GetNormal(iEdge); diff --git a/SU2_CFD/include/solvers/CFVMFlowSolverBase.inl b/SU2_CFD/include/solvers/CFVMFlowSolverBase.inl index 9f1637b2b781..2e681c4f51d7 100644 --- a/SU2_CFD/include/solvers/CFVMFlowSolverBase.inl +++ b/SU2_CFD/include/solvers/CFVMFlowSolverBase.inl @@ -1325,6 +1325,8 @@ void CFVMFlowSolverBase::BC_Periodic(CGeometry* geometry, CSolver** solver accumulated correctly during the communications. For implicit calculations, the Jacobians and linear system are also correctly adjusted here. ---*/ + CouplePeriodicJacobian(geometry, config); + for (unsigned short iPeriodic = 1; iPeriodic <= config->GetnMarker_Periodic() / 2; iPeriodic++) { InitiatePeriodicComms(geometry, config, iPeriodic, PERIODIC_RESIDUAL); CompletePeriodicComms(geometry, config, iPeriodic, PERIODIC_RESIDUAL); diff --git a/SU2_CFD/include/solvers/CScalarSolver.inl b/SU2_CFD/include/solvers/CScalarSolver.inl index 941d68928493..041730ba8029 100644 --- a/SU2_CFD/include/solvers/CScalarSolver.inl +++ b/SU2_CFD/include/solvers/CScalarSolver.inl @@ -412,6 +412,8 @@ void CScalarSolver::BC_Periodic(CGeometry* geometry, CSolver** sol accumulated corectly during the communications. For implicit calculations the Jacobians and linear system are also correctly adjusted here. ---*/ + CouplePeriodicJacobian(geometry, config); + for (unsigned short iPeriodic = 1; iPeriodic <= config->GetnMarker_Periodic() / 2; iPeriodic++) { InitiatePeriodicComms(geometry, config, iPeriodic, PERIODIC_RESIDUAL); CompletePeriodicComms(geometry, config, iPeriodic, PERIODIC_RESIDUAL); diff --git a/SU2_CFD/include/solvers/CSolver.hpp b/SU2_CFD/include/solvers/CSolver.hpp index 882316b5c67a..15c336a33730 100644 --- a/SU2_CFD/include/solvers/CSolver.hpp +++ b/SU2_CFD/include/solvers/CSolver.hpp @@ -149,6 +149,8 @@ class CSolver { bool implicit_periodic; /*!< \brief Flag that controls whether the implicit system should be treated by the periodic BC comms. */ su2activematrix PeriodicProj; /*!< \brief Min/max reconstruction increments at periodic receive points (for limiters). */ std::unordered_map PeriodicProjIndex; /*!< \brief Local point to compact projection row. */ + vector PeriodicMaster; /*!< \brief Local master point of each passive periodic point on this rank, or -1. */ + vector PeriodicMasterMarker; /*!< \brief Periodic marker of each passive point, gives its rotation. */ bool dynamic_grid; /*!< \brief Flag that determines whether the grid is dynamic (moving or deforming + grid velocities). */ @@ -326,6 +328,25 @@ class CSolver { unsigned short val_periodic_index, unsigned short commType); + /*! + * \brief Move the off-diagonal Jacobian blocks of passive periodic points to their masters, rotated. + * \note Call before the PERIODIC_RESIDUAL comms. Only masters on the same rank and blocks in the sparsity pattern are coupled. + */ + void CouplePeriodicJacobian(CGeometry *geometry, const CConfig *config); + + /*! + * \brief Map each passive periodic point to its master on the same rank (built once). + */ + void SetPeriodicMaster(CGeometry *geometry, const CConfig *config); + + /*! + * \brief Whether two points are periodic images of each other on this rank. + */ + inline bool ArePeriodicImages(unsigned long iPoint, unsigned long jPoint) const { + if (PeriodicMaster.empty()) return false; + return PeriodicMaster[iPoint] == static_cast(jPoint) || PeriodicMaster[jPoint] == static_cast(iPoint); + } + /*! * \brief Set number of linear solver iterations. * \param[in] val_iterlinsolver - Number of linear iterations. diff --git a/SU2_CFD/src/solvers/CSolver.cpp b/SU2_CFD/src/solvers/CSolver.cpp index 19f07df2e598..ff93efbba720 100644 --- a/SU2_CFD/src/solvers/CSolver.cpp +++ b/SU2_CFD/src/solvers/CSolver.cpp @@ -4606,3 +4606,149 @@ void CSolver::SavelibROM(CGeometry *geometry, CConfig *config, bool converged) { #endif } + +void CSolver::SetPeriodicMaster(CGeometry *geometry, const CConfig *config) { + if (config->GetnMarker_Periodic() == 0) return; + + BEGIN_SU2_OMP_SAFE_GLOBAL_ACCESS { + + const auto nPeriodic = config->GetnMarker_Periodic(); + const auto nPointAll = geometry->GetnPoint(); + + if (PeriodicMaster.size() != nPointAll) { + PeriodicMaster.assign(nPointAll, -1); + PeriodicMasterMarker.assign(nPointAll, 0); + vector nPeriodicMarker(nPointAll, 0); + vector passive(nPointAll, false); + + for (auto iMarker = 0u; iMarker < config->GetnMarker_All(); iMarker++) { + if (config->GetMarker_All_KindBC(iMarker) != PERIODIC_BOUNDARY) continue; + /*--- Points receiving from the second marker of a pair have their rows removed (CompletePeriodicComms). ---*/ + const bool isPassive = config->GetMarker_All_PerBound(iMarker) <= nPeriodic / 2; + for (auto iVertex = 0ul; iVertex < geometry->nVertex[iMarker]; iVertex++) { + const auto* vertex = geometry->vertex[iMarker][iVertex]; + const auto iPoint = vertex->GetNode(); + nPeriodicMarker[iPoint]++; + if (!isPassive) continue; + passive[iPoint] = true; + if (vertex->GetDonorProcessor() == rank && vertex->GetDonorPoint() >= 0) { + PeriodicMaster[iPoint] = vertex->GetDonorPoint(); + PeriodicMasterMarker[iPoint] = iMarker; + } + } + } + + /*--- Points on several periodic markers keep the treatment of the comms only. ---*/ + for (auto iPoint = 0ul; iPoint < nPointAll; iPoint++) { + const auto master = PeriodicMaster[iPoint]; + if (master < 0) continue; + if (nPeriodicMarker[iPoint] != 1 || nPeriodicMarker[master] != 1 || passive[master]) + PeriodicMaster[iPoint] = -1; + } + } + + } + END_SU2_OMP_SAFE_GLOBAL_ACCESS +} + +void CSolver::CouplePeriodicJacobian(CGeometry *geometry, const CConfig *config) { + SU2_ZONE_SCOPED + if (!implicit_periodic) return; + + SetPeriodicMaster(geometry, config); + + BEGIN_SU2_OMP_SAFE_GLOBAL_ACCESS { + + /*--- Rotation from the frame of a passive point to the frame of its master. ---*/ + auto Rotation = [&](unsigned short iMarker, su2double (&Q)[3][3]) { + for (auto i = 0u; i < 3; i++) + for (auto j = 0u; j < 3; j++) Q[i][j] = (i == j); + if (!rotate_periodic) return false; + const auto* angles = config->GetPeriodicRotAngles(config->GetMarker_All_TagBound(iMarker)); + if (!GeometryToolbox::HasRotation(angles)) return false; + if (nDim == 2) { + su2double Q2[2][2]; + GeometryToolbox::RotationMatrix(angles[2], Q2); + for (auto i = 0u; i < 2; i++) + for (auto j = 0u; j < 2; j++) Q[i][j] = Q2[i][j]; + } else { + GeometryToolbox::RotationMatrix(angles[0], angles[1], angles[2], Q); + } + return true; + }; + + su2activematrix block(nVar, nVar), zero(nVar, nVar); + zero = su2double(0.0); + su2double v[3]; + + /*--- Copy a block through its view, which also decodes quantized storage. ---*/ + auto ReadBlock = [&](unsigned long iRow, unsigned long iCol) { + const auto view = Jacobian.GetBlockView(iRow, iCol); + if (!view) return false; + for (auto i = 0u; i < nVar; i++) + for (auto j = 0u; j < nVar; j++) block(i, j) = view(i, j); + return true; + }; + + auto RotateRows = [&](const su2double (&Q)[3][3]) { + for (auto c = 0u; c < nVar; c++) { + for (auto d = 0u; d < nDim; d++) v[d] = block(1 + d, c); + for (auto d = 0u; d < nDim; d++) { + su2double sum = 0.0; + for (auto e = 0u; e < nDim; e++) sum += Q[d][e] * v[e]; + block(1 + d, c) = sum; + } + } + }; + + /*--- Right product with Q^T: the passive increment is Q^T times the master increment. ---*/ + auto RotateColumns = [&](const su2double (&Q)[3][3]) { + for (auto r = 0u; r < nVar; r++) { + for (auto d = 0u; d < nDim; d++) v[d] = block(r, 1 + d); + for (auto d = 0u; d < nDim; d++) { + su2double sum = 0.0; + for (auto e = 0u; e < nDim; e++) sum += v[e] * Q[d][e]; + block(r, 1 + d) = sum; + } + } + }; + + su2double Qp[3][3], Qk[3][3]; + + /*--- Rows of passive points go to the rows of their masters. ---*/ + for (auto iPoint = 0ul; iPoint < nPointDomain; iPoint++) { + const auto master = PeriodicMaster[iPoint]; + if (master < 0) continue; + const bool rotP = Rotation(PeriodicMasterMarker[iPoint], Qp); + + for (const auto kPoint : geometry->nodes->GetPoints(iPoint)) { + if (!ReadBlock(iPoint, kPoint)) continue; + + long col = kPoint; + if (PeriodicMaster[kPoint] >= 0) { + col = PeriodicMaster[kPoint]; + if (Rotation(PeriodicMasterMarker[kPoint], Qk)) RotateColumns(Qk); + } + if (rotP) RotateRows(Qp); + + Jacobian.SetBlock(master, col, block); + } + } + + /*--- Columns of passive points go to the columns of their masters. ---*/ + for (auto iPoint = 0ul; iPoint < nPointDomain; iPoint++) { + if (PeriodicMaster[iPoint] >= 0) continue; + + for (const auto kPoint : geometry->nodes->GetPoints(iPoint)) { + const auto master = PeriodicMaster[kPoint]; + if (master < 0) continue; + if (!Jacobian.GetBlockView(iPoint, master) || !ReadBlock(iPoint, kPoint)) continue; + if (Rotation(PeriodicMasterMarker[kPoint], Qk)) RotateColumns(Qk); + Jacobian.SetBlock(iPoint, master, block); + Jacobian.SetBlock(iPoint, kPoint, zero); + } + } + + } + END_SU2_OMP_SAFE_GLOBAL_ACCESS +} diff --git a/TestCases/incomp_rans/morse_swirl_jet/inlet_jet.dat b/TestCases/incomp_rans/morse_swirl_jet/inlet_jet.dat new file mode 100644 index 000000000000..19f935ed891f --- /dev/null +++ b/TestCases/incomp_rans/morse_swirl_jet/inlet_jet.dat @@ -0,0 +1,65 @@ +NMARK= 1 +MARKER_TAG= inlet_jet +NROW=60 +NCOL=9 +# COORD-X COORD-Y COORD-Z TEMPERATURE VELOCITY NORMAL-X NORMAL-Y NORMAL-Z NU_TILDE +1.230000000000000e-02 4.915317250182741e-04 -2.146073858374531e-05 2.881500000000000e+02 3.404952035805443e+01 9.964500863218230e-01 3.977264224582153e-03 8.409165736575443e-02 2.108527391098338e-03 +1.230000000000000e-02 9.750124993671942e-04 -4.256996506995672e-05 2.881500000000000e+02 3.430313843595425e+01 9.880697227692148e-01 7.215987429835292e-03 1.538380722453961e-01 2.108527391098338e-03 +1.230000000000000e-02 9.750124993671942e-04 4.256996506995671e-05 2.881500000000000e+02 3.430313843595425e+01 9.880697227692148e-01 -6.219343030316790e-03 1.538815866796235e-01 2.108527391098338e-03 +1.230000000000000e-02 4.915317250182741e-04 2.146073858374531e-05 2.881500000000000e+02 3.404952035805443e+01 9.964500863218230e-01 -3.366941323155189e-03 8.411830463910938e-02 2.108527391098338e-03 +1.230000000000000e-02 1.458493273716226e-03 -6.367919155617299e-05 2.881500000000000e+02 3.454279085009219e+01 9.762877688261749e-01 1.014212659517094e-02 2.162390568526813e-01 2.108527391098338e-03 +1.230000000000000e-02 1.458493273716226e-03 6.367919155617298e-05 2.881500000000000e+02 3.454279085009220e+01 9.762877688261747e-01 -8.742942869563935e-03 2.163001465334435e-01 2.108527391098338e-03 +1.230000000000000e-02 1.941974048065509e-03 -8.478841804240026e-05 2.881500000000000e+02 3.473691736740481e+01 9.688679027627434e-01 1.201797138126057e-02 2.472863832886933e-01 2.108527391098338e-03 +1.230000000000000e-02 1.941974048065509e-03 8.478841804240026e-05 2.881500000000000e+02 3.473691736740481e+01 9.688679027627434e-01 -9.580189035078044e-03 2.473928191645333e-01 2.108527391098338e-03 +1.230000000000000e-02 2.425454822414266e-03 -1.058976445286045e-04 2.881500000000000e+02 3.491004480099832e+01 9.570479293413384e-01 1.437979231487217e-02 2.895729312564240e-01 2.108527391098338e-03 +1.230000000000000e-02 2.425454822414266e-03 1.058976445286045e-04 2.881500000000000e+02 3.491004480099832e+01 9.570479293413384e-01 -1.091287103953410e-02 2.897243003082949e-01 2.108527391098338e-03 +1.230000000000000e-02 2.908935596762439e-03 -1.270068710147833e-04 2.881500000000000e+02 3.511796986204671e+01 9.397713273854733e-01 1.714460373522862e-02 3.413735707211489e-01 2.108527391098338e-03 +1.230000000000000e-02 2.908935596762439e-03 1.270068710147833e-04 2.881500000000000e+02 3.511796986204671e+01 9.397713273854733e-01 -1.267330376870326e-02 3.415687918937142e-01 2.108527391098338e-03 +1.230000000000000e-02 3.392416371111116e-03 -1.481160975009841e-04 2.881500000000000e+02 3.528982116296100e+01 9.260512716016078e-01 1.892666174263513e-02 3.769228353925044e-01 2.108527391098338e-03 +1.230000000000000e-02 3.392416371111116e-03 1.481160975009841e-04 2.881500000000000e+02 3.528982116296100e+01 9.260512716016078e-01 -1.399634959659803e-02 3.771380974696337e-01 2.108527391098338e-03 +1.230000000000000e-02 3.875897145460034e-03 -1.692253239871954e-04 2.881500000000000e+02 3.551215523720097e+01 9.112425122050197e-01 2.065526075006717e-02 4.113519711313309e-01 2.108527391098338e-03 +1.230000000000000e-02 3.875897145460034e-03 1.692253239871954e-04 2.881500000000000e+02 3.551215523720097e+01 9.112425122050197e-01 -1.527502532774494e-02 4.115868772829392e-01 2.108527391098338e-03 +1.230000000000000e-02 4.359377919809123e-03 -1.903345504734142e-04 2.881500000000000e+02 3.573358919956365e+01 9.036946523831382e-01 2.172966451482030e-02 4.276257673880193e-01 2.108527391098338e-03 +1.230000000000000e-02 4.359377919809123e-03 1.903345504734141e-04 2.881500000000000e+02 3.573358919956365e+01 9.036946523831382e-01 -1.562306479376379e-02 4.278923872898056e-01 2.108527391098338e-03 +1.230000000000000e-02 4.842858694158044e-03 -2.114437769596256e-04 2.881500000000000e+02 3.596582688777886e+01 8.959717351739295e-01 2.278227706937255e-02 4.435263437733462e-01 2.108527391098338e-03 +1.230000000000000e-02 4.842858694158044e-03 2.114437769596256e-04 2.881500000000000e+02 3.596582688777886e+01 8.959717351739295e-01 -1.596028429275307e-02 4.438241984104884e-01 2.108527391098338e-03 +1.230000000000000e-02 5.326339468506962e-03 -2.325530034458370e-04 2.881500000000000e+02 3.597906269642409e+01 8.942078992003367e-01 2.331743914955868e-02 4.470442148593665e-01 2.108527391098338e-03 +1.230000000000000e-02 5.326339468506963e-03 2.325530034458369e-04 2.881500000000000e+02 3.597906269642409e+01 8.942078992003365e-01 -1.573376133324451e-02 4.473753253835411e-01 2.108527391098338e-03 +1.230000000000000e-02 5.809820242855882e-03 -2.536622299320483e-04 2.881500000000000e+02 3.598980701325640e+01 8.924123870269365e-01 2.385467051978150e-02 4.505897093535071e-01 2.108527391098338e-03 +1.230000000000000e-02 5.809820242855882e-03 2.536622299320483e-04 2.881500000000000e+02 3.598980701325640e+01 8.924123870269365e-01 -1.550758449662454e-02 4.509541509998167e-01 2.108527391098338e-03 +1.230000000000000e-02 6.293301017204801e-03 -2.747714564182597e-04 2.881500000000000e+02 3.585282925447235e+01 8.896639674444857e-01 2.453168460400286e-02 4.559563811171272e-01 2.108527391098338e-03 +1.230000000000000e-02 6.293301017204801e-03 2.747714564182596e-04 2.881500000000000e+02 3.585282925447235e+01 8.896639674444857e-01 -1.530088291903097e-02 4.563594066224945e-01 2.108527391098338e-03 +1.230000000000000e-02 6.776781791553593e-03 -2.958806829044656e-04 2.881500000000000e+02 3.571601787886337e+01 8.868903347339346e-01 2.521594161932737e-02 4.612913292527621e-01 2.108527391098338e-03 +1.230000000000000e-02 6.776781791553593e-03 2.958806829044654e-04 2.881500000000000e+02 3.571601787886337e+01 8.868903347339346e-01 -1.508420107551411e-02 4.617336905982094e-01 2.108527391098338e-03 +1.230000000000000e-02 7.260262565901019e-03 -3.169899093906116e-04 2.881500000000000e+02 3.548623354001720e+01 8.864116770742088e-01 2.614893873877201e-02 4.621586002113610e-01 2.108527391098338e-03 +1.230000000000000e-02 7.260262565901019e-03 3.169899093906116e-04 2.881500000000000e+02 3.548623354001720e+01 8.864116770742088e-01 -1.423034193634863e-02 4.626789773859011e-01 2.108527391098338e-03 +1.230000000000000e-02 7.743743340249600e-03 -3.380991358768083e-04 2.881500000000000e+02 3.525668118861410e+01 8.859251724448826e-01 2.709464097744716e-02 4.630361424973307e-01 2.108527391098338e-03 +1.230000000000000e-02 7.743743340249600e-03 3.380991358768082e-04 2.881500000000000e+02 3.525668118861410e+01 8.859251724448826e-01 -1.336472122993312e-02 4.636356037395652e-01 2.108527391098338e-03 +1.230000000000000e-02 8.227224114600015e-03 -3.592083623630850e-04 2.881500000000000e+02 3.506478345062848e+01 8.854458827588981e-01 2.818749458180924e-02 4.638868976965356e-01 2.108527391098338e-03 +1.230000000000000e-02 8.227224114600015e-03 3.592083623630849e-04 2.881500000000000e+02 3.506478345062848e+01 8.854458827588981e-01 -1.235017446476032e-02 4.645783700259899e-01 2.108527391098338e-03 +1.230000000000000e-02 8.710704888951459e-03 -3.803175888494065e-04 2.881500000000000e+02 3.487296185468804e+01 8.849593859884991e-01 2.929231168974371e-02 4.647460011949857e-01 2.108527391098338e-03 +1.230000000000000e-02 8.710704888951459e-03 3.803175888494064e-04 2.881500000000000e+02 3.487296185468804e+01 8.849593859884991e-01 -1.132443732297945e-02 4.655304955319002e-01 2.108527391098338e-03 +1.230000000000000e-02 9.194185663303368e-03 -4.014268153357484e-04 2.881500000000000e+02 3.409955958208356e+01 8.854079871950582e-01 3.041559804813040e-02 4.638184856240317e-01 2.108527391098338e-03 +1.230000000000000e-02 9.194185663303369e-03 4.014268153357484e-04 2.881500000000000e+02 3.409955958208356e+01 8.854079871950582e-01 -1.012458709981934e-02 4.647044102946019e-01 2.108527391098338e-03 +1.230000000000000e-02 9.677666437654643e-03 -4.225360418220627e-04 2.881500000000000e+02 3.331699155975138e+01 8.859007846674354e-01 3.159905365039384e-02 4.627972553224809e-01 2.109105393500574e-03 +1.230000000000000e-02 9.677666437654643e-03 4.225360418220626e-04 2.881500000000000e+02 3.331699155975138e+01 8.859007846674354e-01 -8.856628817969465e-03 4.637902110346906e-01 2.109105393500574e-03 +1.230000000000000e-02 1.016114721200506e-02 -4.436452683083394e-04 2.881500000000000e+02 3.202843334758530e+01 8.880303872600582e-01 3.344505778443284e-02 4.585667447739173e-01 2.150324507557260e-03 +1.230000000000000e-02 1.016114721200506e-02 4.436452683083392e-04 2.881500000000000e+02 3.202843334758530e+01 8.880303872600582e-01 -6.648935997922503e-03 4.597366887174077e-01 2.150324507557260e-03 +1.230000000000000e-02 1.064462798635547e-02 -4.647544947946160e-04 2.881500000000000e+02 2.931124680838526e+01 8.867853340771026e-01 3.559994489771646e-02 4.608084365428229e-01 1.769861196946197e-03 +1.230000000000000e-02 1.064462798635547e-02 4.647544947946160e-04 2.881500000000000e+02 2.931124680838526e+01 8.867853340771027e-01 -4.697625191813431e-03 4.621576609592430e-01 1.769861196946197e-03 +1.230000000000000e-02 1.112810876070589e-02 -4.858637212808926e-04 2.881500000000000e+02 2.511433201771983e+01 8.693698105783823e-01 3.824167144025443e-02 4.926801264718960e-01 1.630487557935555e-03 +1.230000000000000e-02 1.112810876070589e-02 4.858637212808926e-04 2.881500000000000e+02 2.511433201771983e+01 8.693698105783823e-01 -4.843752024720255e-03 4.941383111247607e-01 1.630487557935555e-03 +1.230000000000000e-02 1.161158953505630e-02 -5.069729477671694e-04 2.881500000000000e+02 2.068271201250798e+01 8.609729305189665e-01 3.996702674728404e-02 5.070781494864128e-01 1.435649787184269e-03 +1.230000000000000e-02 1.161158953505630e-02 5.069729477671693e-04 2.881500000000000e+02 2.068271201250798e+01 8.609729305189665e-01 -4.379832605461022e-03 5.086319199381131e-01 1.435649787184269e-03 +1.230000000000000e-02 1.209507030940672e-02 -5.280821742534461e-04 2.881500000000000e+02 1.425021780494439e+01 8.068188357102061e-01 3.404111642689164e-02 5.898174028762109e-01 1.164465134572247e-03 +1.230000000000000e-02 1.209507030940672e-02 5.280821742534461e-04 2.881500000000000e+02 1.425021780494439e+01 8.068188357102061e-01 -1.749439413157761e-02 5.905398483736696e-01 1.164465134572247e-03 +1.230000000000000e-02 1.257855108375714e-02 -5.491914007397227e-04 2.881500000000000e+02 9.891554779527372e+00 7.520381756169899e-01 2.135771076565043e-02 6.587734288854707e-01 1.158624905448327e-03 +1.230000000000000e-02 1.257855108375714e-02 5.491914007397226e-04 2.881500000000000e+02 9.891554779527372e+00 7.520381756169899e-01 -3.613944926881677e-02 6.581280442445954e-01 1.158624905448327e-03 +1.230000000000000e-02 1.306203185810882e-02 -5.703006272260550e-04 2.881500000000000e+02 6.393699027877189e+00 7.203924215589249e-01 -1.774214892046960e-02 6.933397256123091e-01 8.989716122905569e-04 +1.230000000000000e-02 1.306203185810882e-02 5.703006272260548e-04 2.881500000000000e+02 6.393699027877188e+00 7.203924215589250e-01 -7.810317344952432e-02 6.891550284642648e-01 8.989716122905569e-04 +1.230000000000000e-02 1.354551263246073e-02 -5.914098537123968e-04 2.881500000000000e+02 4.159475074460833e+00 6.958121544564141e-01 -1.056173699727177e-01 7.104156648545761e-01 8.550258250599377e-04 +1.230000000000000e-02 1.354551263246073e-02 5.914098537123966e-04 2.881500000000000e+02 4.159475074460833e+00 6.958121544564141e-01 -1.671322689231877e-01 6.985071584424246e-01 8.550258250599377e-04 +1.230000000000000e-02 1.402899340681264e-02 -6.125190801987386e-04 2.881500000000000e+02 3.466774653766527e+00 6.780817593465893e-01 -1.962656943156323e-01 7.082971868334907e-01 7.807626782637281e-04 +1.230000000000000e-02 1.402899340681264e-02 6.125190801987387e-04 2.881500000000000e+02 3.466774653766527e+00 6.780817593465893e-01 -2.572510114990779e-01 6.884962198328582e-01 7.807626782637281e-04 +1.230000000000000e-02 1.451247418116454e-02 -6.336283066850803e-04 2.881500000000000e+02 2.818095933870955e+00 6.413195442631660e-01 -3.269956285048218e-01 6.941059725177575e-01 7.066101318319812e-04 +1.230000000000000e-02 1.451247418116454e-02 6.336283066850801e-04 2.881500000000000e+02 2.818095933870956e+00 6.413195442631658e-01 -3.862466329960522e-01 6.629651428584297e-01 7.066101318319812e-04 diff --git a/TestCases/incomp_rans/morse_swirl_jet/morse_sa.cfg b/TestCases/incomp_rans/morse_swirl_jet/morse_sa.cfg new file mode 100644 index 000000000000..45a3bf2c8fed --- /dev/null +++ b/TestCases/incomp_rans/morse_swirl_jet/morse_sa.cfg @@ -0,0 +1,99 @@ +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% % +% SU2 configuration file % +% Case description: Swirling jet in still air, S = 0.36, Re = 56,000 % +% (Morse 1980, ERCOFTAC Classic case 026), SA, 5 deg wedge % +% Author: Nijso Beishuizen % +% Institution: Bosch Thermotechnology % +% Date: Nov 15th, 2026 % +% File Version 8.6.0 "Harrier" % +% % +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +% ------------- DIRECT, ADJOINT, AND LINEARIZED PROBLEM DEFINITION ------------% +% +SOLVER= INC_RANS +KIND_TURB_MODEL= SA +MATH_PROBLEM= DIRECT +RESTART_SOL= YES + +% ---------------- INCOMPRESSIBLE FLOW CONDITION DEFINITION -------------------% +% +% Air; the far field carries a co-flow of 1% of the jet exit velocity (34.46 m/s). +FLUID_MODEL= CONSTANT_DENSITY +INC_DENSITY_INIT= 1.2 +INC_VELOCITY_INIT= ( 0.345, 0.0, 0.0 ) +INC_NONDIM= DIMENSIONAL + +% --------------------------- VISCOSITY MODEL ---------------------------------% +% +% Re = U_exit D / nu = 56,000 with D = 0.0246 m. +VISCOSITY_MODEL= CONSTANT_VISCOSITY +MU_CONSTANT= 1.82e-05 +FREESTREAM_NU_FACTOR= 3.0 + +% -------------------- BOUNDARY CONDITION DEFINITION --------------------------% +% +% The jet enters at x/D = 0.5 with the profiles measured there (inlet_jet.dat). The far field supplies the +% entrained air through the inlet plane; at r = 30 D it suffices up to x/D = 100. +INC_INLET_TYPE= VELOCITY_INLET +MARKER_INLET= ( inlet_jet, 288.15, 34.10, 1.0, 0.0, 0.0 ) +SPECIFIED_INLET_PROFILE= YES +INLET_FILENAME= inlet_jet.dat +% The outlet is a far field too: a pressure outlet lets a reversed flow enter along the axis. +MARKER_FAR= ( farfield, outlet ) +MARKER_EULER= ( axis ) +MARKER_PERIODIC= ( periodic_1, periodic_2, 0.0, 0.0, 0.0, 5.0, 0.0, 0.0, 0.0, 0.0, 0.0 ) +MARKER_PLOTTING= ( axis ) +MARKER_MONITORING= ( axis ) + +% ------------- COMMON PARAMETERS DEFINING THE NUMERICAL METHOD ---------------% +% +NUM_METHOD_GRAD= GREEN_GAUSS +NUM_METHOD_GRAD_RECON= LEAST_SQUARES +CFL_NUMBER= 25 +CFL_ADAPT= YES +CFL_ADAPT_PARAM= ( 0.5, 1.1, 25, 2500, 0.001 ) +ITER= 1000 + +% ------------------------ LINEAR SOLVER DEFINITION ---------------------------% +% +LINEAR_SOLVER= FGMRES +LINEAR_SOLVER_PREC= ILU +LINEAR_SOLVER_ERROR= 1E-4 +LINEAR_SOLVER_ITER= 50 + +% -------------------- FLOW NUMERICAL METHOD DEFINITION -----------------------% +% +CONV_NUM_METHOD_FLOW= FDS +MUSCL_FLOW= YES +SLOPE_LIMITER_FLOW= VENKATAKRISHNAN +VENKAT_LIMITER_COEFF= 0.05 +TIME_DISCRE_FLOW= EULER_IMPLICIT + +% -------------------- TURBULENT NUMERICAL METHOD DEFINITION ------------------% +% +CONV_NUM_METHOD_TURB= SCALAR_UPWIND +MUSCL_TURB= NO +TIME_DISCRE_TURB= EULER_IMPLICIT + +% --------------------------- CONVERGENCE PARAMETERS --------------------------% +% +CONV_FIELD= RMS_PRESSURE +CONV_RESIDUAL_MINVAL= -10 +CONV_STARTITER= 10 + +% ------------------------- INPUT/OUTPUT INFORMATION --------------------------% +% +MESH_FILENAME= morse_wedge.su2 +MESH_FORMAT= SU2 +SOLUTION_FILENAME= solution_flow +RESTART_FILENAME= restart_flow +CONV_FILENAME= history +VOLUME_FILENAME= flow +SCREEN_OUTPUT= INNER_ITER, RMS_PRESSURE, RMS_VELOCITY-X, RMS_NU_TILDE, LINSOL_ITER, LINSOL_RESIDUAL, AVG_CFL +HISTORY_OUTPUT= ITER, RMS_RES, CFL_NUMBER +VOLUME_OUTPUT= COORDINATES, SOLUTION, PRIMITIVE, RESIDUAL +OUTPUT_FILES= RESTART, RESTART_ASCII, PARAVIEW +WRT_RESTART_COMPACT= NO +OUTPUT_WRT_FREQ= 100 diff --git a/TestCases/incomp_rans/morse_swirl_jet/morse_wedge.geo b/TestCases/incomp_rans/morse_swirl_jet/morse_wedge.geo new file mode 100644 index 000000000000..8e0323d752c5 --- /dev/null +++ b/TestCases/incomp_rans/morse_swirl_jet/morse_wedge.geo @@ -0,0 +1,100 @@ +// Structured wedge mesh for the Morse swirling jet (ERCOFTAC C26). +// The x-r plane is meshed at theta = -angle/2 and rotated about the jet axis (x) by the wedge angle, one cell thick. +// A slip wall at r = rmin replaces the axis, so all cells are hexahedra. Lengths are in nozzle diameters times D. +// +// gmsh morse_wedge.geo -3 -format su2 -o morse_wedge.su2 +// +// The mesh must be 3D (-3); a 2D mesh gives a file without volume elements. + +D = 0.0246; // nozzle diameter [m] +angle = 5; // wedge angle [deg] +x0 = 0.5; // inlet plane, x/D +xmax = 50; // outlet plane, x/D +rmin = 0.02; // slip wall replacing the axis, r/D +rjet = 0.5905; // outer radius of the measured inlet profile, r/D +rfine = 4; // end of the uniform radial spacing, r/D +rmax = 30; // far-field radius, r/D +dr = 0.02; // uniform radial spacing, r/D +dx0 = 0.02; // axial spacing at the inlet, x/D +dxmax = 0.25; // largest axial spacing, x/D +g = 1.03; // growth ratio of stretched spacings + +// Cells per segment: axial spacing grows from dx0 to dxmax, then stays uniform. +nx1 = Ceil(Log(dxmax / dx0) / Log(g)); +xg = x0 + dx0 * (g^nx1 - 1) / (g - 1); +nx2 = Round((xmax - xg) / dxmax); +nr1 = Round((rjet - rmin) / dr); +nr2 = Round((rfine - rjet) / dr); +nr3 = Round(Log(1 + (rmax - rfine) * (g - 1) / dr) / Log(g)); + +xs[] = {x0, xg, xmax}; +rs[] = {rmin, rjet, rfine, rmax}; +nxs[] = {nx1, nx2}; +gxs[] = {g, 1}; +nrs[] = {nr1, nr2, nr3}; +grs[] = {1, 1, g}; +a = -0.5 * angle * Pi / 180; + +For i In {0:2} + For j In {0:3} + p = newp; + Point(p) = {xs[i] * D, rs[j] * D * Cos(a), rs[j] * D * Sin(a)}; + P[i * 4 + j] = p; + EndFor +EndFor + +// Lines of constant r (H) and of constant x (V), all oriented towards larger x or r. +For i In {0:1} + For j In {0:3} + l = newl; + Line(l) = {P[i * 4 + j], P[(i + 1) * 4 + j]}; + Transfinite Curve{l} = nxs[i] + 1 Using Progression gxs[i]; + H[i * 4 + j] = l; + EndFor +EndFor +For i In {0:2} + For j In {0:2} + l = newl; + Line(l) = {P[i * 4 + j], P[i * 4 + j + 1]}; + Transfinite Curve{l} = nrs[j] + 1 Using Progression grs[j]; + V[i * 3 + j] = l; + EndFor +EndFor + +For i In {0:1} + For j In {0:2} + cl = newcl; + Curve Loop(cl) = {H[i * 4 + j], V[(i + 1) * 3 + j], -H[i * 4 + j + 1], -V[i * 3 + j]}; + s = news; + Plane Surface(s) = {cl}; + Transfinite Surface{s}; + Recombine Surface{s}; + S[i * 3 + j] = s; + EndFor +EndFor + +ext[] = Extrude {{1, 0, 0}, {0, 0, 0}, angle * Pi / 180} { Surface{S[]}; Layers{1}; Recombine; }; + +// Extrude returns, per source surface, the rotated copy, the volume and the four side surfaces. +For k In {0:5} + top[k] = ext[6 * k]; + vol[k] = ext[6 * k + 1]; +EndFor + +e = 1e-4 * D; +big = 2 * rmax * D; +inlet[] = Surface In BoundingBox{x0 * D - e, -big, -big, x0 * D + e, big, big}; +jet[] = Surface In BoundingBox{x0 * D - e, -big, -big, x0 * D + e, rjet * D + e, big}; +outlet[] = Surface In BoundingBox{xmax * D - e, -big, -big, xmax * D + e, big, big}; +axis[] = Surface In BoundingBox{x0 * D - e, -big, -big, xmax * D + e, rmin * D + e, big}; +side[] = Surface In BoundingBox{x0 * D - e, rmax * D * Cos(a) - e, -big, xmax * D + e, rmax * D + e, big}; +open[] = inlet[]; +open[] -= jet[]; + +Physical Surface("inlet_jet") = {jet[]}; +Physical Surface("farfield") = {open[], side[]}; +Physical Surface("outlet") = {outlet[]}; +Physical Surface("axis") = {axis[]}; +Physical Surface("periodic_1") = {S[]}; +Physical Surface("periodic_2") = {top[]}; +Physical Volume("fluid") = {vol[]}; diff --git a/TestCases/parallel_regression.py b/TestCases/parallel_regression.py index fe4214a965f2..a056a72a1133 100755 --- a/TestCases/parallel_regression.py +++ b/TestCases/parallel_regression.py @@ -397,7 +397,7 @@ def main(): flatplate_udobj.cfg_dir = "user_defined_functions" flatplate_udobj.cfg_file = "lam_flatplate.cfg" flatplate_udobj.test_iter = 20 - flatplate_udobj.test_vals = [-0.001015, 596.450000, 299.550000, 296.900000, 21.318000, 0.586640, 36.553000, 2.188800] + flatplate_udobj.test_vals = [-0.002654, 597.560000, 299.980000, 297.580000, 23.837000, 0.682260, 38.421000, 4.051900] test_list.append(flatplate_udobj) # Probe performance test (11 probes, ADT path) @@ -405,7 +405,7 @@ def main(): probe_performance_11.cfg_dir = "user_defined_functions" probe_performance_11.cfg_file = "test_11_probes.cfg" probe_performance_11.test_iter = 4 - probe_performance_11.test_vals = [-6.290748, 101020, 101050, 99123] # RMS_DENSITY, probe1, probe6, probe11 + probe_performance_11.test_vals = [-6.262158, 100860.000000, 99454.000000, 98936.000000] # RMS_DENSITY, probe1, probe6, probe11 # Tolerances are typically 0.001 in TestCase.py test_list.append(probe_performance_11) @@ -459,7 +459,7 @@ def main(): periodic2d_no_limiter.cfg_dir = "navierstokes/periodic2D" periodic2d_no_limiter.cfg_file = "no_limiter.cfg" periodic2d_no_limiter.test_iter = 100 - periodic2d_no_limiter.test_vals = [-3.216881, -0.582813, -0.629049, 2.266141, -1.056877, -811.470000] + periodic2d_no_limiter.test_vals = [-3.285602, -0.612937, -0.682765, 2.194736, -1.019117, -952.960000] test_list.append(periodic2d_no_limiter) # 2D rotational periodic sector with multigrid @@ -467,7 +467,7 @@ def main(): periodic2d_multigrid.cfg_dir = "navierstokes/periodic2D" periodic2d_multigrid.cfg_file = "multigrid.cfg" periodic2d_multigrid.test_iter = 300 - periodic2d_multigrid.test_vals = [-4.422778, -1.615251, -1.453736, 1.047350, -1.410225, -2060.600000] + periodic2d_multigrid.test_vals = [-4.405188, -1.589621, -1.470131, 1.066630, -1.430812, -2072.000000] test_list.append(periodic2d_multigrid) # 2D rotational periodic sector with limiter @@ -475,7 +475,7 @@ def main(): periodic2d.cfg_dir = "navierstokes/periodic2D" periodic2d.cfg_file = "config.cfg" periodic2d.test_iter = 100 - periodic2d.test_vals = [-3.266248, -0.617784, -0.620252, 2.216476, -1.007761, -1035.000000] + periodic2d.test_vals = [-3.308159, -0.637985, -0.693116, 2.172259, -1.021650, -958.960000] test_list.append(periodic2d) ########################## @@ -876,7 +876,7 @@ def main(): sp_pipeSlice_3d_dp_hf_tp.cfg_dir = "incomp_navierstokes/streamwise_periodic/pipeSlice_3d" sp_pipeSlice_3d_dp_hf_tp.cfg_file = "sp_pipeSlice_3d_dp_hf_tp.cfg" sp_pipeSlice_3d_dp_hf_tp.test_iter = 10 - sp_pipeSlice_3d_dp_hf_tp.test_vals = [-11.119796, -11.234737, -9.429479, -0.000023] + sp_pipeSlice_3d_dp_hf_tp.test_vals = [-13.241550, -13.260364, -10.953558, -0.000025] test_list.append(sp_pipeSlice_3d_dp_hf_tp) # 2D pin array with heat transfer BC on pin surfaces @@ -899,6 +899,14 @@ def main(): inc_turb_naca0012.test_vals = [-4.758064, -10.974498, -0.000005, -0.028653, 3, -5.740545, 2, -5.036110] test_list.append(inc_turb_naca0012) + # Swirling jet on a one-cell wedge, rotational periodicity (Morse 1980) + inc_turb_morse_swirl_jet = TestCase('inc_turb_morse_swirl_jet') + inc_turb_morse_swirl_jet.cfg_dir = "incomp_rans/morse_swirl_jet" + inc_turb_morse_swirl_jet.cfg_file = "morse_sa.cfg" + inc_turb_morse_swirl_jet.test_iter = 10 + inc_turb_morse_swirl_jet.test_vals = [-10.168926, -7.347914, -8.685155, 13.000000, -4.156951, 71.328000] + test_list.append(inc_turb_morse_swirl_jet) + # NACA0012, SST_SUST inc_turb_naca0012_sst_sust = TestCase('inc_turb_naca0012_sst_sust') inc_turb_naca0012_sst_sust.cfg_dir = "incomp_rans/naca0012" @@ -1284,7 +1292,7 @@ def main(): sbs_backward_step.cfg_dir = "backscatter/backward_step" sbs_backward_step.cfg_file = "backwardStep.cfg" sbs_backward_step.test_iter = 3 - sbs_backward_step.test_vals = [-6.352884, -3.465372, -5.507901, -3.906545, -9.506305, -6.365236, -6.331021, -6.331028] + sbs_backward_step.test_vals = [-6.353146, -3.465452, -5.470619, -3.906555, -9.506332, -6.365239, -6.331024, -6.331030] sbs_backward_step.unsteady = True sbs_backward_step.decompress = True sbs_backward_step.grid_file = "backward_step.su2" @@ -1304,7 +1312,7 @@ def main(): flatplate_unsteady.cfg_dir = "navierstokes/flatplate" flatplate_unsteady.cfg_file = "lam_flatplate_unst.cfg" flatplate_unsteady.test_iter = 3 - flatplate_unsteady.test_vals = [0.000008, -8.875128, -8.250204, -6.305788, -5.469452, -3.398230, 0.002075, -0.325535] + flatplate_unsteady.test_vals = [0.000008, -8.875141, -8.250617, -6.305804, -5.469459, -3.398234, 0.002074, -0.310165] flatplate_unsteady.unsteady = True test_list.append(flatplate_unsteady) @@ -1364,7 +1372,7 @@ def main(): Aachen_3D_restart.cfg_file = "aachen_3D_MP_restart.cfg" Aachen_3D_restart.test_iter = 5 Aachen_3D_restart.tol = 0.00001 - Aachen_3D_restart.test_vals = [-7.688483, -8.466346, -6.035067, -6.425967, -5.820125, -4.597817, -5.528297, -5.301466, -3.819862, -5.242356, -5.738805, -3.630202, -2.213240, -2.857919, -0.576864] + Aachen_3D_restart.test_vals = [-7.688485, -8.467588, -6.035067, -6.427338, -5.819784, -4.597818, -5.529569, -5.305004, -3.819863, -5.242440, -5.756583, -3.630202, -2.213244, -2.860891, -0.576864] test_list.append(Aachen_3D_restart) # Jones APU Turbocharger restart @@ -1372,7 +1380,7 @@ def main(): Jones_tc_restart.cfg_dir = "turbomachinery/APU_turbocharger" Jones_tc_restart.cfg_file = "Jones_restart.cfg" Jones_tc_restart.test_iter = 5 - Jones_tc_restart.test_vals = [-11.905727, -12.211201, -19.212537, -13.508616, -19.078613, -13.445675, 73286.000000, 73286.000000, 0.020056, 82.286000] + Jones_tc_restart.test_vals = [-11.914198, -12.203720, -19.150460, -13.443363, -19.037618, -13.395928, 73286.000000, 73286.000000, 0.020056, 82.286000] test_list.append(Jones_tc_restart) # 2D axial stage @@ -1380,7 +1388,7 @@ def main(): axial_stage2D.cfg_dir = "turbomachinery/axial_stage_2D" axial_stage2D.cfg_file = "Axial_stage2D.cfg" axial_stage2D.test_iter = 20 - axial_stage2D.test_vals = [1.167500, 1.598546, -2.928573, 2.573647, -2.527331, 3.016254, 106370.000000, 106370.000000, 5.726800, 64.383000] + axial_stage2D.test_vals = [1.176763, 1.601270, -2.961800, 2.541146, -2.531370, 3.013521, 106390.000000, 106390.000000, 5.735500, 64.426000] test_list.append(axial_stage2D) # 2D transonic stator restart @@ -1388,7 +1396,7 @@ def main(): transonic_stator_restart.cfg_dir = "turbomachinery/transonic_stator_2D" transonic_stator_restart.cfg_file = "transonic_stator_restart.cfg" transonic_stator_restart.test_iter = 20 - transonic_stator_restart.test_vals = [-4.365636, -2.482248, -2.081252, 1.729763, -1.467305, 3.231073, -471620.000000, 94.837000, -0.046834] + transonic_stator_restart.test_vals = [-4.389126, -2.515434, -2.103674, 1.706003, -1.488483, 3.231947, -471620.000000, 94.841000, -0.046801] transonic_stator_restart.test_vals_aarch64 = [-4.437809, -2.553049, -2.164729, 1.657542, -1.356823, 3.178788, -471620.000000, 94.842000, -0.040365] test_list.append(transonic_stator_restart) @@ -1397,7 +1405,7 @@ def main(): multi_interface.cfg_dir = "turbomachinery/multi_interface" multi_interface.cfg_file = "multi_interface_rst.cfg" multi_interface.test_iter = 5 - multi_interface.test_vals = [-8.634558, -8.895554, -9.348754] + multi_interface.test_vals = [-8.633076, -8.894747, -9.348617] multi_interface.test_vals_aarch64 = [-8.632227, -8.894736, -9.348706] test_list.append(multi_interface) @@ -1480,7 +1488,7 @@ def main(): bars_SST_2D.cfg_dir = "sliding_interface/bars_SST_2D" bars_SST_2D.cfg_file = "bars.cfg" bars_SST_2D.test_iter = 13 - bars_SST_2D.test_vals = [13.000000, -0.464267, -1.541047] + bars_SST_2D.test_vals = [13.000000, -0.464304, -1.546997] bars_SST_2D.multizone = True test_list.append(bars_SST_2D) @@ -1617,7 +1625,7 @@ def main(): solid_periodic_pins.cfg_dir = "solid_heat_conduction/periodic_pins" solid_periodic_pins.cfg_file = "configSolid.cfg" solid_periodic_pins.test_iter = 750 - solid_periodic_pins.test_vals = [-15.878962, -14.569206, 300.900000, 425.320000, 5.000000, -1.672653] + solid_periodic_pins.test_vals = [-15.931359, -14.386112, 300.900000, 425.320000, 0.000000, -14.007572] solid_periodic_pins.test_vals_aarch64 = [-15.879016, -14.569206, 300.900000, 425.320000, 5.000000, -1.672666] test_list.append(solid_periodic_pins) diff --git a/TestCases/serial_regression.py b/TestCases/serial_regression.py index 2dcd75403859..e152406b2d73 100755 --- a/TestCases/serial_regression.py +++ b/TestCases/serial_regression.py @@ -216,7 +216,7 @@ def main(): poiseuille.cfg_dir = "navierstokes/poiseuille" poiseuille.cfg_file = "lam_poiseuille.cfg" poiseuille.test_iter = 10 - poiseuille.test_vals = [-7.597002, -6.994814, 0.012154, 13.596296, 0] + poiseuille.test_vals = [-7.597001, -6.994813, 0.012127, 13.596354, 0.000000] test_list.append(poiseuille) # 2D Poiseuille flow (inlet profile file) @@ -936,7 +936,7 @@ def main(): ls89_sa.cfg_dir = "nicf/LS89" ls89_sa.cfg_file = "turb_SA_PR.cfg" ls89_sa.test_iter = 20 - ls89_sa.test_vals = [-5.041500, -13.379523, 0.179019, 0.420831] + ls89_sa.test_vals = [-5.047026, -13.385356, 0.179168, 0.421262] test_list.append(ls89_sa) # Rarefaction shock wave edge_VW @@ -965,7 +965,7 @@ def main(): Aachen_3D_restart.cfg_dir = "turbomachinery/Aachen_turbine" Aachen_3D_restart.cfg_file = "aachen_3D_MP_restart.cfg" Aachen_3D_restart.test_iter = 5 - Aachen_3D_restart.test_vals = [-7.689117, -8.476204, -6.036107, -6.427402, -5.831576, -4.599024, -5.530512, -5.305687, -3.821789, -5.243255, -5.754831, -3.631603, -2.213934, -2.895728, -0.578545] + Aachen_3D_restart.test_vals = [-7.690756, -8.480220, -6.040279, -6.426434, -5.831445, -4.598589, -5.536489, -5.307971, -3.830619, -5.244603, -5.766097, -3.635129, -2.215856, -2.900116, -0.583139] Aachen_3D_restart.enabled_with_asan = False test_list.append(Aachen_3D_restart) @@ -974,7 +974,7 @@ def main(): Jones_tc_restart.cfg_dir = "turbomachinery/APU_turbocharger" Jones_tc_restart.cfg_file = "Jones_restart.cfg" Jones_tc_restart.test_iter = 5 - Jones_tc_restart.test_vals = [-11.905629, -12.211684, -19.212618, -13.507994, -19.069281, -13.439288, 73286.000000, 73286.000000, 0.020056, 82.286000] + Jones_tc_restart.test_vals = [-11.913929, -12.201923, -19.149798, -13.441884, -19.033169, -13.395061, 73286.000000, 73286.000000, 0.020056, 82.286000] test_list.append(Jones_tc_restart) # 2D axial stage @@ -982,7 +982,7 @@ def main(): axial_stage2D.cfg_dir = "turbomachinery/axial_stage_2D" axial_stage2D.cfg_file = "Axial_stage2D.cfg" axial_stage2D.test_iter = 20 - axial_stage2D.test_vals = [1.167521, 1.598536, -2.928575, 2.573646, -2.527330, 3.016253, 106370.000000, 106370.000000, 5.726800, 64.383000] + axial_stage2D.test_vals = [1.177225, 1.602363, -2.962970, 2.540072, -2.535614, 3.008265, 106390.000000, 106390.000000, 5.735500, 64.426000] test_list.append(axial_stage2D) # 2D transonic stator restart @@ -990,7 +990,7 @@ def main(): transonic_stator_restart.cfg_dir = "turbomachinery/transonic_stator_2D" transonic_stator_restart.cfg_file = "transonic_stator_restart.cfg" transonic_stator_restart.test_iter = 20 - transonic_stator_restart.test_vals = [-4.367784, -2.492912, -2.082414, 1.727491, -1.466974, 3.224730, -471620.000000, 94.839000, -0.052082] + transonic_stator_restart.test_vals = [-4.391061, -2.520781, -2.103750, 1.703960, -1.488302, 3.226640, -471620.000000, 94.842000, -0.051820] transonic_stator_restart.test_vals_aarch64 = [-4.367784, -2.492912, -2.082414, 1.727491, -1.466974, 3.224730, -471620.000000, 94.839000, -0.052082] test_list.append(transonic_stator_restart) @@ -999,7 +999,7 @@ def main(): multi_interface.cfg_dir = "turbomachinery/multi_interface" multi_interface.cfg_file = "multi_interface_rst.cfg" multi_interface.test_iter = 5 - multi_interface.test_vals = [-8.634558, -8.895554, -9.348754] + multi_interface.test_vals = [-8.632926, -8.895296, -9.348618] multi_interface.test_vals_aarch64 = [-8.632227, -8.894736, -9.348706] test_list.append(multi_interface) @@ -1094,7 +1094,7 @@ def main(): bars_SST_2D.cfg_dir = "sliding_interface/bars_SST_2D" bars_SST_2D.cfg_file = "bars.cfg" bars_SST_2D.test_iter = 13 - bars_SST_2D.test_vals = [13.000000, -0.462697, -1.541051] + bars_SST_2D.test_vals = [13.000000, -0.462739, -1.546996] bars_SST_2D.multizone = True test_list.append(bars_SST_2D) From 479c107aab46b8cedf2bfead831a30cc89c4d464 Mon Sep 17 00:00:00 2001 From: bigfooted Date: Sat, 21 Nov 2026 12:18:50 +0100 Subject: [PATCH 02/13] Couple only fully fitting periodic points; fix quantized accumulation - Accumulating SetBlock is a no-op on quantized (Q_LU_SGS) off-diagonal blocks, so the moved blocks were dropped. Quantized blocks are now decoded, added and re-encoded; full-precision blocks keep the in-place addition, so results are unchanged bit for bit. - A passive point is coupled only if every moved block exists in the sparsity pattern of its master. On thicker periodic meshes only the along-face blocks fit; moving those alone slowed the discrete adjoint (transonic_stator AD from -7.31 to -6.76 at iteration 79). Now these meshes behave as on develop, and one-cell wedges and slices keep the full coupling. - Loops run over a list of the coupled passive points instead of all points. - CompletePeriodicComms comments named the wrong marker as master. - Regression values: periodic tests without coupled points are back to their develop values; Morse (after #3014) and the two pipeSlice tests use the values computed by CI. Co-Authored-By: Claude Opus 5.5 --- .../include/solvers/CFVMFlowSolverBase.hpp | 2 +- SU2_CFD/include/solvers/CSolver.hpp | 8 +- SU2_CFD/src/solvers/CSolver.cpp | 88 +++++++++++++------ TestCases/parallel_regression.py | 34 +++---- TestCases/serial_regression.py | 16 ++-- 5 files changed, 90 insertions(+), 58 deletions(-) diff --git a/SU2_CFD/include/solvers/CFVMFlowSolverBase.hpp b/SU2_CFD/include/solvers/CFVMFlowSolverBase.hpp index 23e9d8c1a639..214a74bdac70 100644 --- a/SU2_CFD/include/solvers/CFVMFlowSolverBase.hpp +++ b/SU2_CFD/include/solvers/CFVMFlowSolverBase.hpp @@ -444,7 +444,7 @@ class CFVMFlowSolverBase : public CSolver { ompMasterAssignBarrier(Min_Delta_Time,1e30, Max_Delta_Time,0.0, Global_Delta_UnstTimeND,1e30); - /*--- Edges between a point and its own periodic image carry only the rotation of the state. ---*/ + /*--- Edges between a point and its periodic image are left out, their states are tied. ---*/ const bool skipImages = implicit_periodic; if (skipImages) SetPeriodicMaster(geometry, config); diff --git a/SU2_CFD/include/solvers/CSolver.hpp b/SU2_CFD/include/solvers/CSolver.hpp index 5d3c26c67f0d..27ef57df94a1 100644 --- a/SU2_CFD/include/solvers/CSolver.hpp +++ b/SU2_CFD/include/solvers/CSolver.hpp @@ -149,8 +149,9 @@ class CSolver { bool implicit_periodic; /*!< \brief Flag that controls whether the implicit system should be treated by the periodic BC comms. */ su2activematrix PeriodicProj; /*!< \brief Min/max reconstruction increments at periodic receive points (for limiters). */ std::unordered_map PeriodicProjIndex; /*!< \brief Local point to compact projection row. */ - vector PeriodicMaster; /*!< \brief Local master point of each passive periodic point on this rank, or -1. */ + vector PeriodicMaster; /*!< \brief Local master point of each coupled passive periodic point, or -1. */ vector PeriodicMasterMarker; /*!< \brief Periodic marker of each passive point, gives its rotation. */ + vector PeriodicPassive; /*!< \brief Coupled passive periodic points. */ bool dynamic_grid; /*!< \brief Flag that determines whether the grid is dynamic (moving or deforming + grid velocities). */ @@ -330,12 +331,13 @@ class CSolver { /*! * \brief Move the off-diagonal Jacobian blocks of passive periodic points to their masters, rotated. - * \note Call before the PERIODIC_RESIDUAL comms. Only masters on the same rank and blocks in the sparsity pattern are coupled. + * \note Call before the PERIODIC_RESIDUAL comms. A passive point is coupled if its master is on the same rank and + * all its blocks fit in the sparsity pattern. */ void CouplePeriodicJacobian(CGeometry *geometry, const CConfig *config); /*! - * \brief Map each passive periodic point to its master on the same rank (built once). + * \brief Map each coupled passive periodic point to its master on the same rank (built once). */ void SetPeriodicMaster(CGeometry *geometry, const CConfig *config); diff --git a/SU2_CFD/src/solvers/CSolver.cpp b/SU2_CFD/src/solvers/CSolver.cpp index 9140200db186..1d1b281f0e3a 100644 --- a/SU2_CFD/src/solvers/CSolver.cpp +++ b/SU2_CFD/src/solvers/CSolver.cpp @@ -1276,7 +1276,7 @@ void CSolver::CompletePeriodicComms(CGeometry *geometry, base_nodes->SetDelta_Time(iPoint,bufDRecv[buf_offset]); buf_offset++; - /*--- For implicit integration, we choose the first + /*--- For implicit integration, we choose the second periodic face of each pair to be the master/owner of the solution for the linear system while fixing the solution at the matching face during the solve. Here, @@ -1308,7 +1308,7 @@ void CSolver::CompletePeriodicComms(CGeometry *geometry, case PERIODIC_IMPLICIT: - /*--- For implicit integration, we choose the first + /*--- For implicit integration, we choose the second periodic face of each pair to be the master/owner of the solution for the linear system while fixing the solution at the matching face during the solve. Here, @@ -4670,6 +4670,28 @@ void CSolver::SetPeriodicMaster(CGeometry *geometry, const CConfig *config) { if (nPeriodicMarker[iPoint] != 1 || nPeriodicMarker[master] != 1 || passive[master]) PeriodicMaster[iPoint] = -1; } + + /*--- A point is coupled only if all its blocks fit in the sparsity pattern of its master. Columns of passive + * points without a master are ignored, their increment is zero in the linear system. ---*/ + if (implicit_periodic) { + for (auto iPoint = 0ul; iPoint < nPointAll; iPoint++) { + const auto master = PeriodicMaster[iPoint]; + if (master < 0) continue; + bool fits = true; + for (const auto kPoint : geometry->nodes->GetPoints(iPoint)) { + if (iPoint < nPointDomain && (!passive[kPoint] || PeriodicMaster[kPoint] >= 0)) { + const unsigned long col = passive[kPoint] ? PeriodicMaster[kPoint] : kPoint; + fits = fits && Jacobian.GetBlockView(master, col); + } + if (kPoint < nPointDomain && !passive[kPoint]) fits = fits && Jacobian.GetBlockView(kPoint, master); + } + if (!fits) PeriodicMaster[iPoint] = -1; + } + } + + PeriodicPassive.clear(); + for (auto iPoint = 0ul; iPoint < nPointAll; iPoint++) + if (PeriodicMaster[iPoint] >= 0) PeriodicPassive.push_back(iPoint); } } @@ -4702,7 +4724,7 @@ void CSolver::CouplePeriodicJacobian(CGeometry *geometry, const CConfig *config) return true; }; - su2activematrix block(nVar, nVar), zero(nVar, nVar); + su2activematrix block(nVar, nVar), sum(nVar, nVar), zero(nVar, nVar); zero = su2double(0.0); su2double v[3]; @@ -4715,13 +4737,25 @@ void CSolver::CouplePeriodicJacobian(CGeometry *geometry, const CConfig *config) return true; }; + /*--- Add block to an existing block. Quantized storage cannot accumulate, it is decoded, added and re-encoded. ---*/ + auto AddBlock = [&](unsigned long iRow, unsigned long iCol) { + const auto view = Jacobian.GetBlockView(iRow, iCol); + if (view.ptr) { + Jacobian.SetBlock(iRow, iCol, block); + return; + } + for (auto i = 0u; i < nVar; i++) + for (auto j = 0u; j < nVar; j++) sum(i, j) = view(i, j) + block(i, j); + Jacobian.SetBlock(iRow, iCol, sum); + }; + auto RotateRows = [&](const su2double (&Q)[3][3]) { for (auto c = 0u; c < nVar; c++) { for (auto d = 0u; d < nDim; d++) v[d] = block(1 + d, c); for (auto d = 0u; d < nDim; d++) { - su2double sum = 0.0; - for (auto e = 0u; e < nDim; e++) sum += Q[d][e] * v[e]; - block(1 + d, c) = sum; + su2double s = 0.0; + for (auto e = 0u; e < nDim; e++) s += Q[d][e] * v[e]; + block(1 + d, c) = s; } } }; @@ -4731,9 +4765,9 @@ void CSolver::CouplePeriodicJacobian(CGeometry *geometry, const CConfig *config) for (auto r = 0u; r < nVar; r++) { for (auto d = 0u; d < nDim; d++) v[d] = block(r, 1 + d); for (auto d = 0u; d < nDim; d++) { - su2double sum = 0.0; - for (auto e = 0u; e < nDim; e++) sum += v[e] * Q[d][e]; - block(r, 1 + d) = sum; + su2double s = 0.0; + for (auto e = 0u; e < nDim; e++) s += v[e] * Q[d][e]; + block(r, 1 + d) = s; } } }; @@ -4741,36 +4775,32 @@ void CSolver::CouplePeriodicJacobian(CGeometry *geometry, const CConfig *config) su2double Qp[3][3], Qk[3][3]; /*--- Rows of passive points go to the rows of their masters. ---*/ - for (auto iPoint = 0ul; iPoint < nPointDomain; iPoint++) { + for (const auto iPoint : PeriodicPassive) { + if (iPoint >= nPointDomain) continue; const auto master = PeriodicMaster[iPoint]; - if (master < 0) continue; const bool rotP = Rotation(PeriodicMasterMarker[iPoint], Qp); for (const auto kPoint : geometry->nodes->GetPoints(iPoint)) { - if (!ReadBlock(iPoint, kPoint)) continue; - - long col = kPoint; - if (PeriodicMaster[kPoint] >= 0) { - col = PeriodicMaster[kPoint]; - if (Rotation(PeriodicMasterMarker[kPoint], Qk)) RotateColumns(Qk); - } + const bool kPassive = PeriodicMaster[kPoint] >= 0; + const unsigned long col = kPassive ? PeriodicMaster[kPoint] : kPoint; + if (!Jacobian.GetBlockView(master, col) || !ReadBlock(iPoint, kPoint)) continue; + if (kPassive && Rotation(PeriodicMasterMarker[kPoint], Qk)) RotateColumns(Qk); if (rotP) RotateRows(Qp); - - Jacobian.SetBlock(master, col, block); + AddBlock(master, col); } } /*--- Columns of passive points go to the columns of their masters. ---*/ - for (auto iPoint = 0ul; iPoint < nPointDomain; iPoint++) { - if (PeriodicMaster[iPoint] >= 0) continue; + for (const auto iPoint : PeriodicPassive) { + const auto master = PeriodicMaster[iPoint]; + const bool rotP = Rotation(PeriodicMasterMarker[iPoint], Qp); - for (const auto kPoint : geometry->nodes->GetPoints(iPoint)) { - const auto master = PeriodicMaster[kPoint]; - if (master < 0) continue; - if (!Jacobian.GetBlockView(iPoint, master) || !ReadBlock(iPoint, kPoint)) continue; - if (Rotation(PeriodicMasterMarker[kPoint], Qk)) RotateColumns(Qk); - Jacobian.SetBlock(iPoint, master, block); - Jacobian.SetBlock(iPoint, kPoint, zero); + for (const auto jPoint : geometry->nodes->GetPoints(iPoint)) { + if (jPoint >= nPointDomain || PeriodicMaster[jPoint] >= 0) continue; + if (!Jacobian.GetBlockView(jPoint, master) || !ReadBlock(jPoint, iPoint)) continue; + if (rotP) RotateColumns(Qp); + AddBlock(jPoint, master); + Jacobian.SetBlock(jPoint, iPoint, zero); } } diff --git a/TestCases/parallel_regression.py b/TestCases/parallel_regression.py index 2a7fc19f8b32..a7bdf3ef2f82 100755 --- a/TestCases/parallel_regression.py +++ b/TestCases/parallel_regression.py @@ -397,7 +397,7 @@ def main(): flatplate_udobj.cfg_dir = "user_defined_functions" flatplate_udobj.cfg_file = "lam_flatplate.cfg" flatplate_udobj.test_iter = 20 - flatplate_udobj.test_vals = [-0.002654, 597.560000, 299.980000, 297.580000, 23.837000, 0.682260, 38.421000, 4.051900] + flatplate_udobj.test_vals = [-0.001015, 596.450000, 299.550000, 296.900000, 21.318000, 0.586640, 36.553000, 2.188800] test_list.append(flatplate_udobj) # Probe performance test (11 probes, ADT path) @@ -405,7 +405,7 @@ def main(): probe_performance_11.cfg_dir = "user_defined_functions" probe_performance_11.cfg_file = "test_11_probes.cfg" probe_performance_11.test_iter = 4 - probe_performance_11.test_vals = [-6.262158, 100860.000000, 99454.000000, 98936.000000] # RMS_DENSITY, probe1, probe6, probe11 + probe_performance_11.test_vals = [-6.290748, 101020, 101050, 99123] # RMS_DENSITY, probe1, probe6, probe11 # Tolerances are typically 0.001 in TestCase.py test_list.append(probe_performance_11) @@ -459,7 +459,7 @@ def main(): periodic2d_no_limiter.cfg_dir = "navierstokes/periodic2D" periodic2d_no_limiter.cfg_file = "no_limiter.cfg" periodic2d_no_limiter.test_iter = 100 - periodic2d_no_limiter.test_vals = [-3.285602, -0.612937, -0.682765, 2.194736, -1.019117, -952.960000] + periodic2d_no_limiter.test_vals = [-3.216881, -0.582813, -0.629049, 2.266141, -1.056877, -811.470000] test_list.append(periodic2d_no_limiter) # 2D rotational periodic sector with multigrid @@ -467,7 +467,7 @@ def main(): periodic2d_multigrid.cfg_dir = "navierstokes/periodic2D" periodic2d_multigrid.cfg_file = "multigrid.cfg" periodic2d_multigrid.test_iter = 300 - periodic2d_multigrid.test_vals = [-4.405188, -1.589621, -1.470131, 1.066630, -1.430812, -2072.000000] + periodic2d_multigrid.test_vals = [-4.422778, -1.615251, -1.453736, 1.047350, -1.410225, -2060.600000] test_list.append(periodic2d_multigrid) # 2D rotational periodic sector with limiter @@ -475,7 +475,7 @@ def main(): periodic2d.cfg_dir = "navierstokes/periodic2D" periodic2d.cfg_file = "config.cfg" periodic2d.test_iter = 100 - periodic2d.test_vals = [-3.308159, -0.637985, -0.693116, 2.172259, -1.021650, -958.960000] + periodic2d.test_vals = [-3.266248, -0.617784, -0.620252, 2.216476, -1.007761, -1035.000000] test_list.append(periodic2d) ########################## @@ -894,7 +894,7 @@ def main(): sp_pipeSlice_3d_dp_hf_tp.cfg_dir = "incomp_navierstokes/streamwise_periodic/pipeSlice_3d" sp_pipeSlice_3d_dp_hf_tp.cfg_file = "sp_pipeSlice_3d_dp_hf_tp.cfg" sp_pipeSlice_3d_dp_hf_tp.test_iter = 10 - sp_pipeSlice_3d_dp_hf_tp.test_vals = [-13.241550, -13.260364, -10.953558, -0.000025] + sp_pipeSlice_3d_dp_hf_tp.test_vals = [-13.241752, -13.260502, -10.953562, -0.000025] test_list.append(sp_pipeSlice_3d_dp_hf_tp) # Same with the energy equation, periodic temperature and an integrated wall heat @@ -902,7 +902,7 @@ def main(): sp_pipeSlice_3d_dp_ihf_tp.cfg_dir = "incomp_navierstokes/streamwise_periodic/pipeSlice_3d" sp_pipeSlice_3d_dp_ihf_tp.cfg_file = "sp_pipeSlice_3d_dp_ihf_tp.cfg" sp_pipeSlice_3d_dp_ihf_tp.test_iter = 10 - sp_pipeSlice_3d_dp_ihf_tp.test_vals = [-11.120123, -5.196299, -0.000023, -0.015700] + sp_pipeSlice_3d_dp_ihf_tp.test_vals = [-12.253831, -5.369585, -0.000025, -0.015700] test_list.append(sp_pipeSlice_3d_dp_ihf_tp) # 2D pin array with heat transfer BC on pin surfaces @@ -930,7 +930,7 @@ def main(): inc_turb_morse_swirl_jet.cfg_dir = "incomp_rans/morse_swirl_jet" inc_turb_morse_swirl_jet.cfg_file = "morse_sa.cfg" inc_turb_morse_swirl_jet.test_iter = 10 - inc_turb_morse_swirl_jet.test_vals = [-10.168926, -7.347914, -8.685155, 13.000000, -4.156951, 71.328000] + inc_turb_morse_swirl_jet.test_vals = [-10.569835, -8.376495, -9.323474, 12.000000, -4.059383, 71.328000] test_list.append(inc_turb_morse_swirl_jet) # NACA0012, SST_SUST @@ -1318,7 +1318,7 @@ def main(): sbs_backward_step.cfg_dir = "backscatter/backward_step" sbs_backward_step.cfg_file = "backwardStep.cfg" sbs_backward_step.test_iter = 3 - sbs_backward_step.test_vals = [-6.353146, -3.465452, -5.470619, -3.906555, -9.506332, -6.365239, -6.331024, -6.331030] + sbs_backward_step.test_vals = [-6.352884, -3.465372, -5.507901, -3.906545, -9.506305, -6.365236, -6.331021, -6.331028] sbs_backward_step.unsteady = True sbs_backward_step.decompress = True sbs_backward_step.grid_file = "backward_step.su2" @@ -1338,7 +1338,7 @@ def main(): flatplate_unsteady.cfg_dir = "navierstokes/flatplate" flatplate_unsteady.cfg_file = "lam_flatplate_unst.cfg" flatplate_unsteady.test_iter = 3 - flatplate_unsteady.test_vals = [0.000008, -8.875141, -8.250617, -6.305804, -5.469459, -3.398234, 0.002074, -0.310165] + flatplate_unsteady.test_vals = [0.000008, -8.875128, -8.250204, -6.305788, -5.469452, -3.398230, 0.002075, -0.325535] flatplate_unsteady.unsteady = True test_list.append(flatplate_unsteady) @@ -1398,7 +1398,7 @@ def main(): Aachen_3D_restart.cfg_file = "aachen_3D_MP_restart.cfg" Aachen_3D_restart.test_iter = 5 Aachen_3D_restart.tol = 0.00001 - Aachen_3D_restart.test_vals = [-7.688485, -8.467588, -6.035067, -6.427338, -5.819784, -4.597818, -5.529569, -5.305004, -3.819863, -5.242440, -5.756583, -3.630202, -2.213244, -2.860891, -0.576864] + Aachen_3D_restart.test_vals = [-7.688483, -8.466346, -6.035067, -6.425967, -5.820125, -4.597817, -5.528297, -5.301466, -3.819862, -5.242356, -5.738805, -3.630202, -2.213240, -2.857919, -0.576864] test_list.append(Aachen_3D_restart) # Jones APU Turbocharger restart @@ -1406,7 +1406,7 @@ def main(): Jones_tc_restart.cfg_dir = "turbomachinery/APU_turbocharger" Jones_tc_restart.cfg_file = "Jones_restart.cfg" Jones_tc_restart.test_iter = 5 - Jones_tc_restart.test_vals = [-11.914198, -12.203720, -19.150460, -13.443363, -19.037618, -13.395928, 73286.000000, 73286.000000, 0.020056, 82.286000] + Jones_tc_restart.test_vals = [-11.905727, -12.211201, -19.212537, -13.508616, -19.078613, -13.445675, 73286.000000, 73286.000000, 0.020056, 82.286000] test_list.append(Jones_tc_restart) # 2D axial stage @@ -1414,7 +1414,7 @@ def main(): axial_stage2D.cfg_dir = "turbomachinery/axial_stage_2D" axial_stage2D.cfg_file = "Axial_stage2D.cfg" axial_stage2D.test_iter = 20 - axial_stage2D.test_vals = [1.176763, 1.601270, -2.961800, 2.541146, -2.531370, 3.013521, 106390.000000, 106390.000000, 5.735500, 64.426000] + axial_stage2D.test_vals = [1.167500, 1.598546, -2.928573, 2.573647, -2.527331, 3.016254, 106370.000000, 106370.000000, 5.726800, 64.383000] test_list.append(axial_stage2D) # 2D transonic stator restart @@ -1422,7 +1422,7 @@ def main(): transonic_stator_restart.cfg_dir = "turbomachinery/transonic_stator_2D" transonic_stator_restart.cfg_file = "transonic_stator_restart.cfg" transonic_stator_restart.test_iter = 20 - transonic_stator_restart.test_vals = [-4.389126, -2.515434, -2.103674, 1.706003, -1.488483, 3.231947, -471620.000000, 94.841000, -0.046801] + transonic_stator_restart.test_vals = [-4.365636, -2.482248, -2.081252, 1.729763, -1.467305, 3.231073, -471620.000000, 94.837000, -0.046834] transonic_stator_restart.test_vals_aarch64 = [-4.437809, -2.553049, -2.164729, 1.657542, -1.356823, 3.178788, -471620.000000, 94.842000, -0.040365] test_list.append(transonic_stator_restart) @@ -1431,7 +1431,7 @@ def main(): multi_interface.cfg_dir = "turbomachinery/multi_interface" multi_interface.cfg_file = "multi_interface_rst.cfg" multi_interface.test_iter = 5 - multi_interface.test_vals = [-8.633076, -8.894747, -9.348617] + multi_interface.test_vals = [-8.634558, -8.895554, -9.348754] multi_interface.test_vals_aarch64 = [-8.632227, -8.894736, -9.348706] test_list.append(multi_interface) @@ -1514,7 +1514,7 @@ def main(): bars_SST_2D.cfg_dir = "sliding_interface/bars_SST_2D" bars_SST_2D.cfg_file = "bars.cfg" bars_SST_2D.test_iter = 13 - bars_SST_2D.test_vals = [13.000000, -0.464304, -1.546997] + bars_SST_2D.test_vals = [13.000000, -0.464267, -1.541047] bars_SST_2D.multizone = True test_list.append(bars_SST_2D) @@ -1651,7 +1651,7 @@ def main(): solid_periodic_pins.cfg_dir = "solid_heat_conduction/periodic_pins" solid_periodic_pins.cfg_file = "configSolid.cfg" solid_periodic_pins.test_iter = 750 - solid_periodic_pins.test_vals = [-15.931359, -14.386112, 300.900000, 425.320000, 0.000000, -14.007572] + solid_periodic_pins.test_vals = [-15.878962, -14.569206, 300.900000, 425.320000, 5.000000, -1.672653] solid_periodic_pins.test_vals_aarch64 = [-15.879016, -14.569206, 300.900000, 425.320000, 5.000000, -1.672666] test_list.append(solid_periodic_pins) diff --git a/TestCases/serial_regression.py b/TestCases/serial_regression.py index 3d37cee52ee0..4871709e62d0 100755 --- a/TestCases/serial_regression.py +++ b/TestCases/serial_regression.py @@ -216,7 +216,7 @@ def main(): poiseuille.cfg_dir = "navierstokes/poiseuille" poiseuille.cfg_file = "lam_poiseuille.cfg" poiseuille.test_iter = 10 - poiseuille.test_vals = [-7.597001, -6.994813, 0.012127, 13.596354, 0.000000] + poiseuille.test_vals = [-7.597002, -6.994814, 0.012154, 13.596296, 0] test_list.append(poiseuille) # 2D Poiseuille flow (inlet profile file) @@ -936,7 +936,7 @@ def main(): ls89_sa.cfg_dir = "nicf/LS89" ls89_sa.cfg_file = "turb_SA_PR.cfg" ls89_sa.test_iter = 20 - ls89_sa.test_vals = [-5.047026, -13.385356, 0.179168, 0.421262] + ls89_sa.test_vals = [-5.041500, -13.379523, 0.179019, 0.420831] test_list.append(ls89_sa) # Rarefaction shock wave edge_VW @@ -965,7 +965,7 @@ def main(): Aachen_3D_restart.cfg_dir = "turbomachinery/Aachen_turbine" Aachen_3D_restart.cfg_file = "aachen_3D_MP_restart.cfg" Aachen_3D_restart.test_iter = 5 - Aachen_3D_restart.test_vals = [-7.690756, -8.480220, -6.040279, -6.426434, -5.831445, -4.598589, -5.536489, -5.307971, -3.830619, -5.244603, -5.766097, -3.635129, -2.215856, -2.900116, -0.583139] + Aachen_3D_restart.test_vals = [-7.689117, -8.476204, -6.036107, -6.427402, -5.831576, -4.599024, -5.530512, -5.305687, -3.821789, -5.243255, -5.754831, -3.631603, -2.213934, -2.895728, -0.578545] Aachen_3D_restart.enabled_with_asan = False test_list.append(Aachen_3D_restart) @@ -974,7 +974,7 @@ def main(): Jones_tc_restart.cfg_dir = "turbomachinery/APU_turbocharger" Jones_tc_restart.cfg_file = "Jones_restart.cfg" Jones_tc_restart.test_iter = 5 - Jones_tc_restart.test_vals = [-11.913929, -12.201923, -19.149798, -13.441884, -19.033169, -13.395061, 73286.000000, 73286.000000, 0.020056, 82.286000] + Jones_tc_restart.test_vals = [-11.905629, -12.211684, -19.212618, -13.507994, -19.069281, -13.439288, 73286.000000, 73286.000000, 0.020056, 82.286000] test_list.append(Jones_tc_restart) # 2D axial stage @@ -982,7 +982,7 @@ def main(): axial_stage2D.cfg_dir = "turbomachinery/axial_stage_2D" axial_stage2D.cfg_file = "Axial_stage2D.cfg" axial_stage2D.test_iter = 20 - axial_stage2D.test_vals = [1.177225, 1.602363, -2.962970, 2.540072, -2.535614, 3.008265, 106390.000000, 106390.000000, 5.735500, 64.426000] + axial_stage2D.test_vals = [1.167521, 1.598536, -2.928575, 2.573646, -2.527330, 3.016253, 106370.000000, 106370.000000, 5.726800, 64.383000] test_list.append(axial_stage2D) # 2D transonic stator restart @@ -990,7 +990,7 @@ def main(): transonic_stator_restart.cfg_dir = "turbomachinery/transonic_stator_2D" transonic_stator_restart.cfg_file = "transonic_stator_restart.cfg" transonic_stator_restart.test_iter = 20 - transonic_stator_restart.test_vals = [-4.391061, -2.520781, -2.103750, 1.703960, -1.488302, 3.226640, -471620.000000, 94.842000, -0.051820] + transonic_stator_restart.test_vals = [-4.367784, -2.492912, -2.082414, 1.727491, -1.466974, 3.224730, -471620.000000, 94.839000, -0.052082] transonic_stator_restart.test_vals_aarch64 = [-4.367784, -2.492912, -2.082414, 1.727491, -1.466974, 3.224730, -471620.000000, 94.839000, -0.052082] test_list.append(transonic_stator_restart) @@ -999,7 +999,7 @@ def main(): multi_interface.cfg_dir = "turbomachinery/multi_interface" multi_interface.cfg_file = "multi_interface_rst.cfg" multi_interface.test_iter = 5 - multi_interface.test_vals = [-8.632926, -8.895296, -9.348618] + multi_interface.test_vals = [-8.634558, -8.895554, -9.348754] multi_interface.test_vals_aarch64 = [-8.632227, -8.894736, -9.348706] test_list.append(multi_interface) @@ -1094,7 +1094,7 @@ def main(): bars_SST_2D.cfg_dir = "sliding_interface/bars_SST_2D" bars_SST_2D.cfg_file = "bars.cfg" bars_SST_2D.test_iter = 13 - bars_SST_2D.test_vals = [13.000000, -0.462739, -1.546996] + bars_SST_2D.test_vals = [13.000000, -0.462697, -1.541051] bars_SST_2D.multizone = True test_list.append(bars_SST_2D) From 11efe51fd90c63b90d40350f019c0274bfc8f73f Mon Sep 17 00:00:00 2001 From: bigfooted Date: Sat, 21 Nov 2026 15:28:53 +0100 Subject: [PATCH 03/13] Update the transonic_stator discrete adjoint values No periodic point is coupled in this case. The values change at the 1e-5 level on CI only; local builds of develop and of this branch give bit-identical results. Co-Authored-By: Claude Opus 5.5 --- TestCases/parallel_regression_AD.py | 2 +- TestCases/serial_regression_AD.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/TestCases/parallel_regression_AD.py b/TestCases/parallel_regression_AD.py index 879d3e7463ab..f92a7a2e53d0 100644 --- a/TestCases/parallel_regression_AD.py +++ b/TestCases/parallel_regression_AD.py @@ -251,7 +251,7 @@ def main(): discadj_trans_stator.cfg_dir = "disc_adj_turbomachinery/transonic_stator_2D" discadj_trans_stator.cfg_file = "transonic_stator.cfg" discadj_trans_stator.test_iter = 79 - discadj_trans_stator.test_vals = [79.000000, -7.555647, -10.335486, -10.356919, -13.629543] + discadj_trans_stator.test_vals = [79.000000, -7.555649, -10.335509, -10.356935, -13.629546] discadj_trans_stator.test_vals_aarch64 = [79.000000, -7.555647, -10.335486, -10.356919, -13.629543] test_list.append(discadj_trans_stator) diff --git a/TestCases/serial_regression_AD.py b/TestCases/serial_regression_AD.py index 05d44805e201..8fe4642b02dc 100644 --- a/TestCases/serial_regression_AD.py +++ b/TestCases/serial_regression_AD.py @@ -200,7 +200,7 @@ def main(): discadj_trans_stator.cfg_dir = "disc_adj_turbomachinery/transonic_stator_2D" discadj_trans_stator.cfg_file = "transonic_stator.cfg" discadj_trans_stator.test_iter = 79 - discadj_trans_stator.test_vals = [79.000000, -7.308168, -9.891121, -10.038669, -13.368502] + discadj_trans_stator.test_vals = [79.000000, -7.308175, -9.891136, -10.038680, -13.368508] discadj_trans_stator.test_vals_aarch64 = [79.000000, -7.308167, -9.891117, -10.038669, -13.368501] test_list.append(discadj_trans_stator) From d0a897ae93f3e20f4b17618e84d457bc06ef3144 Mon Sep 17 00:00:00 2001 From: bigfooted Date: Sat, 21 Nov 2026 16:46:45 +0100 Subject: [PATCH 04/13] Run the regression tests on the TestCases develop branch Co-Authored-By: Claude Opus 5.5 --- .github/workflows/regression.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/regression.yml b/.github/workflows/regression.yml index 49b0773ff86b..323353274e5a 100644 --- a/.github/workflows/regression.yml +++ b/.github/workflows/regression.yml @@ -235,7 +235,7 @@ jobs: uses: docker://ghcr.io/su2code/su2/test-su2:261011-1107 with: # -t -c - args: -b ${{github.ref}} -t develop -c fix_periodic_jacobian -s ${{matrix.testscript}} + args: -b ${{github.ref}} -t develop -c develop -s ${{matrix.testscript}} - name: Cleanup uses: docker://ghcr.io/su2code/su2/test-su2:261011-1107 with: @@ -284,7 +284,7 @@ jobs: uses: docker://ghcr.io/su2code/su2/test-su2:261011-1107 with: # -t -c - args: -b ${{github.ref}} -t develop -c fix_periodic_jacobian -s ${{matrix.testscript}} -a "--tapetests" + args: -b ${{github.ref}} -t develop -c develop -s ${{matrix.testscript}} -a "--tapetests" - name: Cleanup uses: docker://ghcr.io/su2code/su2/test-su2:261011-1107 with: @@ -334,7 +334,7 @@ jobs: PMIX_MCA_gds: hash with: # -t -c - args: -b ${{github.ref}} -t develop -c fix_periodic_jacobian -s ${{matrix.testscript}} -a "--tsan" + args: -b ${{github.ref}} -t develop -c develop -s ${{matrix.testscript}} -a "--tsan" - name: Cleanup uses: docker://ghcr.io/su2code/su2/test-su2-tsan:261011-1107 with: @@ -379,7 +379,7 @@ jobs: uses: docker://ghcr.io/su2code/su2/test-su2-asan:261011-1107 with: # -t -c - args: -b ${{github.ref}} -t develop -c fix_periodic_jacobian -s ${{matrix.testscript}} -a "--asan" + args: -b ${{github.ref}} -t develop -c develop -s ${{matrix.testscript}} -a "--asan" - name: Cleanup uses: docker://ghcr.io/su2code/su2/test-su2-asan:261011-1107 with: From 8741253e5b078e730820d6efaad56ee6e3d010f5 Mon Sep 17 00:00:00 2001 From: bigfooted Date: Wed, 25 Nov 2026 18:26:14 +0100 Subject: [PATCH 05/13] Simplify the periodic Jacobian coupling - One helper, RotateMomentumBlock, computes Ql*B*Qr^T on the momentum rows and columns. It replaces the hand-unrolled 2D/3D rotation in the periodic comms and the Rotation/RotateRows/RotateColumns lambdas. - Rotation matrices are built once per marker instead of once per block. - CBlockView::apply decodes, adds and re-encodes quantized blocks instead of silently doing nothing, so AddBlock works with Q_LU_SGS and the local workaround is removed. - The time step skips an edge when j is the periodic donor of i on this rank, read from the geometry, independent of whether the point is coupled. This removes skipImages, ArePeriodicImages and the per-iteration call to SetPeriodicMaster. - SetPeriodicMaster is called once from CouplePeriodicJacobian; the redundant implicit_periodic test and the PeriodicPassive member are gone. Regression values are unchanged: for the periodic and Q_LU_SGS cases the results are identical to the previous commit. Co-Authored-By: Claude Opus 5.5 --- Common/include/linear_algebra/CSysMatrix.hpp | 19 +- .../include/solvers/CFVMFlowSolverBase.hpp | 8 +- SU2_CFD/include/solvers/CSolver.hpp | 20 +- SU2_CFD/src/solvers/CSolver.cpp | 241 +++++++----------- 4 files changed, 121 insertions(+), 167 deletions(-) diff --git a/Common/include/linear_algebra/CSysMatrix.hpp b/Common/include/linear_algebra/CSysMatrix.hpp index ed33589b31d2..07827f6106d4 100644 --- a/Common/include/linear_algebra/CSysMatrix.hpp +++ b/Common/include/linear_algebra/CSysMatrix.hpp @@ -227,8 +227,7 @@ struct CBlockView { /*! * \brief Write the block from callable \p f(i,j). * \p Overwrite=true overwrites (or quantizes for Q_LU_SGS off-diagonal blocks); - * \p Overwrite=false accumulates into non-quantized storage only — accumulating into - * quantized storage would require decode-accumulate-encode and is a silent no-op. + * \p Overwrite=false accumulates (quantized storage is decoded, added and re-encoded). * Only enabled for mutable (non-const ScalarType) views. */ template > = 0> @@ -241,8 +240,20 @@ struct CBlockView { else ptr[i * nVar + j] += f(i, j); } - } else if constexpr (Overwrite) { - if (qs) EncodeQuantBlock(f, qs, qv, nVar); + } else if (qs) { + if constexpr (Overwrite) { + EncodeQuantBlock(f, qs, qv, nVar); + } else { + using T = std::remove_const_t; + for (auto r = 0ul; r < nVar; ++r) { + /*--- The old scale is kept because EncodeQuantRow overwrites qs[r] before re-reading the row. ---*/ + const auto scale = DecodeQuantScale(qs[r]); + const auto sum = [&](unsigned long i, unsigned long j) { + return static_cast(qv[i * nVar + j] * scale) + f(i, j); + }; + EncodeQuantRow(sum, qs[r], qv + r * nVar, nVar, r); + } + } } } }; diff --git a/SU2_CFD/include/solvers/CFVMFlowSolverBase.hpp b/SU2_CFD/include/solvers/CFVMFlowSolverBase.hpp index 214a74bdac70..5f476cb5d45f 100644 --- a/SU2_CFD/include/solvers/CFVMFlowSolverBase.hpp +++ b/SU2_CFD/include/solvers/CFVMFlowSolverBase.hpp @@ -444,10 +444,6 @@ class CFVMFlowSolverBase : public CSolver { ompMasterAssignBarrier(Min_Delta_Time,1e30, Max_Delta_Time,0.0, Global_Delta_UnstTimeND,1e30); - /*--- Edges between a point and its periodic image are left out, their states are tied. ---*/ - const bool skipImages = implicit_periodic; - if (skipImages) SetPeriodicMaster(geometry, config); - /*--- Loop domain points. ---*/ SU2_OMP_FOR_DYN(omp_chunk_size) @@ -465,7 +461,9 @@ class CFVMFlowSolverBase : public CSolver { for (unsigned short iNeigh = 0; iNeigh < geometry->nodes->GetnPoint(iPoint); ++iNeigh) { auto jPoint = geometry->nodes->GetPoint(iPoint,iNeigh); - if (skipImages && ArePeriodicImages(iPoint, jPoint)) continue; + + /*--- The edge to a periodic image is left out, the states of both points are tied. ---*/ + if (implicit_periodic && IsPeriodicImage(geometry, config, iPoint, jPoint)) continue; auto iEdge = geometry->nodes->GetEdge(iPoint,iNeigh); auto Normal = geometry->edges->GetNormal(iEdge); diff --git a/SU2_CFD/include/solvers/CSolver.hpp b/SU2_CFD/include/solvers/CSolver.hpp index 27ef57df94a1..76c3c4b6695e 100644 --- a/SU2_CFD/include/solvers/CSolver.hpp +++ b/SU2_CFD/include/solvers/CSolver.hpp @@ -151,7 +151,6 @@ class CSolver { std::unordered_map PeriodicProjIndex; /*!< \brief Local point to compact projection row. */ vector PeriodicMaster; /*!< \brief Local master point of each coupled passive periodic point, or -1. */ vector PeriodicMasterMarker; /*!< \brief Periodic marker of each passive point, gives its rotation. */ - vector PeriodicPassive; /*!< \brief Coupled passive periodic points. */ bool dynamic_grid; /*!< \brief Flag that determines whether the grid is dynamic (moving or deforming + grid velocities). */ @@ -337,16 +336,25 @@ class CSolver { void CouplePeriodicJacobian(CGeometry *geometry, const CConfig *config); /*! - * \brief Map each coupled passive periodic point to its master on the same rank (built once). + * \brief Map each coupled passive periodic point to its master on the same rank. */ void SetPeriodicMaster(CGeometry *geometry, const CConfig *config); /*! - * \brief Whether two points are periodic images of each other on this rank. + * \brief Whether jPoint is the periodic donor of iPoint on this rank. + * \note Only happens on meshes one cell thick in the periodic direction. */ - inline bool ArePeriodicImages(unsigned long iPoint, unsigned long jPoint) const { - if (PeriodicMaster.empty()) return false; - return PeriodicMaster[iPoint] == static_cast(jPoint) || PeriodicMaster[jPoint] == static_cast(iPoint); + inline bool IsPeriodicImage(const CGeometry *geometry, const CConfig *config, unsigned long iPoint, + unsigned long jPoint) const { + if (!geometry->nodes->GetPeriodicBoundary(iPoint) || !geometry->nodes->GetPeriodicBoundary(jPoint)) return false; + for (auto iMarker = 0u; iMarker < config->GetnMarker_All(); iMarker++) { + if (config->GetMarker_All_KindBC(iMarker) != PERIODIC_BOUNDARY) continue; + const auto iVertex = geometry->nodes->GetVertex(iPoint, iMarker); + if (iVertex < 0) continue; + const auto* vertex = geometry->vertex[iMarker][iVertex]; + if (vertex->GetDonorProcessor() == rank && vertex->GetDonorPoint() == static_cast(jPoint)) return true; + } + return false; } /*! diff --git a/SU2_CFD/src/solvers/CSolver.cpp b/SU2_CFD/src/solvers/CSolver.cpp index 1d1b281f0e3a..974ea12a4e89 100644 --- a/SU2_CFD/src/solvers/CSolver.cpp +++ b/SU2_CFD/src/solvers/CSolver.cpp @@ -302,6 +302,23 @@ void CSolver::GetPeriodicCommCountAndType(const CConfig* config, } namespace PeriodicCommHelpers { + /*--- B = Ql*B*Qr^T on the momentum rows and columns of B, a null matrix leaves that side alone. ---*/ + template + void RotateMomentumBlock(const Matrix* Ql, const Matrix* Qr, unsigned short nDim, unsigned short nVar, + su2activematrix& B) { + auto rotate = [nDim](const Matrix& Q, auto&& x) { + su2double v[3]; + for (auto d = 0u; d < nDim; d++) v[d] = x(d); + for (auto d = 0u; d < nDim; d++) { + su2double s = 0.0; + for (auto e = 0u; e < nDim; e++) s += Q[d][e] * v[e]; + x(d) = s; + } + }; + if (Ql) for (auto c = 0u; c < nVar; c++) rotate(*Ql, [&](unsigned d) -> su2double& { return B(1 + d, c); }); + if (Qr) for (auto r = 0u; r < nVar; r++) rotate(*Qr, [&](unsigned d) -> su2double& { return B(r, 1 + d); }); + } + CVectorOfMatrix& selectGradient(CVariable* nodes, unsigned short commType) { switch(commType) { case PERIODIC_PRIM_GG: @@ -642,31 +659,11 @@ void CSolver::InitiatePeriodicComms(CGeometry *geometry, } } - /*--- Rotate the momentum rows and columns of the Jacobian, the residual of the - periodic match is Q*R(Q^T*U), so its Jacobian is Q*J*Q^T. First the rows. ---*/ + /*--- The residual of the periodic match is Q*R(Q^T*U), so its Jacobian is Q*J*Q^T. ---*/ if (rotate_periodic) { - for (iVar = 0; iVar < nVar; iVar++) { - if (nDim == 2) { - jacBlock[1][iVar] = rotMatrix2D[0][0]*block(1, iVar) + rotMatrix2D[0][1]*block(2, iVar); - jacBlock[2][iVar] = rotMatrix2D[1][0]*block(1, iVar) + rotMatrix2D[1][1]*block(2, iVar); - } else { - jacBlock[1][iVar] = rotMatrix3D[0][0]*block(1, iVar) + rotMatrix3D[0][1]*block(2, iVar) + - rotMatrix3D[0][2]*block(3, iVar); - jacBlock[2][iVar] = rotMatrix3D[1][0]*block(1, iVar) + rotMatrix3D[1][1]*block(2, iVar) + - rotMatrix3D[1][2]*block(3, iVar); - jacBlock[3][iVar] = rotMatrix3D[2][0]*block(1, iVar) + rotMatrix3D[2][1]*block(2, iVar) + - rotMatrix3D[2][2]*block(3, iVar); - } - } - - /*--- Then the columns, i.e. the momentum part of each row. ---*/ - - for (auto iRow = 0u; iRow < nVar; iRow++) { - su2double rotated[3] = {0.0}; - Rotate(zeros, &jacBlock[iRow][1], rotated); - for (auto jDim = 0u; jDim < nDim; jDim++) jacBlock[iRow][1+jDim] = rotated[jDim]; - } + if (nDim == 2) PeriodicCommHelpers::RotateMomentumBlock(&rotMatrix2D, &rotMatrix2D, nDim, nVar, jacBlock); + else PeriodicCommHelpers::RotateMomentumBlock(&rotMatrix3D, &rotMatrix3D, nDim, nVar, jacBlock); } /*--- Load the Jacobian terms into the buffer for sending. ---*/ @@ -4633,173 +4630,113 @@ void CSolver::SavelibROM(CGeometry *geometry, CConfig *config, bool converged) { } void CSolver::SetPeriodicMaster(CGeometry *geometry, const CConfig *config) { - if (config->GetnMarker_Periodic() == 0) return; - - BEGIN_SU2_OMP_SAFE_GLOBAL_ACCESS { - const auto nPeriodic = config->GetnMarker_Periodic(); const auto nPointAll = geometry->GetnPoint(); - if (PeriodicMaster.size() != nPointAll) { - PeriodicMaster.assign(nPointAll, -1); - PeriodicMasterMarker.assign(nPointAll, 0); - vector nPeriodicMarker(nPointAll, 0); - vector passive(nPointAll, false); + PeriodicMaster.assign(nPointAll, -1); + PeriodicMasterMarker.assign(nPointAll, 0); + vector nPeriodicMarker(nPointAll, 0); + vector passive(nPointAll, false); - for (auto iMarker = 0u; iMarker < config->GetnMarker_All(); iMarker++) { - if (config->GetMarker_All_KindBC(iMarker) != PERIODIC_BOUNDARY) continue; - /*--- Points receiving from the second marker of a pair have their rows removed (CompletePeriodicComms). ---*/ - const bool isPassive = config->GetMarker_All_PerBound(iMarker) <= nPeriodic / 2; - for (auto iVertex = 0ul; iVertex < geometry->nVertex[iMarker]; iVertex++) { - const auto* vertex = geometry->vertex[iMarker][iVertex]; - const auto iPoint = vertex->GetNode(); - nPeriodicMarker[iPoint]++; - if (!isPassive) continue; - passive[iPoint] = true; - if (vertex->GetDonorProcessor() == rank && vertex->GetDonorPoint() >= 0) { - PeriodicMaster[iPoint] = vertex->GetDonorPoint(); - PeriodicMasterMarker[iPoint] = iMarker; - } + for (auto iMarker = 0u; iMarker < config->GetnMarker_All(); iMarker++) { + if (config->GetMarker_All_KindBC(iMarker) != PERIODIC_BOUNDARY) continue; + /*--- Points receiving from the second marker of a pair have their rows removed (CompletePeriodicComms). ---*/ + const bool isPassive = config->GetMarker_All_PerBound(iMarker) <= nPeriodic / 2; + for (auto iVertex = 0ul; iVertex < geometry->nVertex[iMarker]; iVertex++) { + const auto* vertex = geometry->vertex[iMarker][iVertex]; + const auto iPoint = vertex->GetNode(); + nPeriodicMarker[iPoint]++; + if (!isPassive) continue; + passive[iPoint] = true; + if (vertex->GetDonorProcessor() == rank && vertex->GetDonorPoint() >= 0) { + PeriodicMaster[iPoint] = vertex->GetDonorPoint(); + PeriodicMasterMarker[iPoint] = iMarker; } } + } - /*--- Points on several periodic markers keep the treatment of the comms only. ---*/ - for (auto iPoint = 0ul; iPoint < nPointAll; iPoint++) { - const auto master = PeriodicMaster[iPoint]; - if (master < 0) continue; - if (nPeriodicMarker[iPoint] != 1 || nPeriodicMarker[master] != 1 || passive[master]) - PeriodicMaster[iPoint] = -1; - } + /*--- Points on several periodic markers keep the treatment of the comms only. ---*/ + for (auto iPoint = 0ul; iPoint < nPointAll; iPoint++) { + const auto master = PeriodicMaster[iPoint]; + if (master < 0) continue; + if (nPeriodicMarker[iPoint] != 1 || nPeriodicMarker[master] != 1 || passive[master]) PeriodicMaster[iPoint] = -1; + } - /*--- A point is coupled only if all its blocks fit in the sparsity pattern of its master. Columns of passive - * points without a master are ignored, their increment is zero in the linear system. ---*/ - if (implicit_periodic) { - for (auto iPoint = 0ul; iPoint < nPointAll; iPoint++) { - const auto master = PeriodicMaster[iPoint]; - if (master < 0) continue; - bool fits = true; - for (const auto kPoint : geometry->nodes->GetPoints(iPoint)) { - if (iPoint < nPointDomain && (!passive[kPoint] || PeriodicMaster[kPoint] >= 0)) { - const unsigned long col = passive[kPoint] ? PeriodicMaster[kPoint] : kPoint; - fits = fits && Jacobian.GetBlockView(master, col); - } - if (kPoint < nPointDomain && !passive[kPoint]) fits = fits && Jacobian.GetBlockView(kPoint, master); - } - if (!fits) PeriodicMaster[iPoint] = -1; + /*--- A point is coupled only if all its blocks fit in the sparsity pattern of its master. Columns of passive + * points without a master are ignored, their increment is zero in the linear system. ---*/ + for (auto iPoint = 0ul; iPoint < nPointAll; iPoint++) { + const auto master = PeriodicMaster[iPoint]; + if (master < 0) continue; + const bool ownRow = iPoint < nPointDomain; + bool fits = true; + for (const auto kPoint : geometry->nodes->GetPoints(iPoint)) { + const bool kCoupled = PeriodicMaster[kPoint] >= 0; + if (ownRow && (!passive[kPoint] || kCoupled)) { + const unsigned long col = kCoupled ? PeriodicMaster[kPoint] : kPoint; + fits = fits && Jacobian.GetBlockView(master, col); } + if (kPoint < nPointDomain && !passive[kPoint]) fits = fits && Jacobian.GetBlockView(kPoint, master); } - - PeriodicPassive.clear(); - for (auto iPoint = 0ul; iPoint < nPointAll; iPoint++) - if (PeriodicMaster[iPoint] >= 0) PeriodicPassive.push_back(iPoint); - } - + if (!fits) PeriodicMaster[iPoint] = -1; } - END_SU2_OMP_SAFE_GLOBAL_ACCESS } void CSolver::CouplePeriodicJacobian(CGeometry *geometry, const CConfig *config) { SU2_ZONE_SCOPED - if (!implicit_periodic) return; - - SetPeriodicMaster(geometry, config); + if (!implicit_periodic || config->GetnMarker_Periodic() == 0) return; BEGIN_SU2_OMP_SAFE_GLOBAL_ACCESS { - /*--- Rotation from the frame of a passive point to the frame of its master. ---*/ - auto Rotation = [&](unsigned short iMarker, su2double (&Q)[3][3]) { - for (auto i = 0u; i < 3; i++) - for (auto j = 0u; j < 3; j++) Q[i][j] = (i == j); - if (!rotate_periodic) return false; + if (PeriodicMaster.size() != geometry->GetnPoint()) SetPeriodicMaster(geometry, config); + + /*--- Rotation from the frame of each periodic marker to the frame of its match, null if none. ---*/ + using RotationMatrix = std::array, 3>; + const auto nMarker = config->GetnMarker_All(); + vector rotations(nMarker); + vector markerRotation(nMarker, nullptr); + for (auto iMarker = 0u; iMarker < nMarker && rotate_periodic; iMarker++) { + if (config->GetMarker_All_KindBC(iMarker) != PERIODIC_BOUNDARY) continue; const auto* angles = config->GetPeriodicRotAngles(config->GetMarker_All_TagBound(iMarker)); - if (!GeometryToolbox::HasRotation(angles)) return false; - if (nDim == 2) { - su2double Q2[2][2]; - GeometryToolbox::RotationMatrix(angles[2], Q2); - for (auto i = 0u; i < 2; i++) - for (auto j = 0u; j < 2; j++) Q[i][j] = Q2[i][j]; - } else { - GeometryToolbox::RotationMatrix(angles[0], angles[1], angles[2], Q); - } - return true; + if (!GeometryToolbox::HasRotation(angles)) continue; + if (nDim == 2) GeometryToolbox::RotationMatrix(angles[2], rotations[iMarker]); + else GeometryToolbox::RotationMatrix(angles[0], angles[1], angles[2], rotations[iMarker]); + markerRotation[iMarker] = &rotations[iMarker]; + } + auto Rotation = [&](unsigned long iPoint) -> const RotationMatrix* { + return PeriodicMaster[iPoint] >= 0 ? markerRotation[PeriodicMasterMarker[iPoint]] : nullptr; }; - su2activematrix block(nVar, nVar), sum(nVar, nVar), zero(nVar, nVar); + su2activematrix block(nVar, nVar), zero(nVar, nVar); zero = su2double(0.0); - su2double v[3]; - - /*--- Copy a block through its view, which also decodes quantized storage. ---*/ auto ReadBlock = [&](unsigned long iRow, unsigned long iCol) { const auto view = Jacobian.GetBlockView(iRow, iCol); - if (!view) return false; for (auto i = 0u; i < nVar; i++) for (auto j = 0u; j < nVar; j++) block(i, j) = view(i, j); - return true; }; - /*--- Add block to an existing block. Quantized storage cannot accumulate, it is decoded, added and re-encoded. ---*/ - auto AddBlock = [&](unsigned long iRow, unsigned long iCol) { - const auto view = Jacobian.GetBlockView(iRow, iCol); - if (view.ptr) { - Jacobian.SetBlock(iRow, iCol, block); - return; - } - for (auto i = 0u; i < nVar; i++) - for (auto j = 0u; j < nVar; j++) sum(i, j) = view(i, j) + block(i, j); - Jacobian.SetBlock(iRow, iCol, sum); - }; - - auto RotateRows = [&](const su2double (&Q)[3][3]) { - for (auto c = 0u; c < nVar; c++) { - for (auto d = 0u; d < nDim; d++) v[d] = block(1 + d, c); - for (auto d = 0u; d < nDim; d++) { - su2double s = 0.0; - for (auto e = 0u; e < nDim; e++) s += Q[d][e] * v[e]; - block(1 + d, c) = s; - } - } - }; - - /*--- Right product with Q^T: the passive increment is Q^T times the master increment. ---*/ - auto RotateColumns = [&](const su2double (&Q)[3][3]) { - for (auto r = 0u; r < nVar; r++) { - for (auto d = 0u; d < nDim; d++) v[d] = block(r, 1 + d); - for (auto d = 0u; d < nDim; d++) { - su2double s = 0.0; - for (auto e = 0u; e < nDim; e++) s += v[e] * Q[d][e]; - block(r, 1 + d) = s; - } - } - }; - - su2double Qp[3][3], Qk[3][3]; - /*--- Rows of passive points go to the rows of their masters. ---*/ - for (const auto iPoint : PeriodicPassive) { - if (iPoint >= nPointDomain) continue; + for (auto iPoint = 0ul; iPoint < nPointDomain; iPoint++) { const auto master = PeriodicMaster[iPoint]; - const bool rotP = Rotation(PeriodicMasterMarker[iPoint], Qp); - + if (master < 0) continue; for (const auto kPoint : geometry->nodes->GetPoints(iPoint)) { - const bool kPassive = PeriodicMaster[kPoint] >= 0; - const unsigned long col = kPassive ? PeriodicMaster[kPoint] : kPoint; - if (!Jacobian.GetBlockView(master, col) || !ReadBlock(iPoint, kPoint)) continue; - if (kPassive && Rotation(PeriodicMasterMarker[kPoint], Qk)) RotateColumns(Qk); - if (rotP) RotateRows(Qp); - AddBlock(master, col); + const unsigned long col = PeriodicMaster[kPoint] >= 0 ? PeriodicMaster[kPoint] : kPoint; + if (!Jacobian.GetBlockView(master, col)) continue; + ReadBlock(iPoint, kPoint); + PeriodicCommHelpers::RotateMomentumBlock(Rotation(iPoint), Rotation(kPoint), nDim, nVar, block); + Jacobian.AddBlock(master, col, block); } } /*--- Columns of passive points go to the columns of their masters. ---*/ - for (const auto iPoint : PeriodicPassive) { + for (auto iPoint = 0ul; iPoint < PeriodicMaster.size(); iPoint++) { const auto master = PeriodicMaster[iPoint]; - const bool rotP = Rotation(PeriodicMasterMarker[iPoint], Qp); - + if (master < 0) continue; for (const auto jPoint : geometry->nodes->GetPoints(iPoint)) { if (jPoint >= nPointDomain || PeriodicMaster[jPoint] >= 0) continue; - if (!Jacobian.GetBlockView(jPoint, master) || !ReadBlock(jPoint, iPoint)) continue; - if (rotP) RotateColumns(Qp); - AddBlock(jPoint, master); + if (!Jacobian.GetBlockView(jPoint, master)) continue; + ReadBlock(jPoint, iPoint); + PeriodicCommHelpers::RotateMomentumBlock(nullptr, Rotation(iPoint), nDim, nVar, block); + Jacobian.AddBlock(jPoint, master, block); Jacobian.SetBlock(jPoint, iPoint, zero); } } From 1eb9c59c063cdc1b5beb6613ffef1ce41b328355 Mon Sep 17 00:00:00 2001 From: bigfooted Date: Wed, 25 Nov 2026 19:26:28 +0100 Subject: [PATCH 06/13] Address review: passive Jacobian blocks, loop names, nPoint - The moved Jacobian blocks and the rotation matrices of the coupling are passive types; RotateMomentumBlock is templated on the block scalar so the comms keep their active block. - Descriptive loop variables (iVar, jVar, iDim, jDim) in RotateMomentumBlock and ReadBlock. - SetPeriodicMaster and CouplePeriodicJacobian use the member nPoint instead of a local nPointAll. Co-Authored-By: Claude Opus 5.5 --- SU2_CFD/src/solvers/CSolver.cpp | 60 ++++++++++++++++++--------------- 1 file changed, 33 insertions(+), 27 deletions(-) diff --git a/SU2_CFD/src/solvers/CSolver.cpp b/SU2_CFD/src/solvers/CSolver.cpp index 974ea12a4e89..9c85dfcf99f5 100644 --- a/SU2_CFD/src/solvers/CSolver.cpp +++ b/SU2_CFD/src/solvers/CSolver.cpp @@ -303,20 +303,24 @@ void CSolver::GetPeriodicCommCountAndType(const CConfig* config, namespace PeriodicCommHelpers { /*--- B = Ql*B*Qr^T on the momentum rows and columns of B, a null matrix leaves that side alone. ---*/ - template + template void RotateMomentumBlock(const Matrix* Ql, const Matrix* Qr, unsigned short nDim, unsigned short nVar, - su2activematrix& B) { - auto rotate = [nDim](const Matrix& Q, auto&& x) { - su2double v[3]; - for (auto d = 0u; d < nDim; d++) v[d] = x(d); - for (auto d = 0u; d < nDim; d++) { - su2double s = 0.0; - for (auto e = 0u; e < nDim; e++) s += Q[d][e] * v[e]; - x(d) = s; + su2matrix& B) { + auto rotate = [nDim](const Matrix& Q, auto&& component) { + Scalar vec[3]; + for (auto iDim = 0u; iDim < nDim; iDim++) vec[iDim] = component(iDim); + for (auto iDim = 0u; iDim < nDim; iDim++) { + Scalar sum = 0.0; + for (auto jDim = 0u; jDim < nDim; jDim++) sum += Q[iDim][jDim] * vec[jDim]; + component(iDim) = sum; } }; - if (Ql) for (auto c = 0u; c < nVar; c++) rotate(*Ql, [&](unsigned d) -> su2double& { return B(1 + d, c); }); - if (Qr) for (auto r = 0u; r < nVar; r++) rotate(*Qr, [&](unsigned d) -> su2double& { return B(r, 1 + d); }); + if (Ql) + for (auto jVar = 0u; jVar < nVar; jVar++) + rotate(*Ql, [&](unsigned iDim) -> Scalar& { return B(1 + iDim, jVar); }); + if (Qr) + for (auto iVar = 0u; iVar < nVar; iVar++) + rotate(*Qr, [&](unsigned iDim) -> Scalar& { return B(iVar, 1 + iDim); }); } CVectorOfMatrix& selectGradient(CVariable* nodes, unsigned short commType) { @@ -4631,12 +4635,11 @@ void CSolver::SavelibROM(CGeometry *geometry, CConfig *config, bool converged) { void CSolver::SetPeriodicMaster(CGeometry *geometry, const CConfig *config) { const auto nPeriodic = config->GetnMarker_Periodic(); - const auto nPointAll = geometry->GetnPoint(); - PeriodicMaster.assign(nPointAll, -1); - PeriodicMasterMarker.assign(nPointAll, 0); - vector nPeriodicMarker(nPointAll, 0); - vector passive(nPointAll, false); + PeriodicMaster.assign(nPoint, -1); + PeriodicMasterMarker.assign(nPoint, 0); + vector nPeriodicMarker(nPoint, 0); + vector passive(nPoint, false); for (auto iMarker = 0u; iMarker < config->GetnMarker_All(); iMarker++) { if (config->GetMarker_All_KindBC(iMarker) != PERIODIC_BOUNDARY) continue; @@ -4656,7 +4659,7 @@ void CSolver::SetPeriodicMaster(CGeometry *geometry, const CConfig *config) { } /*--- Points on several periodic markers keep the treatment of the comms only. ---*/ - for (auto iPoint = 0ul; iPoint < nPointAll; iPoint++) { + for (auto iPoint = 0ul; iPoint < nPoint; iPoint++) { const auto master = PeriodicMaster[iPoint]; if (master < 0) continue; if (nPeriodicMarker[iPoint] != 1 || nPeriodicMarker[master] != 1 || passive[master]) PeriodicMaster[iPoint] = -1; @@ -4664,7 +4667,7 @@ void CSolver::SetPeriodicMaster(CGeometry *geometry, const CConfig *config) { /*--- A point is coupled only if all its blocks fit in the sparsity pattern of its master. Columns of passive * points without a master are ignored, their increment is zero in the linear system. ---*/ - for (auto iPoint = 0ul; iPoint < nPointAll; iPoint++) { + for (auto iPoint = 0ul; iPoint < nPoint; iPoint++) { const auto master = PeriodicMaster[iPoint]; if (master < 0) continue; const bool ownRow = iPoint < nPointDomain; @@ -4687,10 +4690,10 @@ void CSolver::CouplePeriodicJacobian(CGeometry *geometry, const CConfig *config) BEGIN_SU2_OMP_SAFE_GLOBAL_ACCESS { - if (PeriodicMaster.size() != geometry->GetnPoint()) SetPeriodicMaster(geometry, config); + if (PeriodicMaster.size() != nPoint) SetPeriodicMaster(geometry, config); /*--- Rotation from the frame of each periodic marker to the frame of its match, null if none. ---*/ - using RotationMatrix = std::array, 3>; + using RotationMatrix = std::array, 3>; const auto nMarker = config->GetnMarker_All(); vector rotations(nMarker); vector markerRotation(nMarker, nullptr); @@ -4698,20 +4701,23 @@ void CSolver::CouplePeriodicJacobian(CGeometry *geometry, const CConfig *config) if (config->GetMarker_All_KindBC(iMarker) != PERIODIC_BOUNDARY) continue; const auto* angles = config->GetPeriodicRotAngles(config->GetMarker_All_TagBound(iMarker)); if (!GeometryToolbox::HasRotation(angles)) continue; - if (nDim == 2) GeometryToolbox::RotationMatrix(angles[2], rotations[iMarker]); - else GeometryToolbox::RotationMatrix(angles[0], angles[1], angles[2], rotations[iMarker]); + const auto theta = SU2_TYPE::GetValue(angles[0]); + const auto phi = SU2_TYPE::GetValue(angles[1]); + const auto psi = SU2_TYPE::GetValue(angles[2]); + if (nDim == 2) GeometryToolbox::RotationMatrix(psi, rotations[iMarker]); + else GeometryToolbox::RotationMatrix(theta, phi, psi, rotations[iMarker]); markerRotation[iMarker] = &rotations[iMarker]; } auto Rotation = [&](unsigned long iPoint) -> const RotationMatrix* { return PeriodicMaster[iPoint] >= 0 ? markerRotation[PeriodicMasterMarker[iPoint]] : nullptr; }; - su2activematrix block(nVar, nVar), zero(nVar, nVar); - zero = su2double(0.0); + su2passivematrix block(nVar, nVar), zero(nVar, nVar); + zero = passivedouble(0.0); auto ReadBlock = [&](unsigned long iRow, unsigned long iCol) { const auto view = Jacobian.GetBlockView(iRow, iCol); - for (auto i = 0u; i < nVar; i++) - for (auto j = 0u; j < nVar; j++) block(i, j) = view(i, j); + for (auto iVar = 0u; iVar < nVar; iVar++) + for (auto jVar = 0u; jVar < nVar; jVar++) block(iVar, jVar) = view(iVar, jVar); }; /*--- Rows of passive points go to the rows of their masters. ---*/ @@ -4728,7 +4734,7 @@ void CSolver::CouplePeriodicJacobian(CGeometry *geometry, const CConfig *config) } /*--- Columns of passive points go to the columns of their masters. ---*/ - for (auto iPoint = 0ul; iPoint < PeriodicMaster.size(); iPoint++) { + for (auto iPoint = 0ul; iPoint < nPoint; iPoint++) { const auto master = PeriodicMaster[iPoint]; if (master < 0) continue; for (const auto jPoint : geometry->nodes->GetPoints(iPoint)) { From f09b17439d78a00bb101d6d29ee94622febeb94b Mon Sep 17 00:00:00 2001 From: bigfooted Date: Fri, 27 Nov 2026 23:51:45 +0100 Subject: [PATCH 07/13] Build the periodic coupling table once SetPeriodicMaster runs on the first call of CouplePeriodicJacobian, when the sparsity pattern of the Jacobian is fixed, and also stores the list of coupled points and the rotation matrix of each periodic marker. Cases with no coupled points return before the OpenMP safe-access region. Co-Authored-By: Claude Opus 5.5 --- SU2_CFD/include/solvers/CSolver.hpp | 4 ++- SU2_CFD/src/solvers/CSolver.cpp | 56 ++++++++++++++++------------- 2 files changed, 35 insertions(+), 25 deletions(-) diff --git a/SU2_CFD/include/solvers/CSolver.hpp b/SU2_CFD/include/solvers/CSolver.hpp index 76c3c4b6695e..c9331916dbd3 100644 --- a/SU2_CFD/include/solvers/CSolver.hpp +++ b/SU2_CFD/include/solvers/CSolver.hpp @@ -151,6 +151,8 @@ class CSolver { std::unordered_map PeriodicProjIndex; /*!< \brief Local point to compact projection row. */ vector PeriodicMaster; /*!< \brief Local master point of each coupled passive periodic point, or -1. */ vector PeriodicMasterMarker; /*!< \brief Periodic marker of each passive point, gives its rotation. */ + vector PeriodicPassive; /*!< \brief Coupled passive periodic points. */ + vector PeriodicRotation; /*!< \brief Rotation of each periodic marker to its match, empty if none. */ bool dynamic_grid; /*!< \brief Flag that determines whether the grid is dynamic (moving or deforming + grid velocities). */ @@ -336,7 +338,7 @@ class CSolver { void CouplePeriodicJacobian(CGeometry *geometry, const CConfig *config); /*! - * \brief Map each coupled passive periodic point to its master on the same rank. + * \brief Map each coupled passive periodic point to its master on the same rank, and set the marker rotations. */ void SetPeriodicMaster(CGeometry *geometry, const CConfig *config); diff --git a/SU2_CFD/src/solvers/CSolver.cpp b/SU2_CFD/src/solvers/CSolver.cpp index 9c85dfcf99f5..0ee0fe214f96 100644 --- a/SU2_CFD/src/solvers/CSolver.cpp +++ b/SU2_CFD/src/solvers/CSolver.cpp @@ -4682,34 +4682,43 @@ void CSolver::SetPeriodicMaster(CGeometry *geometry, const CConfig *config) { } if (!fits) PeriodicMaster[iPoint] = -1; } -} - -void CSolver::CouplePeriodicJacobian(CGeometry *geometry, const CConfig *config) { - SU2_ZONE_SCOPED - if (!implicit_periodic || config->GetnMarker_Periodic() == 0) return; - BEGIN_SU2_OMP_SAFE_GLOBAL_ACCESS { - - if (PeriodicMaster.size() != nPoint) SetPeriodicMaster(geometry, config); + PeriodicPassive.clear(); + for (auto iPoint = 0ul; iPoint < nPoint; iPoint++) + if (PeriodicMaster[iPoint] >= 0) PeriodicPassive.push_back(iPoint); - /*--- Rotation from the frame of each periodic marker to the frame of its match, null if none. ---*/ - using RotationMatrix = std::array, 3>; - const auto nMarker = config->GetnMarker_All(); - vector rotations(nMarker); - vector markerRotation(nMarker, nullptr); - for (auto iMarker = 0u; iMarker < nMarker && rotate_periodic; iMarker++) { + /*--- Rotation from the frame of each periodic marker to the frame of its match, empty if none. ---*/ + PeriodicRotation.assign(config->GetnMarker_All(), su2passivematrix()); + for (auto iMarker = 0u; iMarker < config->GetnMarker_All() && rotate_periodic; iMarker++) { if (config->GetMarker_All_KindBC(iMarker) != PERIODIC_BOUNDARY) continue; const auto* angles = config->GetPeriodicRotAngles(config->GetMarker_All_TagBound(iMarker)); if (!GeometryToolbox::HasRotation(angles)) continue; + auto& rotation = PeriodicRotation[iMarker]; + rotation.resize(3, 3) = passivedouble(0.0); const auto theta = SU2_TYPE::GetValue(angles[0]); const auto phi = SU2_TYPE::GetValue(angles[1]); const auto psi = SU2_TYPE::GetValue(angles[2]); - if (nDim == 2) GeometryToolbox::RotationMatrix(psi, rotations[iMarker]); - else GeometryToolbox::RotationMatrix(theta, phi, psi, rotations[iMarker]); - markerRotation[iMarker] = &rotations[iMarker]; + if (nDim == 2) GeometryToolbox::RotationMatrix(psi, rotation); + else GeometryToolbox::RotationMatrix(theta, phi, psi, rotation); } - auto Rotation = [&](unsigned long iPoint) -> const RotationMatrix* { - return PeriodicMaster[iPoint] >= 0 ? markerRotation[PeriodicMasterMarker[iPoint]] : nullptr; +} + +void CSolver::CouplePeriodicJacobian(CGeometry *geometry, const CConfig *config) { + SU2_ZONE_SCOPED + if (!implicit_periodic || config->GetnMarker_Periodic() == 0) return; + + /*--- The table is built on the first call, the sparsity pattern of the Jacobian is fixed by then. ---*/ + const bool built = PeriodicMaster.size() == nPoint; + if (built && PeriodicPassive.empty()) return; + + BEGIN_SU2_OMP_SAFE_GLOBAL_ACCESS { + + if (!built) SetPeriodicMaster(geometry, config); + + auto Rotation = [&](unsigned long iPoint) -> const su2passivematrix* { + if (PeriodicMaster[iPoint] < 0) return nullptr; + const auto& rotation = PeriodicRotation[PeriodicMasterMarker[iPoint]]; + return rotation.size() ? &rotation : nullptr; }; su2passivematrix block(nVar, nVar), zero(nVar, nVar); @@ -4721,9 +4730,9 @@ void CSolver::CouplePeriodicJacobian(CGeometry *geometry, const CConfig *config) }; /*--- Rows of passive points go to the rows of their masters. ---*/ - for (auto iPoint = 0ul; iPoint < nPointDomain; iPoint++) { + for (const auto iPoint : PeriodicPassive) { + if (iPoint >= nPointDomain) continue; const auto master = PeriodicMaster[iPoint]; - if (master < 0) continue; for (const auto kPoint : geometry->nodes->GetPoints(iPoint)) { const unsigned long col = PeriodicMaster[kPoint] >= 0 ? PeriodicMaster[kPoint] : kPoint; if (!Jacobian.GetBlockView(master, col)) continue; @@ -4734,14 +4743,13 @@ void CSolver::CouplePeriodicJacobian(CGeometry *geometry, const CConfig *config) } /*--- Columns of passive points go to the columns of their masters. ---*/ - for (auto iPoint = 0ul; iPoint < nPoint; iPoint++) { + for (const auto iPoint : PeriodicPassive) { const auto master = PeriodicMaster[iPoint]; - if (master < 0) continue; for (const auto jPoint : geometry->nodes->GetPoints(iPoint)) { if (jPoint >= nPointDomain || PeriodicMaster[jPoint] >= 0) continue; if (!Jacobian.GetBlockView(jPoint, master)) continue; ReadBlock(jPoint, iPoint); - PeriodicCommHelpers::RotateMomentumBlock(nullptr, Rotation(iPoint), nDim, nVar, block); + PeriodicCommHelpers::RotateMomentumBlock(nullptr, Rotation(iPoint), nDim, nVar, block); Jacobian.AddBlock(jPoint, master, block); Jacobian.SetBlock(jPoint, iPoint, zero); } From 86f9c48eba1acd12067490d37e5ba0d945349c28 Mon Sep 17 00:00:00 2001 From: bigfooted Date: Fri, 27 Nov 2026 23:51:59 +0100 Subject: [PATCH 08/13] Record the periodic volume when recording the mesh coordinates The periodic part of each dual volume was communicated once, in CommunicateInitialState, so in the discrete adjoint it did not depend on the mesh coordinates and the geometric sensitivities missed its derivative. CSolver::CommunicatePeriodicVolume resets and accumulates the periodic volume; the adjoint fluid iteration calls it after UpdateGeometry. On the Morse swirling jet (one-cell wedge, every point periodic) the adjoint derivative of the inlet static pressure with respect to a smooth mesh deformation changes from +22.6 to -2.02; central finite differences give -2.137. The primal is unchanged. Co-Authored-By: Claude Opus 5.5 --- SU2_CFD/include/solvers/CFVMFlowSolverBase.inl | 3 +-- SU2_CFD/include/solvers/CSolver.hpp | 6 ++++++ SU2_CFD/src/iteration/CDiscAdjFluidIteration.cpp | 2 ++ SU2_CFD/src/solvers/CSolver.cpp | 8 ++++++++ 4 files changed, 17 insertions(+), 2 deletions(-) diff --git a/SU2_CFD/include/solvers/CFVMFlowSolverBase.inl b/SU2_CFD/include/solvers/CFVMFlowSolverBase.inl index 54978dde434b..ae89a8135a03 100644 --- a/SU2_CFD/include/solvers/CFVMFlowSolverBase.inl +++ b/SU2_CFD/include/solvers/CFVMFlowSolverBase.inl @@ -254,9 +254,8 @@ void CFVMFlowSolverBase::CommunicateInitialState(CGeometry* geometry, cons /*--- Communicate and store volume and the number of neighbors for any dual CVs that lie on on periodic markers. ---*/ + CommunicatePeriodicVolume(geometry, config); for (unsigned short iPeriodic = 1; iPeriodic <= config->GetnMarker_Periodic() / 2; iPeriodic++) { - InitiatePeriodicComms(geometry, config, iPeriodic, PERIODIC_VOLUME); - CompletePeriodicComms(geometry, config, iPeriodic, PERIODIC_VOLUME); InitiatePeriodicComms(geometry, config, iPeriodic, PERIODIC_NEIGHBORS); CompletePeriodicComms(geometry, config, iPeriodic, PERIODIC_NEIGHBORS); } diff --git a/SU2_CFD/include/solvers/CSolver.hpp b/SU2_CFD/include/solvers/CSolver.hpp index c9331916dbd3..9dd3c7be50c3 100644 --- a/SU2_CFD/include/solvers/CSolver.hpp +++ b/SU2_CFD/include/solvers/CSolver.hpp @@ -330,6 +330,12 @@ class CSolver { unsigned short val_periodic_index, unsigned short commType); + /*! + * \brief Set the periodic volume of each periodic point, the volume of its matches on the other periodic faces. + * \note Called again when the mesh coordinates are recorded, so the periodic volume depends on them. + */ + void CommunicatePeriodicVolume(CGeometry *geometry, const CConfig *config); + /*! * \brief Move the off-diagonal Jacobian blocks of passive periodic points to their masters, rotated. * \note Call before the PERIODIC_RESIDUAL comms. A passive point is coupled if its master is on the same rank and diff --git a/SU2_CFD/src/iteration/CDiscAdjFluidIteration.cpp b/SU2_CFD/src/iteration/CDiscAdjFluidIteration.cpp index 7c33451e6095..5fe40729f533 100644 --- a/SU2_CFD/src/iteration/CDiscAdjFluidIteration.cpp +++ b/SU2_CFD/src/iteration/CDiscAdjFluidIteration.cpp @@ -478,6 +478,8 @@ void CDiscAdjFluidIteration::SetDependencies(CSolver***** solver, CGeometry**** CGeometry::UpdateGeometry(geometry[iZone][iInst], config[iZone]); END_SU2_OMP_PARALLEL + solvers0[FLOW_SOL]->CommunicatePeriodicVolume(geometry0, config[iZone]); + CGeometry::ComputeWallDistance(config, geometry, iZone); } diff --git a/SU2_CFD/src/solvers/CSolver.cpp b/SU2_CFD/src/solvers/CSolver.cpp index 0ee0fe214f96..0e68fce3927e 100644 --- a/SU2_CFD/src/solvers/CSolver.cpp +++ b/SU2_CFD/src/solvers/CSolver.cpp @@ -4633,6 +4633,14 @@ void CSolver::SavelibROM(CGeometry *geometry, CConfig *config, bool converged) { } +void CSolver::CommunicatePeriodicVolume(CGeometry *geometry, const CConfig *config) { + for (auto iPoint = 0ul; iPoint < geometry->GetnPoint(); iPoint++) geometry->nodes->SetPeriodicVolume(iPoint, 0.0); + for (unsigned short iPeriodic = 1; iPeriodic <= config->GetnMarker_Periodic() / 2; iPeriodic++) { + InitiatePeriodicComms(geometry, config, iPeriodic, PERIODIC_VOLUME); + CompletePeriodicComms(geometry, config, iPeriodic, PERIODIC_VOLUME); + } +} + void CSolver::SetPeriodicMaster(CGeometry *geometry, const CConfig *config) { const auto nPeriodic = config->GetnMarker_Periodic(); From cf9ced6158a7980384c7670809a987d866ade3f0 Mon Sep 17 00:00:00 2001 From: bigfooted Date: Sat, 28 Nov 2026 09:32:38 +0100 Subject: [PATCH 09/13] Add a discrete-adjoint regression test for the Morse swirling jet discadj_incomp_turb_morse_swirl_jet runs 10 adjoint iterations of the one-cell periodic wedge from the converged primal solution, with the inlet static pressure as objective. Every point of the wedge is periodic, so the test covers the coupled Jacobian in the adjoint linear solve. Co-Authored-By: Claude Opus 5.5 --- .../morse_swirl_jet/morse_sa_adjoint.cfg | 103 ++++++++++++++++++ TestCases/parallel_regression_AD.py | 8 ++ 2 files changed, 111 insertions(+) create mode 100644 TestCases/incomp_rans/morse_swirl_jet/morse_sa_adjoint.cfg diff --git a/TestCases/incomp_rans/morse_swirl_jet/morse_sa_adjoint.cfg b/TestCases/incomp_rans/morse_swirl_jet/morse_sa_adjoint.cfg new file mode 100644 index 000000000000..58174f661dc1 --- /dev/null +++ b/TestCases/incomp_rans/morse_swirl_jet/morse_sa_adjoint.cfg @@ -0,0 +1,103 @@ +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% % +% SU2 configuration file % +% Case description: Swirling jet in still air, S = 0.36, Re = 56,000 % +% (Morse 1980, ERCOFTAC Classic case 026), SA, 5 deg wedge % +% Author: Nijso Beishuizen % +% Institution: Bosch Thermotechnology % +% Date: Nov 15th, 2026 % +% File Version 8.6.0 "Harrier" % +% % +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +% ------------- DIRECT, ADJOINT, AND LINEARIZED PROBLEM DEFINITION ------------% +% +SOLVER= INC_RANS +KIND_TURB_MODEL= SA +MATH_PROBLEM= DISCRETE_ADJOINT +RESTART_SOL= NO + +% ---------------- INCOMPRESSIBLE FLOW CONDITION DEFINITION -------------------% +% +% Air; the far field carries a co-flow of 1% of the jet exit velocity (34.46 m/s). +FLUID_MODEL= CONSTANT_DENSITY +INC_DENSITY_INIT= 1.2 +INC_VELOCITY_INIT= ( 0.345, 0.0, 0.0 ) +INC_NONDIM= DIMENSIONAL + +% --------------------------- VISCOSITY MODEL ---------------------------------% +% +% Re = U_exit D / nu = 56,000 with D = 0.0246 m. +VISCOSITY_MODEL= CONSTANT_VISCOSITY +MU_CONSTANT= 1.82e-05 +FREESTREAM_NU_FACTOR= 3.0 + +% -------------------- BOUNDARY CONDITION DEFINITION --------------------------% +% +% The jet enters at x/D = 0.5 with the profiles measured there (inlet_jet.dat). The far field supplies the +% entrained air through the inlet plane; at r = 30 D it suffices up to x/D = 100. +INC_INLET_TYPE= VELOCITY_INLET +MARKER_INLET= ( inlet_jet, 288.15, 34.10, 1.0, 0.0, 0.0 ) +SPECIFIED_INLET_PROFILE= YES +INLET_FILENAME= inlet_jet.dat +% The outlet is a far field too: a pressure outlet lets a reversed flow enter along the axis. +MARKER_FAR= ( farfield, outlet ) +MARKER_EULER= ( axis ) +MARKER_PERIODIC= ( periodic_1, periodic_2, 0.0, 0.0, 0.0, 5.0, 0.0, 0.0, 0.0, 0.0, 0.0 ) +MARKER_PLOTTING= ( axis ) +MARKER_MONITORING= ( axis ) +OBJECTIVE_FUNCTION= SURFACE_STATIC_PRESSURE +MARKER_ANALYZE= ( inlet_jet ) +MARKER_ANALYZE_AVERAGE= AREA + +% ------------- COMMON PARAMETERS DEFINING THE NUMERICAL METHOD ---------------% +% +NUM_METHOD_GRAD= GREEN_GAUSS +NUM_METHOD_GRAD_RECON= LEAST_SQUARES +CFL_NUMBER= 500 +CFL_ADAPT= NO +CFL_ADAPT_PARAM= ( 0.5, 1.1, 25, 2500, 0.001 ) +ITER= 10 + +% ------------------------ LINEAR SOLVER DEFINITION ---------------------------% +% +LINEAR_SOLVER= FGMRES +LINEAR_SOLVER_PREC= ILU +LINEAR_SOLVER_ERROR= 1E-4 +LINEAR_SOLVER_ITER= 50 + +% -------------------- FLOW NUMERICAL METHOD DEFINITION -----------------------% +% +CONV_NUM_METHOD_FLOW= FDS +MUSCL_FLOW= YES +SLOPE_LIMITER_FLOW= VENKATAKRISHNAN +VENKAT_LIMITER_COEFF= 0.05 +TIME_DISCRE_FLOW= EULER_IMPLICIT + +% -------------------- TURBULENT NUMERICAL METHOD DEFINITION ------------------% +% +CONV_NUM_METHOD_TURB= SCALAR_UPWIND +MUSCL_TURB= NO +TIME_DISCRE_TURB= EULER_IMPLICIT + +% --------------------------- CONVERGENCE PARAMETERS --------------------------% +% +CONV_FIELD= ADJOINT_PRESSURE +CONV_RESIDUAL_MINVAL= -10 +CONV_STARTITER= 10 + +% ------------------------- INPUT/OUTPUT INFORMATION --------------------------% +% +MESH_FILENAME= morse_wedge.su2 +MESH_FORMAT= SU2 +SOLUTION_FILENAME= solution_flow +RESTART_FILENAME= restart_flow +RESTART_ADJ_FILENAME= restart_adj +CONV_FILENAME= history +VOLUME_FILENAME= flow +SCREEN_OUTPUT= INNER_ITER, RMS_ADJ_PRESSURE, RMS_ADJ_VELOCITY-X, RMS_ADJ_NU_TILDE +HISTORY_OUTPUT= ITER, RMS_RES +VOLUME_OUTPUT= COORDINATES, SOLUTION, PRIMITIVE, RESIDUAL +OUTPUT_FILES= RESTART +WRT_RESTART_COMPACT= NO +OUTPUT_WRT_FREQ= 100 diff --git a/TestCases/parallel_regression_AD.py b/TestCases/parallel_regression_AD.py index ca3cfea19d98..659b3c8a452d 100644 --- a/TestCases/parallel_regression_AD.py +++ b/TestCases/parallel_regression_AD.py @@ -141,6 +141,14 @@ def main(): discadj_incomp_turb_NACA0012_sst.test_vals_aarch64 = [-4.294502, -3.069650, -7.086569, 0.000000, -1.151213] test_list.append(discadj_incomp_turb_NACA0012_sst) + # Adjoint Incompressible Turbulent Morse swirling jet, SA, one-cell periodic wedge + discadj_incomp_turb_morse_swirl_jet = TestCase('discadj_incomp_turb_morse_swirl_jet') + discadj_incomp_turb_morse_swirl_jet.cfg_dir = "incomp_rans/morse_swirl_jet" + discadj_incomp_turb_morse_swirl_jet.cfg_file = "morse_sa_adjoint.cfg" + discadj_incomp_turb_morse_swirl_jet.test_iter = 10 + discadj_incomp_turb_morse_swirl_jet.test_vals = [10.000000, -5.548784, -3.649149, -1.128684] + test_list.append(discadj_incomp_turb_morse_swirl_jet) + #################################################################### ### Disc. Adj. Axisymmetric RANS ### #################################################################### From 51bdfbf1e1335df1db8e909b8d2474025b53ff87 Mon Sep 17 00:00:00 2001 From: bigfooted Date: Sat, 28 Nov 2026 17:46:47 +0100 Subject: [PATCH 10/13] Show the residual on passive periodic points The passive face of an implicit periodic pair had its residual zeroed, so the volume output showed residuals on only one of the two planes. PERIODIC_IMPLICIT now also sends the master's (rotated) residual to the passive point. The solution and convergence history are unchanged. Co-Authored-By: Claude Opus 5.5 --- SU2_CFD/src/solvers/CSolver.cpp | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/SU2_CFD/src/solvers/CSolver.cpp b/SU2_CFD/src/solvers/CSolver.cpp index d36d3f1acaf6..762959f5847f 100644 --- a/SU2_CFD/src/solvers/CSolver.cpp +++ b/SU2_CFD/src/solvers/CSolver.cpp @@ -215,7 +215,7 @@ void CSolver::GetPeriodicCommCountAndType(const CConfig* config, MPI_TYPE = COMM_TYPE::DOUBLE; break; case PERIODIC_IMPLICIT: - COUNT_PER_POINT = nVar; + COUNT_PER_POINT = 2*nVar; MPI_TYPE = COMM_TYPE::DOUBLE; break; case PERIODIC_LAPLACIAN: @@ -693,12 +693,14 @@ void CSolver::InitiatePeriodicComms(CGeometry *geometry, for (iVar = 0; iVar < nVar; iVar++) { bufDSend[buf_offset+iVar] = base_nodes->GetSolution(iPoint, iVar); + bufDSend[buf_offset+nVar+iVar] = LinSysRes(iPoint, iVar); } - /*--- Rotate the momentum components of the solution array. ---*/ + /*--- Rotate the momentum components of the solution and of the residual. ---*/ if (rotate_periodic) { Rotate(zeros, &base_nodes->GetSolution(iPoint)[1], &bufDSend[buf_offset+1]); + Rotate(zeros, &LinSysRes(iPoint, 1), &bufDSend[buf_offset+nVar+1]); } break; @@ -1329,6 +1331,13 @@ void CSolver::CompletePeriodicComms(CGeometry *geometry, buf_offset++; } + /*--- The passive point shows the residual of the combined control volume of its master. ---*/ + + for (iVar = 0; iVar < nVar; iVar++) { + LinSysRes(iPoint, iVar) = bufDRecv[buf_offset]; + buf_offset++; + } + } break; From ac6529dc0f816057796d5d33b688e9881adf56c4 Mon Sep 17 00:00:00 2001 From: bigfooted Date: Sun, 29 Nov 2026 09:19:15 +0100 Subject: [PATCH 11/13] Fix forward-mode AD build of quantized block accumulation The accumulate lambda returned a CoDi expression in forward mode, which PassiveValue does not unwrap, so static_cast failed. Return T. Co-Authored-By: Claude Opus 5.5 --- Common/include/linear_algebra/CSysMatrix.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Common/include/linear_algebra/CSysMatrix.hpp b/Common/include/linear_algebra/CSysMatrix.hpp index 07827f6106d4..dfc32dc93a26 100644 --- a/Common/include/linear_algebra/CSysMatrix.hpp +++ b/Common/include/linear_algebra/CSysMatrix.hpp @@ -248,7 +248,7 @@ struct CBlockView { for (auto r = 0ul; r < nVar; ++r) { /*--- The old scale is kept because EncodeQuantRow overwrites qs[r] before re-reading the row. ---*/ const auto scale = DecodeQuantScale(qs[r]); - const auto sum = [&](unsigned long i, unsigned long j) { + const auto sum = [&](unsigned long i, unsigned long j) -> T { return static_cast(qv[i * nVar + j] * scale) + f(i, j); }; EncodeQuantRow(sum, qs[r], qv + r * nVar, nVar, r); From 3866f4e005094702b23cceec4d9a6128cc2ccc64 Mon Sep 17 00:00:00 2001 From: bigfooted Date: Sun, 29 Nov 2026 12:51:02 +0100 Subject: [PATCH 12/13] Fix forward-mode AD build of the periodic Jacobian coupling The Jacobian is active in forward AD, so the moved blocks use its scalar type there and stay passive otherwise. Co-Authored-By: Claude Opus 5.5 --- SU2_CFD/src/solvers/CSolver.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/SU2_CFD/src/solvers/CSolver.cpp b/SU2_CFD/src/solvers/CSolver.cpp index 32927b54abe5..278e737ff339 100644 --- a/SU2_CFD/src/solvers/CSolver.cpp +++ b/SU2_CFD/src/solvers/CSolver.cpp @@ -4922,8 +4922,10 @@ void CSolver::CouplePeriodicJacobian(CGeometry *geometry, const CConfig *config) return rotation.size() ? &rotation : nullptr; }; - su2passivematrix block(nVar, nVar), zero(nVar, nVar); - zero = passivedouble(0.0); + /*--- Blocks are passive, except in forward AD where the Jacobian itself is active. ---*/ + using BlockScalar = std::conditional_t::value, su2double, passivedouble>; + su2matrix block(nVar, nVar), zero(nVar, nVar); + zero = BlockScalar(0.0); auto ReadBlock = [&](unsigned long iRow, unsigned long iCol) { const auto view = Jacobian.GetBlockView(iRow, iCol); for (auto iVar = 0u; iVar < nVar; iVar++) From 0a03542781e3f321a3ca71c5389d20dd062e32d0 Mon Sep 17 00:00:00 2001 From: bigfooted Date: Sun, 29 Nov 2026 14:45:40 +0100 Subject: [PATCH 13/13] Update regression values after merging develop periodic3d_axis (new in develop) couples its one-cell wedge points; the Morse primal and adjoint values follow the develop changes; transonic_stator returns to the develop values. Co-Authored-By: Claude Opus 5.5 --- TestCases/parallel_regression.py | 4 ++-- TestCases/parallel_regression_AD.py | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/TestCases/parallel_regression.py b/TestCases/parallel_regression.py index e758ebd76bee..e2f767f8831a 100755 --- a/TestCases/parallel_regression.py +++ b/TestCases/parallel_regression.py @@ -507,7 +507,7 @@ def main(): periodic3d_axis.cfg_dir = "navierstokes/periodic3D_axis" periodic3d_axis.cfg_file = "config.cfg" periodic3d_axis.test_iter = 100 - periodic3d_axis.test_vals = [-3.353165, 0.157501, 2.051458, -9.594400, -9.594400] + periodic3d_axis.test_vals = [-3.271569, -0.284345, 2.163829, -7.848400, -7.848400] test_list.append(periodic3d_axis) ########################## @@ -962,7 +962,7 @@ def main(): inc_turb_morse_swirl_jet.cfg_dir = "incomp_rans/morse_swirl_jet" inc_turb_morse_swirl_jet.cfg_file = "morse_sa.cfg" inc_turb_morse_swirl_jet.test_iter = 10 - inc_turb_morse_swirl_jet.test_vals = [-10.569835, -8.376495, -9.323474, 12.000000, -4.059383, 71.328000] + inc_turb_morse_swirl_jet.test_vals = [-10.569500, -8.370534, -9.323232, 12.000000, -4.041427, 71.328000] test_list.append(inc_turb_morse_swirl_jet) # NACA0012, SST_SUST diff --git a/TestCases/parallel_regression_AD.py b/TestCases/parallel_regression_AD.py index 659b3c8a452d..19288e429169 100644 --- a/TestCases/parallel_regression_AD.py +++ b/TestCases/parallel_regression_AD.py @@ -146,7 +146,7 @@ def main(): discadj_incomp_turb_morse_swirl_jet.cfg_dir = "incomp_rans/morse_swirl_jet" discadj_incomp_turb_morse_swirl_jet.cfg_file = "morse_sa_adjoint.cfg" discadj_incomp_turb_morse_swirl_jet.test_iter = 10 - discadj_incomp_turb_morse_swirl_jet.test_vals = [10.000000, -5.548784, -3.649149, -1.128684] + discadj_incomp_turb_morse_swirl_jet.test_vals = [10.000000, -5.548813, -3.649165, -1.128723] test_list.append(discadj_incomp_turb_morse_swirl_jet) #################################################################### @@ -259,7 +259,7 @@ def main(): discadj_trans_stator.cfg_dir = "disc_adj_turbomachinery/transonic_stator_2D" discadj_trans_stator.cfg_file = "transonic_stator.cfg" discadj_trans_stator.test_iter = 79 - discadj_trans_stator.test_vals = [79.000000, -7.555649, -10.335509, -10.356935, -13.629546] + discadj_trans_stator.test_vals = [79.000000, -7.555647, -10.335486, -10.356919, -13.629543] discadj_trans_stator.test_vals_aarch64 = [79.000000, -7.555647, -10.335486, -10.356919, -13.629543] test_list.append(discadj_trans_stator)