Skip to content

Avoid recomputing residual norms for MG early exit#2786

Open
pcarruscag wants to merge 2 commits intodevelopfrom
pedro/use_available_residual
Open

Avoid recomputing residual norms for MG early exit#2786
pcarruscag wants to merge 2 commits intodevelopfrom
pedro/use_available_residual

Conversation

@pcarruscag
Copy link
Copy Markdown
Member

@pcarruscag pcarruscag commented Apr 12, 2026

I think the norm should include the MG part of the residual, because it is the sum of the 2 that the solver is trying to converge.

@pcarruscag pcarruscag changed the title Test Avoid recomputing residual norms for MG early exit Apr 13, 2026
@pcarruscag pcarruscag requested a review from bigfooted April 13, 2026 04:46
SU2_ZONE_SCOPED

if (geometry->GetMGLevel() != MESH_0) return;
if (geometry->GetMGLevel() != MESH_0 && !config->GetMGOptions().MG_Smooth_EarlyExit) return;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We do not need to set the RMS residual on the fine mesh when we do an early exit because we already call computelinsysresRMS?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What this does is compute the residual for all mesh levels, if MG early exit is on.
Before it was only doing the fine mesh.

Comment on lines +605 to +612
/*--- Time integration, update solution using the old solution plus the solution increment ---*/
Time_Integration(geometry_fine, solver_container_fine, config, iRKStep, RunTime_EqSystem);

/*--- Capture initial RMS after the very first residual evaluation.
* This is the earliest point where LinSysRes = R(u_current) (not stale).
* ComputeLinSysResRMS must be called by all threads (uses parallel dot). ---*/
* This is the earliest point where LinSysRes = R(u_current) (not stale). ---*/
if (iPreSmooth == 0 && iRKStep == 0) {
const passivedouble initial_rms = ComputeLinSysResRMS(solver_fine);
BEGIN_SU2_OMP_SAFE_GLOBAL_ACCESS
{
BEGIN_SU2_OMP_SAFE_GLOBAL_ACCESS {
const passivedouble initial_rms = ComputeLinSysResRMS(solver_fine);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok that makes sense, so space+time gives complete update, then we compute residual of this

Comment on lines +625 to +626
BEGIN_SU2_OMP_SAFE_GLOBAL_ACCESS {
const passivedouble current_rms = ComputeLinSysResRMS(solver_fine);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok, we need to compute this again because of the update with the boundary conditions in postprocessing?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is as before, to check the convergence of the smoothing iterations.


/*--- Record final correction norm for debugging output. ---*/
if (config->GetMGOptions().MG_Smooth_Output) {
const su2double res = sqrt(solver->LinSysRes.squaredNorm() / (nVar * geometry->GetGlobal_nPointDomain()));
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is not the same as linsysres?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is equivalent, but here it needs to be computed from scratch instead of grabbing the result from the solver because this function manipulates LinSysRes directly, not through the solver (Space + Time integration).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants