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]]++;
        }
Ejemplo n.º 2
0
void Foam::meshReader::createPolyCells()
{
    // loop through all cell faces and create connectivity. This will produce
    // a global face list and will describe all cells as lists of face labels

    const faceListList& cFaces = cellFaces();

    // count the maximum number of faces and set the size of the cellPolys_
    cellPolys_.setSize(cFaces.size());

    label maxFaces = 0;

    forAll(cellPolys_, cellI)
    {
        cellPolys_[cellI].setSize(cFaces[cellI].size(), -1);

        maxFaces += cFaces[cellI].size();
    }
Ejemplo n.º 3
0
// Builds the list of faces defining the boundary of the domain.
// These are the faces that are referenced by only one cell. 
// This list is used in the lookup of boundary condition patches.
void CGNSBoundaryConditions::identifyBoundaryFaces()
{
    const Foam::cellShapeList& cellsAsShapes = mapper.getCells();
	
    /* the following code was strongly inspired from 
        polyMesh::polyMesh
	(
	const IOobject& io,
	const pointField& points,
	const cellShapeList& cellsAsShapes,
	const faceListList& boundaryFaces,
	const wordList& boundaryPatchNames,
	const wordList& boundaryPatchTypes,
	const word& defaultBoundaryPatchType,
	const wordList& boundaryPatchPhysicalTypes
	)
	see src/OpenFOAM/meshes/polyMesh/polyMeshFromShapeMesh.C
        */

    // Set up a list of face shapes for each cell
    if ( debug_ )
	Foam::Info << "Allocating cellFaceList - size = " << cellsAsShapes.size() << Foam::endl;
    Foam::faceListList cellFaceList(cellsAsShapes.size()); // the list of faces making up each cell
    if ( debug_ )
	Foam::Info << "Allocating cellFaces - size = " << cellsAsShapes.size() << Foam::endl;
    Foam::labelListList cellFaces(cellsAsShapes.size());   // the list of unique face ids making up each cell
    
    if ( debug_ )
	Foam::Info << "Prefilling cellFaces for each cell" << Foam::endl;
    forAll(cellsAsShapes, cellI)
    {
        cellFaceList[cellI] = cellsAsShapes[cellI].faces();
        
	// Count maximum possible numer of mesh faces
        //maxFaces += cellsFaceShapes[cellI].size();
	Foam::label nCellFaces = cellFaceList[cellI].size();
        cellFaces[cellI].setSize( nCellFaces );

        // Initialise cell faces ids to -1 to flag undefined faces
        cellFaces[cellI] = -1; // this sets the whole list to -1
    }
Ejemplo n.º 4
0
void Foam::meshReader::createPolyBoundary()
{
    label nBoundaryFaces = 0;
    label nMissingFaces = 0;
    label nInterfaces = 0;

    const faceListList& cFaces = cellFaces();

    // determine number of non-patched faces:
    forAll(cellPolys_, cellI)
    {
        cell& curCell = cellPolys_[cellI];

        forAll(curCell, fI)
        {
            if (curCell[fI] < 0)
            {
                nMissingFaces++;
            }
        }
    }
    forAll(ptCells, i)
    {
        ptCells[i].setSize(UNIT_POINT_CELLS);
    }

    // Initialize the list of labels which will hold the count of the
    // actual number of cells per point during the analysis
    labelList cellCount(nPoints, 0);

    // Note. Unlike the standard point-cell algorithm, which asks the cell for
    // the supporting point labels, we need to work based on the cell faces.
    // This is because some of the faces do not come from the cell shape.
    // It is also advantageous to remove duplicates from the point-cell
    // addressing, because this removes a lot of waste later.

    faceListList& cFaces = cellFaces();

    // For each cell
    forAll(cFaces, cellI)
    {
        const faceList& faces = cFaces[cellI];

        forAll(faces, i)
        {
            // For each vertex
            const labelList& labels = faces[i];

            forAll(labels, j)
            {
                // Set working point label
                label curPoint = labels[j];