Repository navigation
Conversation
Contributor
Author
|
Main thing to go through is the adaptive CFL. It needs more attention anyway, because it is the best convergence accelerator that we have. For now this seems to work well on the cases I've tested. |
Agglomeration: - In 3D a symmetry plane met at an angle by another boundary no longer makes a node mixed, so wall/symmetry edges coarsen instead of staying fine-size singletons on every level (3D bump: 288 -> 26 singletons per level). - Columns standing on mixed nodes (wall ends) are paved first, so no column from either side straddles a leading or trailing edge. - A column only advances along a stiff edge of the mesh, so columns from side planes no longer march along thin layers and break up wall-normal columns. Prolongation: - The linear prolongation gradient is rejected only for a degenerate stencil (condition of the unit directions), and solved by Cholesky, instead of rejecting every stretched cell (constant fallback 31% -> 1.5% of cells). - Each level's correction fades in over 4 coarse CVs from where a wall ends. Adaptive CFL: escalating cuts on repeated stalls, and cap increases stay below the cap set at the last stall. 3D bump 17x177x81 (MG_CFL_SCALING 0.05): MG1 313 its, MG2 374, single grid 561, MG1 before 1128. 2D flat plate and 3-element airfoil unchanged. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
On an agglomerated coarse level the averaged gradient term of the viscous flux crosses faces that are poorly aligned with the edges between CV centroids. The implicit Jacobian does not hold that term, so the coarse iteration diverged once the coarse CFL exceeded a few hundred, which is why MG_CFL_SCALING had to be around 0.05. With the primitive gradients zero on coarse levels the coarse residual matches its Jacobian and the coarse smoother converges at any CFL. 3D bump 9x89x41, MG_CFL_SCALING 0.25: MG1 204, MG2 200, MG3 202 iterations (single grid 210, previously 700 / 318 / 321 or worse). Scaling 1.0 also works. 2D flat plate and 3-element airfoil unchanged. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A flip-flop above a certain CFL repeats at every CFL that the cap probe and the ceiling regrowth reach again, so on a stalled run each attempt cost 40 to 70 iterations and the residual never fell. The lowest CFL at which a flip-flop occurred now caps the CFL at half of it and limits the cap probe to that, until the flow residuals have fallen three orders of magnitude. 3D bump 17x177x81, MG1, CFL cap 1e5: converges in 480 iterations where it stalled at -10 for more than 960. Single grid, 2D flat plate, 2_2DCJ and the 2D bump are unchanged (561, 226, 330, 581 iterations); 4_2DANW does not reach the rule and behaves as before. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…rge function' Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
…e/su2 into feature_mg_linear_prolong
# Conflicts: # Common/src/linear_algebra/CSysSolve.cpp
4 of 6 tasks
MG_LINEAR_PROLONGATION now also selects the limited linear reconstruction when the full multigrid warmup hands its solution to the next finer level, for the flow and the scalar solvers. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… promotion Wall nodes take their coarse wall parent's value instead of the linear extrapolation, so the promoted solution starts from the wall condition. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…in the template The Corr-smooth column of MG_SMOOTH_OUTPUT printed the initial norm, which was never set. The config template now shows MG_CORRECTION_SMOOTH at its default of 0. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The fit now weights each neighbour's directional difference equally, which makes it independent of the neighbour distances. Restricting analytic fields and prolongating them back, the error drops on every level of an irregular mixed-element mesh (wall-layer field on level 3: 0.24 of the constant-operator error, against 0.36 unweighted). Iteration counts are equal or slightly lower: 2_2DCJ 197 (198), 1_2DZP 137x097 214 (217), 273x193 at CFL cap 500 2040 (2040). The aspect-ratio gate stays. Without it, the more accurate transfer slows the solver in boundary and shear layers (2_2DCJ 266, 273x193 capped 2143). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The frozen and stall rules cut the CFL by 0.75x per event and kept the cuts. The branch that undid them only armed after a 30x reduction, so a run that started below 30x CFLmin reached the floor first, and the cap probe could not raise a plateau cap above itself. The CFL then stayed at CFLmin: all 4_2DANW 1025 cluster runs, 2_2DCJ 0levelsdown MG3/MG4 and 5_2DMEA mesh 5 MG0. A plateau now triggers one cut to 0.35x the plateau CFL. After a 40 iteration transient, the fall of the mean log residual over 100 iterations (S1) is compared with the fall before the cut (S0): - S1 >= 1.3 max(S0, 0) + 0.03: the cut is kept, and the cap may grow back to 0.7x the plateau CFL; - S1 < S0 - 0.03: the cut is undone, the plateau caps are released and no more probes follow; - otherwise the cut is undone, probes hold for 300 iterations, and the next one needs a fall below min(0.5 S0, S0 - 0.03). No probe starts while the residual falls by 0.3 decades per 100 iterations or more, or while the first flow residual reaches CONV_RESIDUAL_MINVAL within the iteration limit at the current rate. A jump, regression, flip-flop or linear solver failure ends a probe. 4_2DANW 65 on 2 ranks: MG0 reaches -12 at iteration 1384 (before: -10 at 2178, no -12 in 2500), MG1 -12 at 1395 (before: no -10 in 2500). With a kept cut as a permanent cap, the CFL stayed at 205 and MG0 converged slower than with the ratchet, hence the regrowth. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…-smoothing step The coarse residual for the forcing term and the first coarse pre-smoothing step were evaluated at the same state. The forcing term evaluation now also assembles the Jacobian and the time step, and the first pre-smoothing step on that level starts from them. This saves one preprocessing and one residual evaluation per coarse level and cycle, for the flow system when the coarse level has pre-smoothing steps. A second visit of a W-cycle evaluates again. SetForcing_Term is split in two. SetRestricted_Residual stores the restricted defect before the coarse residual is computed, so the coarse boundary conditions still act on it, and SetForcing_Term subtracts the coarse residual afterwards. Results are bitwise identical without symmetry planes or Euler walls (4_2DANW 65 MG3, flat plate with its symmetry marker as farfield). With them, the projection of the normal momentum acts on the two parts of the forcing term separately, which differs by round-off: 1.7e-6 (NACA0012 Euler) and 1.6e-5 (laminar flat plate) in log rms after 100 iterations. About 2-4% less time per iteration on the 273x193 flat plate with MG3. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… CFL bounds - MG_LINEAR_SOLVER_ITER defaults to 3 on the coarse levels. - TURB_SUBITER sets the number of turbulence iterations per flow iteration. - AdaptCFLNumber scales the CFL floor and cap of a coarse level with MG_CFL_SCALING, and loses the unused flip-flop detection. - MG_SMOOTH_OUTPUT prints the smoothing and correction gain of the finest level and the accumulated work in finest-grid equivalents. - The coarsest level is smoothed at least once. - Coarse residuals are reduced once per cycle with MG_SMOOTH_OUTPUT. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
- Coarse levels run at half the CFL of the next finer level by default (was a quarter). On the six turbulence verification cases on fine meshes this lowers multigrid work relative to single grid, most on the flat plate (0.83 -> 0.68), the 2D bump (0.41 -> 0.35) and the NACA 4412 airfoil (0.99 -> 0.85); drag is unchanged. - Update the reference values of all regression tests that use multigrid without setting MG_CFL_SCALING. Most references were already stale from the earlier multigrid changes on this branch: with MG_CFL_SCALING= 0.25 only 2 of 38 tests reproduced them. - hybrid edge_VW now reaches CONV_RESIDUAL_MINVAL before iteration 25; test at iteration 20. - aarch64 references that differed from x86 are left unchanged. - Not regenerated locally (no MPI build of the Python wrapper, stale AD build): parallel pywrapper_naca0012, pywrapper_aeroelastic, pywrapper_unsteadyCHT, hybrid pywrapper translating/moving-frame file diffs, and the AD scripts' directdiff_euler_py / discadj_euler_py. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The reference values of wedge, rae2822_sa, rae2822_sst, bars_SST_2D and axi_rans_air_nozzle_species conflicted, both branches had changed them. They are regenerated with the merged code for the serial and parallel suites. The hybrid suite takes the serial values, which it matched before the merge. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
- CEulerSolver: the wall-end loops no longer redeclare iMarker. - CSysMatrix: LevelProgress gets a copy assignment to match its copy constructor. - CDriver, CMultiGridIntegration: the owner of a reduced maximum is found with >= instead of ==, and the NaN test uses std::isnan. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
- MUSCL_FIRST_ORDER_WALL_ENDS stops with an error for the incompressible and NEMO solvers, which do not implement it. - The coarse-grid face-closure report prints only with MG_SMOOTH_OUTPUT. - config_template.cfg describes the actual linear prolongation fallback and the wall-end fade, and lists TURB_SUBITER and MG_LINEAR_SOLVER_ITER. - Remove the comments left from the CFL_ADAPT_RESIDUAL option. - Use std::this_thread::yield instead of the POSIX sched_yield, and rename a local constant FAR, which is a macro on Windows. - Restore the C3DContainerDecorator member; the caller avoids sizing tests on an unsized container. - Fix a sign-compare warning in the adaptive CFL. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…anch They are independent of multigrid and go to a separate pull request. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…tartup Coarse levels zeroed the primitive gradient so the viscous flux matched its Jacobian. The output call on the active startup level zeroed it too, which left the turbulence model there without vorticity, strain rate and velocity gradient. That call now computes the gradient. Flat plate 273x193, MG_CFL_SCALING 1.0: SST reached muT/mu of 1e10 on the coarse levels without vorticity and about 300 with it, and converges in 497 instead of 744 iterations. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The distance from a wall end was counted on each rank without an exchange, so a fade that reached a partition interface stopped there and the correction weights depended on the number of ranks. The front now grows one layer per pass with a halo exchange after each pass. The weights are only computed with MUSCL_FIRST_ORDER_WALL_ENDS. Three-element airfoil, 4 ranks: level 3 had 42 and 68 coarse CVs at distance 2 and 3 instead of 46 and 77. On 1 and 2 ranks the counts are unchanged. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Every split line moved to the partition holding most of it, whatever the load, so the imbalance grew with the rank count. Every rank now sees the split lines and processes them in root order, moving each to the partition with most of its points that stays within the load tolerance (1 + PARMETIS_TOLERANCE times the mean load) and leaves no partition empty. A line no partition can take stays split, and their number is reported. Flat plate 1089x769, 16 ranks: imbalance 1.057 before, 1.017 now, all lines kept whole. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The vectorized viscous numerics take |d|^2/|d.n| as the distance in the Jacobian, which matches the normal derivative of the corrected gradient. CAvgGrad_Flow and CGeneralAvgGrad_Flow, used for the other upwind schemes and for non-ideal gases, now do the same. Three-element airfoil with HLLC: same convergence (467 iterations) and same converged solution. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
On the 137x97 flat plate, serial and parallel: - turb_flatplate_mg_linear: SA with MG_LINEAR_PROLONGATION, MUSCL_FIRST_ORDER_WALL_ENDS and PARMETIS_ANISOTROPY_WEIGHT. - turb_flatplate_sst_fullmg: SST with the full-multigrid startup and TURB_SUBITER= 2, which runs the turbulence model on the coarse levels within the 20 tested iterations. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…evel at the level-0 CFL - AdaptCFLNumber is the develop version again. It keeps the coarse-level CFL bounds scaled with MG_CFL_SCALING. The residual-driven adaptation moves to its own pull request as an opt-in method. - During the full-multigrid startup the active level takes the level-0 CFL, and only the levels below it are scaled with MG_CFL_SCALING. The active level was given the coarse-level CFL of its depth before, 0.08 to 0.27 for CFL_NUMBER 10 on level 3. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Regenerate the regression references changed by both branches, and restrict the wall distance to the coarse grids also when the case has no walls.
…k diagnostics The stiffness ratio of the front paving is passive, which fixes the AD compilation. The anisotropy edge weight is clamped in floating point before conversion to idx_t, and capped so that the sum of all weights stays within half the range of idx_t, with an error if the graph is too large for 32-bit indices. The correction-peak and per-rank closure dumps of MG_SMOOTH_OUTPUT are removed, the closure summary stays on the master rank. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
The coarse-grid coordinate and wall-distance exchanges ran inside a single-thread block, but CompleteComms has its own worksharing loop and barriers. In the discrete adjoint recording UpdateGeometry runs inside a parallel region, so the ranks deadlocked. All threads now call the exchanges, as for the fine grid. The discrete adjoint transposes every recorded linear solve with LINEAR_SOLVER_ITER. With MG_LINEAR_SOLVER_ITER capping the forward coarse solves, the reverse sweep had to grow the FGMRES basis inside the parallel region, which stopped the run with "If this class were constructed in parallel". The cap is no longer applied with the discrete adjoint. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Values regenerated in the CI containers for all suites. The gradient files of cont_adj_euler, multiple_ffd and the moving-frame pywrapper forces are regenerated from container runs. The unsteady NACA0012 adjoint gradient reference lives in the TestCases data repo and differs by at most 5e-4 % in 5 of 242 entries, so both tests get a 0.001 % file tolerance. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…oarse viscous flux - Incompressible coarse levels keep the averaged viscous gradient. The edge-only coarse flux and the effective-distance Jacobian are compressible only, and the incompressible Jacobian has no effective distance, so the corrected coarse flux did not match it. - The active level of the Full-MG startup uses LINEAR_SOLVER_ITER; only the levels below it are capped by MG_LINEAR_SOLVER_ITER (CConfig::GetMG_LinSolIter). - MG_LINEAR_SOLVER_ITER entries of 0 and TURB_SUBITER= 0 are rejected. A 0 entry used to mean LINEAR_SOLVER_ITER, the opposite of a cap. - The MUSCL_FIRST_ORDER_WALL_ENDS flags move to CEulerSolver::SetWallEndFlags, exchange halos through InitiateComms with a new FIRST_ORDER_RECONSTRUCTION quantity instead of a hand-written Sendrecv loop, and are recomputed after mesh deformation. The multigrid correction weights are rebuilt when the flags change. References regenerated in the CI containers: inc_lam_cylinder, inc_lam_sphere and the cantera cases (incompressible MG), naca0012_FMG and turb_flatplate_sst_fullmg (Full-MG cap). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Proposed Changes
Multigrid on stretched meshes was slow or unstable in three situations. The coarse grids differed with the number of MPI ranks. The coarse-grid correction was only piecewise constant. The coarse-grid viscous operator did not match the fine grid. This PR addresses these. The new features are options that are off by default; the changes to existing multigrid defaults are listed separately below.
New options (all off by default)
MG_LINEAR_PROLONGATION). The coarse-grid correction is prolonged with a limited least-squares gradient over each coarse control volume, instead of injecting the parent value into every child. The reconstruction is exact for a linear correction, and the children still average back to the coarse value. Walls and symmetry planes keep the constant operator for the velocity. Cells with a badly conditioned or very stretched stencil keep the constant operator.PARMETIS_ANISOTROPY_WEIGHT). Graph edges are weighted by the aspect ratio of their cells, and anisotropic lines are moved onto a single rank. A line edge is an edge that is the strongest at one end, or at least half the strongest at both ends. The weights are capped so that their sum stays within half the range ofidx_t, and the run stops with an error if a 32-bit ParMETIS cannot represent them for the given graph.MUSCL_FIRST_ORDER_WALL_ENDS). MUSCL is dropped to first order on the edges of points where a no-slip wall ends on a surface-continuing boundary, or at a sharp edge. The multigrid correction is not prolongated to these points and their neighbours, and fades in over 4 coarse control volumes. Compressible flow solver only.TURB_SUBITER). Number of turbulence iterations per flow iteration, default 1.MG_LINEAR_SOLVER_ITER). See the default below.Agglomeration and Full-MG
MGLEVELis checked against the supported maximum, and the startup stagnation test no longer counts a growing residual as stagnation.MG_SMOOTH_OUTPUTadditionally reports linear solver iterations, the work in finest-grid equivalents, and the face closure of each coarse grid.Changes to existing behaviour (not behind an option)
These change the results of existing multigrid and implicit viscous cases, and the regression references have been updated accordingly.
MG_CFL_SCALINGdefaults to 0.5 (was 0.25), and the CFL limits of the adaptive CFL scale with the level.MG_LINEAR_SOLVER_ITER), never more thanLINEAR_SOLVER_ITER.Not part of this PR
The residual-driven CFL adaptation and the BCGSTAB best-iterate change that were developed on this branch are not included here.
PR Checklist
Put an X by all that apply. You can fill this out after submitting the PR. If you have any questions, don't hesitate to ask! We want to help. These are a guide for you to know what the reviewers will be looking for in your contribution.
pre-commit run --allto format old commits.