Beispiel #1
0
// Get faceEdges in order of face points, i.e. faceEdges[0] is between
// f[0] and f[1]
labelList getSortedEdges
(
    const edgeList& edges,
    const labelList& f,
    const labelList& edgeLabels
)
{
    labelList faceEdges(edgeLabels.size(), -1);

    // Find starting pos in f for every edgeLabels
    forAll(edgeLabels, i)
    {
        label edgeI = edgeLabels[i];

        const edge& e = edges[edgeI];

        label fp = findIndex(f, e[0]);
        label fp1 = f.fcIndex(fp);

        if (f[fp1] == e[1])
        {
            // EdgeI between fp -> fp1
            faceEdges[fp] = edgeI;
        }
        else
        {
            // EdgeI between fp-1 -> fp
            faceEdges[f.rcIndex(fp)] = edgeI;
        }
    }
Beispiel #2
0
// Return true if the cut edge at loop[index] is preceded by cuts through
// the edge end points.
bool Foam::geomCellLooper::edgeEndsCut
(
    const labelList& loop,
    const label index
) const
{
    label edgeI = getEdge(loop[index]);

    const edge& e = mesh().edges()[edgeI];

    const label prevCut = loop[loop.rcIndex(index)];
    const label nextCut = loop[loop.fcIndex(index)];

    if (!isEdge(prevCut) && !isEdge(nextCut))
    {
        // Cuts before and after are both vertices. Check if both
        // the edge endpoints
        label v0 = getVertex(prevCut);
        label v1 = getVertex(nextCut);

        if
        (
            (v0 == e[0] && v1 == e[1])
         || (v0 == e[1] && v1 == e[0])
        )
        {
            return true;
        }
    }
    return false;
}
Foam::label Foam::isoCutFace::calcSubFace
(
    const scalar isoValue,
    const pointField& points,
    const scalarField& f,
    const labelList& pLabels
)
{
    // Face status set to one of the values:
    //  -1: face is fully below the isosurface
    //   0: face is cut, i.e. has values larger and smaller than isoValue
    //  +1: face is fully above the isosurface
    label faceStatus;

    scalar f1 = f[pLabels[0]];

    // If vertex values are very close to isoValue lift them slightly to avoid
    // dealing with the many special cases of a face being touched either at a
    // single point, along an edge, or the entire face being on the surface.
    if (mag(f1 - isoValue) < 10*SMALL)
    {
        f1 += sign(f1 - isoValue)*10*SMALL;
    }

    // Finding cut edges, the point along them where they are cut, and all fully
    // submerged face points.
    forAll(pLabels, pi)
    {
        label pl2 = pLabels[pLabels.fcIndex(pi)];
        scalar f2 = f[pl2];
        if (mag(f2 - isoValue) < 10*SMALL)
        {
            f2 += sign(f2 - isoValue)*10*SMALL;
        }

        if (f1 > isoValue)
        {
            nFullySubmergedPoints_ += 1;

            if (f2 < isoValue)
            {
                lastEdgeCut_ = (isoValue - f1)/(f2 - f1);
            }
        }
        else if (f1 < isoValue && f2 > isoValue)
        {
            if (firstFullySubmergedPoint_ == -1)
            {
                firstFullySubmergedPoint_ = pLabels.fcIndex(pi);

                firstEdgeCut_ = (isoValue - f1)/(f2 - f1);
            }
            else
            {
                if (debug)
                {
                    const face fl(pLabels);

                    WarningInFunction
                        << "More than two face cuts for face " << fl
                        << endl;

                    Pout<< "Face values: f-isoValue = " << endl;
                    forAll(fl, fpi)
                    {
                        Pout<< f[fl[fpi]] - isoValue << " ";
                    }
                    Pout<< " " << endl;
                }
            }
        }