const triSurf* triSurfacePatchManipulator::surfaceWithPatches
(
    IOdictionary* meshDictPtr,
    const word prefix,
    const bool forceOverwrite
) const
{
    //- collect patch information
    VRWGraph facetsInPatch;
    detectedSurfaceRegions(facetsInPatch);

    //- create new list of boundary patches
    LongList<labelledTri> newTriangles(facetInPatch_.size());
    label counter(0);
    geometricSurfacePatchList newPatches(nPatches_);

    if( forceOverwrite )
    {
        forAll(newPatches, patchI)
        {
            newPatches[patchI].name() = prefix+help::scalarToText(patchI);
            newPatches[patchI].geometricType() = "patch";
            newPatches[patchI].index() = patchI;
        }
    }
Ejemplo n.º 2
0
//- Attach mesh
void Foam::attachPolyTopoChanger::attach(const bool removeEmptyPatches)
{
    if (debug)
    {
        Pout<< "void attachPolyTopoChanger::attach(): "
            << "Attaching mesh" << endl;
    }

    // Save current file instance
    const fileName oldInst = mesh_.facesInstance();

    // Execute all polyMeshModifiers
    changeMesh(false);  // no inflation

    const pointField p = mesh_.oldPoints();

    mesh_.movePoints(p);

    if (debug)
    {
        Pout << "Clearing mesh." << endl;
    }

    if (removeEmptyPatches)
    {
        // Re-do the boundary patches, removing the ones with zero size
        const polyBoundaryMesh& oldPatches = mesh_.boundaryMesh();

        List<polyPatch*> newPatches(oldPatches.size());
        label nNewPatches = 0;

        forAll (oldPatches, patchI)
        {
            if (oldPatches[patchI].size())
            {
                newPatches[nNewPatches] = oldPatches[patchI].clone
                (
                    mesh_.boundaryMesh(),
                    nNewPatches,
                    oldPatches[patchI].size(),
                    oldPatches[patchI].start()
                ).ptr();

                nNewPatches++;
            }
            else
            {
                if (debug)
                {
                    Pout<< "Removing zero-sized patch " << patchI
                        << " named " << oldPatches[patchI].name() << endl;
                }
            }
        }

        newPatches.setSize(nNewPatches);

        mesh_.removeBoundary();
        mesh_.addPatches(newPatches);
    }

    // Reset the file instance to overwrite the original mesh
    mesh_.setInstance(oldInst);

    if (debug)
    {
        Pout<< "void attachPolyTopoChanger::attach(): "
            << "Finished attaching mesh" << endl;
    }

    mesh_.checkMesh();
}