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 b0f5e757da..508c0c3f94 100644 --- a/src/OpenFOAM/matrices/lduMatrix/solvers/GAMG/GAMGAgglomerations/pairGAMGAgglomeration/pairGAMGAgglomerate.C +++ b/src/OpenFOAM/matrices/lduMatrix/solvers/GAMG/GAMGAgglomerations/pairGAMGAgglomeration/pairGAMGAgglomerate.C @@ -26,177 +26,7 @@ License #include "pairGAMGAgglomeration.H" #include "lduAddressing.H" -// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // - -Foam::tmp Foam::pairGAMGAgglomeration::agglomerate -( - label& nCoarseCells, - const lduAddressing& fineMatrixAddressing, - const scalarField& faceWeights -) -{ - const label nFineCells = fineMatrixAddressing.size(); - - const labelUList& upperAddr = fineMatrixAddressing.upperAddr(); - const labelUList& lowerAddr = fineMatrixAddressing.lowerAddr(); - - // For each cell calculate faces - labelList cellFaces(upperAddr.size() + lowerAddr.size()); - labelList cellFaceOffsets(nFineCells + 1); - - // memory management - { - labelList nNbrs(nFineCells, 0); - - forAll(upperAddr, facei) - { - nNbrs[upperAddr[facei]]++; - } - - forAll(lowerAddr, facei) - { - nNbrs[lowerAddr[facei]]++; - } - - cellFaceOffsets[0] = 0; - forAll(nNbrs, celli) - { - cellFaceOffsets[celli+1] = cellFaceOffsets[celli] + nNbrs[celli]; - } - - // reset the whole list to use as counter - nNbrs = 0; - - forAll(upperAddr, facei) - { - cellFaces - [ - cellFaceOffsets[upperAddr[facei]] + nNbrs[upperAddr[facei]] - ] = facei; - - nNbrs[upperAddr[facei]]++; - } - - forAll(lowerAddr, facei) - { - cellFaces - [ - cellFaceOffsets[lowerAddr[facei]] + nNbrs[lowerAddr[facei]] - ] = facei; - - nNbrs[lowerAddr[facei]]++; - } - } - - - // go through the faces and create clusters - - tmp tcoarseCellMap(new labelField(nFineCells, -1)); - labelField& coarseCellMap = tcoarseCellMap(); - - nCoarseCells = 0; - - for (label celli=0; celli maxFaceWeight - ) - { - // Match found. Pick up all the necessary data - matchFaceNo = facei; - maxFaceWeight = faceWeights[facei]; - } - } - - if (matchFaceNo >= 0) - { - // Make a new group - coarseCellMap[upperAddr[matchFaceNo]] = nCoarseCells; - coarseCellMap[lowerAddr[matchFaceNo]] = nCoarseCells; - nCoarseCells++; - } - else - { - // No match. Find the best neighbouring cluster and - // put the cell there - label clusterMatchFaceNo = -1; - scalar clusterMaxFaceCoeff = -GREAT; - - for - ( - label faceOs=cellFaceOffsets[celli]; - faceOs clusterMaxFaceCoeff) - { - clusterMatchFaceNo = facei; - clusterMaxFaceCoeff = faceWeights[facei]; - } - } - - if (clusterMatchFaceNo >= 0) - { - // Add the cell to the best cluster - coarseCellMap[celli] = max - ( - coarseCellMap[upperAddr[clusterMatchFaceNo]], - coarseCellMap[lowerAddr[clusterMatchFaceNo]] - ); - } - } - } - } - - - // Check that all cells are part of clusters, - // if not create single-cell "clusters" for each - for (label celli=0; celli Foam::pairGAMGAgglomeration::agglomerate +( + label& nCoarseCells, + const lduAddressing& fineMatrixAddressing, + const scalarField& faceWeights +) +{ + const label nFineCells = fineMatrixAddressing.size(); + + const labelUList& upperAddr = fineMatrixAddressing.upperAddr(); + const labelUList& lowerAddr = fineMatrixAddressing.lowerAddr(); + + // For each cell calculate faces + labelList cellFaces(upperAddr.size() + lowerAddr.size()); + labelList cellFaceOffsets(nFineCells + 1); + + // memory management + { + labelList nNbrs(nFineCells, 0); + + forAll(upperAddr, facei) + { + nNbrs[upperAddr[facei]]++; + } + + forAll(lowerAddr, facei) + { + nNbrs[lowerAddr[facei]]++; + } + + cellFaceOffsets[0] = 0; + forAll(nNbrs, celli) + { + cellFaceOffsets[celli+1] = cellFaceOffsets[celli] + nNbrs[celli]; + } + + // reset the whole list to use as counter + nNbrs = 0; + + forAll(upperAddr, facei) + { + cellFaces + [ + cellFaceOffsets[upperAddr[facei]] + nNbrs[upperAddr[facei]] + ] = facei; + + nNbrs[upperAddr[facei]]++; + } + + forAll(lowerAddr, facei) + { + cellFaces + [ + cellFaceOffsets[lowerAddr[facei]] + nNbrs[lowerAddr[facei]] + ] = facei; + + nNbrs[lowerAddr[facei]]++; + } + } + + + // go through the faces and create clusters + + tmp tcoarseCellMap(new labelField(nFineCells, -1)); + labelField& coarseCellMap = tcoarseCellMap(); + + nCoarseCells = 0; + label celli; + + for (label cellfi=0; cellfi maxFaceWeight + ) + { + // Match found. Pick up all the necessary data + matchFaceNo = facei; + maxFaceWeight = faceWeights[facei]; + } + } + + if (matchFaceNo >= 0) + { + // Make a new group + coarseCellMap[upperAddr[matchFaceNo]] = nCoarseCells; + coarseCellMap[lowerAddr[matchFaceNo]] = nCoarseCells; + nCoarseCells++; + } + else + { + // No match. Find the best neighbouring cluster and + // put the cell there + label clusterMatchFaceNo = -1; + scalar clusterMaxFaceCoeff = -GREAT; + + for + ( + label faceOs=cellFaceOffsets[celli]; + faceOs clusterMaxFaceCoeff) + { + clusterMatchFaceNo = facei; + clusterMaxFaceCoeff = faceWeights[facei]; + } + } + + if (clusterMatchFaceNo >= 0) + { + // Add the cell to the best cluster + coarseCellMap[celli] = max + ( + coarseCellMap[upperAddr[clusterMatchFaceNo]], + coarseCellMap[lowerAddr[clusterMatchFaceNo]] + ); + } + } + } + } + + // Check that all cells are part of clusters, + // if not create single-cell "clusters" for each + for (label cellfi=0; cellfi