Foam::tmp<Foam::labelField> 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]]++; }
void Foam::MGridGenGAMGAgglomeration:: makeCompactCellFaceAddressingAndFaceWeights ( const lduAddressing& fineAddressing, List<idxtype>& cellCells, List<idxtype>& cellCellOffsets, const scalarField& magSi, List<scalar>& faceWeights ) { const label nFineCells = fineAddressing.size(); const label nFineFaces = fineAddressing.upperAddr().size(); const labelUList& upperAddr = fineAddressing.upperAddr(); const labelUList& lowerAddr = fineAddressing.lowerAddr(); // Number of neighbours for each cell labelList nNbrs(nFineCells, 0); forAll(upperAddr, facei) { nNbrs[upperAddr[facei]]++; } forAll(lowerAddr, facei) { nNbrs[lowerAddr[facei]]++; } // Set the sizes of the addressing and faceWeights arrays cellCellOffsets.setSize(nFineCells + 1); cellCells.setSize(2*nFineFaces); faceWeights.setSize(2*nFineFaces); cellCellOffsets[0] = 0; forAll(nNbrs, celli) { cellCellOffsets[celli+1] = cellCellOffsets[celli] + nNbrs[celli]; }