diff --git a/applications/test/GAMGAgglomeration/Test-GAMGAgglomeration.C b/applications/test/GAMGAgglomeration/Test-GAMGAgglomeration.C index 82ccd8ce33..a11b78772e 100644 --- a/applications/test/GAMGAgglomeration/Test-GAMGAgglomeration.C +++ b/applications/test/GAMGAgglomeration/Test-GAMGAgglomeration.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -35,6 +35,116 @@ Description #include "meshTools.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +void checkConnectedAgglomeration +( + const lduMesh& mesh, + const labelUList& restrict, + const label nCoarse +) +{ + if (mesh.lduAddr().size() != restrict.size()) + { + FatalErrorIn + ( + "checkConnectedAgglomeration(const lduMesh&, const labelList&)" + ) << "nCells:" << mesh.lduAddr().size() + << " agglom:" << restrict.size() + << abort(FatalError); + } + + // Seed (master) for every region + labelList regionToMaster(nCoarse, -1); + labelList master(mesh.lduAddr().size(), -1); + forAll(restrict, cellI) + { + label region = restrict[cellI]; + if (regionToMaster[region] == -1) + { + // Set cell to be master for region + //Pout<< "For region " << region + // << " allocating local master " << cellI + // << endl; + regionToMaster[region] = cellI; + master[cellI] = cellI; + } + } + + // Now loop and transport master through region + const labelUList& lower = mesh.lduAddr().lowerAddr(); + const labelUList& upper = mesh.lduAddr().upperAddr(); + + while (true) + { + label nChanged = 0; + + forAll(lower, faceI) + { + label own = lower[faceI]; + label nei = upper[faceI]; + + if (restrict[own] == restrict[nei]) + { + // Region-internal face + + if (master[own] != -1) + { + if (master[nei] == -1) + { + master[nei] = master[own]; + nChanged++; + } + else if (master[nei] != master[own]) + { + FatalErrorIn("checkConnectedAgglomeration(..)") + << "problem" << abort(FatalError); + } + } + else if (master[nei] != -1) + { + master[own] = master[nei]; + nChanged++; + } + } + } + + reduce(nChanged, sumOp