From 55c81bce1b9c10cbbefac3d94118f303caa21ebe Mon Sep 17 00:00:00 2001 From: ksaurabh-amd <> Date: Thu, 9 Oct 2025 11:53:34 +0100 Subject: [PATCH] ENH: GAMGAgglomeration: increase repeatability. Fixes #3450 --- .../pairGAMGAgglomeration/pairGAMGAgglomerate.C | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/OpenFOAM/matrices/lduMatrix/solvers/GAMG/GAMGAgglomerations/pairGAMGAgglomeration/pairGAMGAgglomerate.C b/src/OpenFOAM/matrices/lduMatrix/solvers/GAMG/GAMGAgglomerations/pairGAMGAgglomeration/pairGAMGAgglomerate.C index 7da7012658..dfc6d6e257 100644 --- a/src/OpenFOAM/matrices/lduMatrix/solvers/GAMG/GAMGAgglomerations/pairGAMGAgglomeration/pairGAMGAgglomerate.C +++ b/src/OpenFOAM/matrices/lduMatrix/solvers/GAMG/GAMGAgglomerations/pairGAMGAgglomeration/pairGAMGAgglomerate.C @@ -221,9 +221,14 @@ Foam::tmp Foam::pairGAMGAgglomeration::agglomerate auto tcoarseCellMap = tmp::New(nFineCells, -1); auto& coarseCellMap = tcoarseCellMap.ref(); + // Small tolerance to account for faces potentially having slightly + // different truncation error in their weights from run to run + // (e.g. due to offloading). If all the largest faces per cell are + // within this tolerance use the first one. This guarantees repeatability. + const scalar tol = 1E-10; + nCoarseCells = 0; label celli; - for (label cellfi=0; cellfi Foam::pairGAMGAgglomeration::agglomerate ( coarseCellMap[upperAddr[facei]] < 0 && coarseCellMap[lowerAddr[facei]] < 0 - && faceWeights[facei] > maxFaceWeight + && faceWeights[facei] > maxFaceWeight*(1.0 + tol) ) { // Match found. Pick up all the necessary data @@ -282,7 +287,7 @@ Foam::tmp Foam::pairGAMGAgglomeration::agglomerate { label facei = cellFaces[faceOs]; - if (faceWeights[facei] > clusterMaxFaceCoeff) + if (faceWeights[facei] > clusterMaxFaceCoeff*(1.0 + tol)) { clusterMatchFaceNo = facei; clusterMaxFaceCoeff = faceWeights[facei];