Ejemplo n.º 1
0
//- Calculate map from new patch faces to old patch faces. -1 where
//  could not map.
Foam::labelList Foam::fvMeshAdder::calcPatchMap
(
    const label oldStart,
    const label oldSize,
    const labelList& oldToNew,
    const polyPatch& newPatch,
    const label unmappedValue
)
{
    labelList newToOld(newPatch.size(), unmappedValue);

    label newStart = newPatch.start();
    label newSize = newPatch.size();

    for (label i = 0; i < oldSize; i++)
    {
        label newFaceI = oldToNew[oldStart+i];

        if (newFaceI >= newStart && newFaceI < newStart+newSize)
        {
            newToOld[newFaceI-newStart] = i;
        }
    }
    return newToOld;
}
Ejemplo n.º 2
0
Foam::labelList Foam::manualRenumber::renumber
(
    const polyMesh& mesh,
    const pointField& points
) const
{
    labelIOList newToOld
    (
        IOobject
        (
            dataFile_,
            mesh.facesInstance(),
            mesh,
            IOobject::MUST_READ,
            IOobject::AUTO_WRITE,
            false
        )
    );

    // check if the final renumbering is OK

    if (newToOld.size() != points.size())
    {
        FatalErrorIn
        (
            "manualRenumber::renumber(const pointField&, const scalarField&)"
        )   << "Size of renumber list does not correspond "
            << "to the number of points.  Size: "
            << newToOld.size() << " Number of points: "
            << points.size()
            << ".\n" << "Manual renumbering data read from file "
            << dataFile_ << "." << endl
            << exit(FatalError);
    }

    // Invert to see if one to one
    labelList oldToNew(points.size(), -1);
    forAll(newToOld, i)
    {
        label origCellI = newToOld[i];

        if (origCellI < 0 || origCellI >= points.size())
        {
            FatalErrorIn
            (
                "manualRenumber::renumber(const pointField&"
                ", const scalarField&)"
            )   << "Renumbering is not one-to-one. Index "
                << i << " maps onto original cell " << origCellI
                << ".\n" << "Manual renumbering data read from file "
                << dataFile_ << "." << endl
                << exit(FatalError);
        }

        if (oldToNew[origCellI] == -1)
        {
            oldToNew[origCellI] = i;
        }
        else
        {
            FatalErrorIn
            (
                "manualRenumber::renumber(const pointField&"
                ", const scalarField&)"
            )   << "Renumbering is not one-to-one. Both index "
                << oldToNew[origCellI]
                << " and " << i << " map onto " << origCellI
                << ".\n" << "Manual renumbering data read from file "
                << dataFile_ << "." << endl
                << exit(FatalError);
        }
    }