コード例 #1
0
Foam::dummyAgglomeration::dummyAgglomeration
(
    const lduMesh& mesh,
    const dictionary& controlDict
)
:
    GAMGAgglomeration(mesh, controlDict),
    nLevels_(readLabel(controlDict.lookup("nLevels")))
{
    const label nCoarseCells = mesh.lduAddr().size();

    for
    (
        label nCreatedLevels = 0;
        nCreatedLevels < nLevels_;
        nCreatedLevels++
    )
    {
        nCells_[nCreatedLevels] = nCoarseCells;
        restrictAddressing_.set
        (
            nCreatedLevels,
            new labelField(identity(nCoarseCells))
        );

        agglomerateLduAddressing(nCreatedLevels);
    }

    // Shrink the storage of the levels to those created
    compactLevels(nLevels_);
}
Foam::BlockLduMatrix<Type>::BlockLduMatrix(const lduMesh& ldu)
:
    lduMesh_(ldu),
    diagPtr_(NULL),
    upperPtr_(NULL),
    lowerPtr_(NULL),
    interfaces_(ldu.interfaces().size()),
    coupleUpper_(ldu.lduAddr().nPatches()),
    coupleLower_(ldu.lduAddr().nPatches()),
    fixedEqns_(ldu.lduAddr().size()/fixFillIn)
{
    const lduAddressing& addr = ldu.lduAddr();

    forAll (coupleUpper_, i)
    {
        coupleUpper_.set(i, new CoeffField<Type>(addr.patchAddr(i).size()));
        coupleLower_.set(i, new CoeffField<Type>(addr.patchAddr(i).size()));
    }
コード例 #3
0
Foam::labelListList Foam::GAMGProcAgglomeration::globalCellCells
(
    const lduMesh& mesh
)
{
    const lduAddressing& addr = mesh.lduAddr();
    lduInterfacePtrsList interfaces = mesh.interfaces();

    const label myProcID = Pstream::myProcNo(mesh.comm());

    globalIndex globalNumbering
    (
        addr.size(),
        Pstream::msgType(),
        mesh.comm(),
        Pstream::parRun()
    );

    labelList globalIndices(addr.size());
    forAll(globalIndices, cellI)
    {
        globalIndices[cellI] = globalNumbering.toGlobal(myProcID, cellI);
    }
コード例 #4
0
Foam::dummyAgglomeration::dummyAgglomeration
(
    const lduMesh& mesh,
    const dictionary& controlDict
)
:
    GAMGAgglomeration(mesh, controlDict),
    nLevels_(readLabel(controlDict.lookup("nLevels")))
{
    const label nCoarseCells = mesh.lduAddr().size();

    for
    (
        label nCreatedLevels = 0;
        nCreatedLevels < nLevels_;
        nCreatedLevels++
    )
    {
        nCells_[nCreatedLevels] = nCoarseCells;
        restrictAddressingHost_.set
        (
            nCreatedLevels,
            new labelField(identity(nCoarseCells))
        );

        labelgpuList restrictAddressingTmp(restrictAddressingHost_[nCreatedLevels]);

        restrictSortAddressing_.set(nCreatedLevels,new labelgpuField(nCoarseCells));
        labelgpuList& restrictSortAddressing = restrictSortAddressing_[nCreatedLevels];

        thrust::copy
        (
            thrust::make_counting_iterator(0),
            thrust::make_counting_iterator(0)+restrictSortAddressing.size(),
            restrictSortAddressing.begin()
        );

        thrust::stable_sort_by_key
        (
            restrictAddressingTmp.begin(),
            restrictAddressingTmp.end(),
            restrictSortAddressing.begin()
        );

        agglomerateLduAddressing(nCreatedLevels);
    }

    // Shrink the storage of the levels to those created
    compactLevels(nLevels_);
}
コード例 #5
0
Foam::labelListList Foam::GAMGProcAgglomeration::globalCellCells
(
    const lduMesh& mesh
)
{
    const lduAddressing& addr = mesh.lduAddr();
    lduInterfacePtrsList interfaces = mesh.interfaces();

    const label myProcID = Pstream::myProcNo(mesh.comm());

    globalIndex globalNumbering
    (
        addr.size(),
        Pstream::msgType(),
        mesh.comm(),
        Pstream::parRun()
    );

    labelList globalIndices
    (
        identity
        (
            globalNumbering.localSize(myProcID),
            globalNumbering.localStart(myProcID)
        )
    );

    // Get the interface cells
    PtrList<labelList> nbrGlobalCells(interfaces.size());
    {
        // Initialise transfer of restrict addressing on the interface
        forAll(interfaces, inti)
        {
            if (interfaces.set(inti))
            {
                interfaces[inti].initInternalFieldTransfer
                (
                    Pstream::commsTypes::nonBlocking,
                    globalIndices
                );
            }
        }

        if (Pstream::parRun())
        {
            Pstream::waitRequests();
        }

        forAll(interfaces, inti)
        {
            if (interfaces.set(inti))
            {
                nbrGlobalCells.set
                (
                    inti,
                    new labelList
                    (
                        interfaces[inti].internalFieldTransfer
                        (
                            Pstream::commsTypes::nonBlocking,
                            globalIndices
                        )
                    )
                );
            }
        }
    }


    // Scan the neighbour list to find out how many times the cell
    // appears as a neighbour of the face. Done this way to avoid guessing
    // and resizing list
    labelList nNbrs(addr.size(), 1);

    const labelUList& nbr = addr.upperAddr();
    const labelUList& own = addr.lowerAddr();

    {
        forAll(nbr, facei)
        {
            nNbrs[nbr[facei]]++;
            nNbrs[own[facei]]++;
        }

        forAll(interfaces, inti)
        {
            if (interfaces.set(inti))
            {
                const labelUList& faceCells = interfaces[inti].faceCells();

                forAll(faceCells, i)
                {
                    nNbrs[faceCells[i]]++;
                }
            }
        }
    }
コード例 #6
0
Foam::autoPtr<Foam::lduPrimitiveMesh>
Foam::procFacesGAMGProcAgglomeration::singleCellMesh
(
    const label singleCellMeshComm,
    const lduMesh& mesh,
    scalarField& faceWeights
) const
{
    // Count number of faces per processor
    List<Map<label>> procFaces(UPstream::nProcs(mesh.comm()));
    Map<label>& myNeighbours = procFaces[UPstream::myProcNo(mesh.comm())];

    {
        const lduInterfacePtrsList interfaces(mesh.interfaces());
        forAll(interfaces, intI)
        {
            if (interfaces.set(intI))
            {
                const processorLduInterface& pp =
                    refCast<const processorLduInterface>
                    (
                        interfaces[intI]
                    );
                label size = interfaces[intI].faceCells().size();
                myNeighbours.insert(pp.neighbProcNo(), size);
            }
        }
    }

    Pstream::gatherList(procFaces, Pstream::msgType(), mesh.comm());
    Pstream::scatterList(procFaces, Pstream::msgType(), mesh.comm());

    autoPtr<lduPrimitiveMesh> singleCellMeshPtr;

    if (Pstream::master(mesh.comm()))
    {
        // I am master
        label nCells = Pstream::nProcs(mesh.comm());

        DynamicList<label> l(3*nCells);
        DynamicList<label> u(3*nCells);
        DynamicList<scalar> weight(3*nCells);

        DynamicList<label> nbrs;
        DynamicList<scalar> weights;

        forAll(procFaces, procI)
        {
            const Map<label>& neighbours = procFaces[procI];

            // Add all the higher processors
            nbrs.clear();
            weights.clear();
            forAllConstIter(Map<label>, neighbours, iter)
            {
                if (iter.key() > procI)
                {
                    nbrs.append(iter.key());
                    weights.append(iter());
                }
                sort(nbrs);
                forAll(nbrs, i)
                {
                    l.append(procI);
                    u.append(nbrs[i]);
                    weight.append(weights[i]);
                }
            }
        }