void Foam::setAndNormalToFaceZone::applyToSet
(
    const topoSetSource::setAction action,
    topoSet& set
) const
{
    if (!isA<faceZoneSet>(set))
    {
        WarningInFunction
            << "Operation only allowed on a faceZoneSet." << endl;
    }
    else
    {
        faceZoneSet& fzSet = refCast<faceZoneSet>(set);

        if ((action == topoSetSource::NEW) || (action == topoSetSource::ADD))
        {
            Info<< "    Adding all faces from faceSet " << setName_
                << " ..." << endl;

            // Load the sets
            faceSet fSet(mesh_, setName_);

            // Start off from copy
            DynamicList<label> newAddressing(fzSet.addressing());
            DynamicList<bool> newFlipMap(fzSet.flipMap());

            const faceList& faces = mesh_.faces();
            const pointField& points = mesh_.points();

            forAllConstIter(faceSet, fSet, iter)
            {
                label faceI = iter.key();

                if (!fzSet.found(faceI))
                {
                    newAddressing.append(faceI);

                    vector n = faces[faceI].normal(points);
                    if ((n & normal_) > 0)
                    {
                        newFlipMap.append(false);
                    }
                    else
                    {
                        newFlipMap.append(true);
                    }
                }
            }

            fzSet.addressing().transfer(newAddressing);
            fzSet.flipMap().transfer(newFlipMap);
            fzSet.updateSet();
        }
Exemple #2
0
void Foam::setsToFaceZone::applyToSet
(
    const topoSetSource::setAction action,
    topoSet& set
) const
{
    if (!isA<faceZoneSet>(set))
    {
        WarningIn
        (
            "setsToFaceZone::applyToSet(const topoSetSource::setAction"
            ", topoSet"
        )   << "Operation only allowed on a faceZoneSet." << endl;
    }
    else
    {
        faceZoneSet& fzSet = refCast<faceZoneSet>(set);

        if ((action == topoSetSource::NEW) || (action == topoSetSource::ADD))
        {
            Info<< "    Adding all faces from faceSet " << faceSetName_
                << " ..." << endl;

            // Load the sets
            faceSet fSet(mesh_, faceSetName_);
            cellSet cSet(mesh_, cellSetName_);

            // Start off from copy
            DynamicList<label> newAddressing(fzSet.addressing());
            DynamicList<bool> newFlipMap(fzSet.flipMap());

            forAllConstIter(faceSet, fSet, iter)
            {
                label faceI = iter.key();

                if (!fzSet.found(faceI))
                {
                    bool flip = false;

                    label own = mesh_.faceOwner()[faceI];
                    bool ownFound = cSet.found(own);

                    if (mesh_.isInternalFace(faceI))
                    {
                        label nei = mesh_.faceNeighbour()[faceI];
                        bool neiFound = cSet.found(nei);

                        if (ownFound && !neiFound)
                        {
                            flip = false;
                        }
                        else if (!ownFound && neiFound)
                        {
                            flip = true;
                        }
                        else
                        {
                            WarningIn
                            (
                                "setsToFaceZone::applyToSet"
                                "(const topoSetSource::setAction, topoSet)"
                            )   << "One of owner or neighbour of internal face "
                                << faceI << " should be in cellSet "
                                << cSet.name()
                                << " to be able to determine orientation."
                                << endl
                                << "Face:" << faceI << " own:" << own
                                << " OwnInCellSet:" << ownFound
                                << " nei:" << nei
                                << " NeiInCellSet:" << neiFound
                                << endl;
                        }
                    }
                    else
                    {
                        flip = !ownFound;
                    }

                    newAddressing.append(faceI);
                    newFlipMap.append(flip);
                }
            }

            fzSet.addressing().transfer(newAddressing);
            fzSet.flipMap().transfer(newFlipMap);
            fzSet.updateSet();
        }