BUG: distributedTriSurfaceMesh: handle zero sized local surfaces

This commit is contained in:
mattijs
2013-05-16 11:17:54 +01:00
parent 0bf5772998
commit fe32d73d5a
5 changed files with 99 additions and 61 deletions

View File

@ -433,7 +433,10 @@ Foam::triSurfaceMesh::edgeTree() const
+ nInternalEdges() + nInternalEdges()
); );
treeBoundBox bb; treeBoundBox bb(vector::zero, vector::zero);
if (bEdges.size())
{
label nPoints; label nPoints;
PatchTools::calcBounds PatchTools::calcBounds
( (
@ -451,6 +454,7 @@ Foam::triSurfaceMesh::edgeTree() const
bb = bb.extend(rndGen, 1e-4); bb = bb.extend(rndGen, 1e-4);
bb.min() -= point(ROOTVSMALL, ROOTVSMALL, ROOTVSMALL); bb.min() -= point(ROOTVSMALL, ROOTVSMALL, ROOTVSMALL);
bb.max() += point(ROOTVSMALL, ROOTVSMALL, ROOTVSMALL); bb.max() += point(ROOTVSMALL, ROOTVSMALL, ROOTVSMALL);
}
scalar oldTol = indexedOctree<treeDataEdge>::perturbTol(); scalar oldTol = indexedOctree<treeDataEdge>::perturbTol();
indexedOctree<treeDataEdge>::perturbTol() = tolerance(); indexedOctree<treeDataEdge>::perturbTol() = tolerance();

View File

@ -121,7 +121,10 @@ Foam::triSurfaceRegionSearch::treeByRegion() const
); );
// Calculate bb without constructing local point numbering. // Calculate bb without constructing local point numbering.
treeBoundBox bb; treeBoundBox bb(vector::zero, vector::zero);
if (indirectRegionPatches_[regionI].size())
{
label nPoints; label nPoints;
PatchTools::calcBounds PatchTools::calcBounds
( (
@ -136,18 +139,22 @@ Foam::triSurfaceRegionSearch::treeByRegion() const
// << "Surface does not have compact point numbering. " // << "Surface does not have compact point numbering. "
// << "Of " << surface().points().size() // << "Of " << surface().points().size()
// << " only " << nPoints // << " only " << nPoints
// << " are used. This might give problems in some routines." // << " are used."
// << " This might give problems in some routines."
// << endl; // << endl;
// } // }
// Random number generator. Bit dodgy since not exactly random ;-) // Random number generator. Bit dodgy since not exactly
// random ;-)
Random rndGen(65431); Random rndGen(65431);
// Slightly extended bb. Slightly off-centred just so on symmetric // Slightly extended bb. Slightly off-centred just so
// geometry there are fewer face/edge aligned items. // on symmetric geometry there are fewer face/edge
// aligned items.
bb = bb.extend(rndGen, 1e-4); bb = bb.extend(rndGen, 1e-4);
bb.min() -= point(ROOTVSMALL, ROOTVSMALL, ROOTVSMALL); bb.min() -= point(ROOTVSMALL, ROOTVSMALL, ROOTVSMALL);
bb.max() += point(ROOTVSMALL, ROOTVSMALL, ROOTVSMALL); bb.max() += point(ROOTVSMALL, ROOTVSMALL, ROOTVSMALL);
}
treeByRegion_.set treeByRegion_.set
( (

View File

@ -200,7 +200,10 @@ Foam::triSurfaceSearch::tree() const
if (treePtr_.empty()) if (treePtr_.empty())
{ {
// Calculate bb without constructing local point numbering. // Calculate bb without constructing local point numbering.
treeBoundBox bb; treeBoundBox bb(vector::zero, vector::zero);
if (surface().size())
{
label nPoints; label nPoints;
PatchTools::calcBounds(surface(), bb, nPoints); PatchTools::calcBounds(surface(), bb, nPoints);
@ -208,7 +211,8 @@ Foam::triSurfaceSearch::tree() const
{ {
WarningIn("triSurfaceSearch::tree() const") WarningIn("triSurfaceSearch::tree() const")
<< "Surface does not have compact point numbering." << "Surface does not have compact point numbering."
<< " Of " << surface().points().size() << " only " << nPoints << " Of " << surface().points().size()
<< " only " << nPoints
<< " are used. This might give problems in some routines." << " are used. This might give problems in some routines."
<< endl; << endl;
} }
@ -221,6 +225,7 @@ Foam::triSurfaceSearch::tree() const
bb = bb.extend(rndGen, 1e-4); bb = bb.extend(rndGen, 1e-4);
bb.min() -= point(ROOTVSMALL, ROOTVSMALL, ROOTVSMALL); bb.min() -= point(ROOTVSMALL, ROOTVSMALL, ROOTVSMALL);
bb.max() += point(ROOTVSMALL, ROOTVSMALL, ROOTVSMALL); bb.max() += point(ROOTVSMALL, ROOTVSMALL, ROOTVSMALL);
}
scalar oldTol = indexedOctree<treeDataTriSurface>::perturbTol(); scalar oldTol = indexedOctree<treeDataTriSurface>::perturbTol();
indexedOctree<treeDataTriSurface>::perturbTol() = tolerance_; indexedOctree<treeDataTriSurface>::perturbTol() = tolerance_;

View File

@ -2360,10 +2360,28 @@ bool Foam::distributedTriSurfaceMesh::writeObject
// Make sure dictionary goes to same directory as surface // Make sure dictionary goes to same directory as surface
const_cast<fileName&>(dict_.instance()) = searchableSurface::instance(); const_cast<fileName&>(dict_.instance()) = searchableSurface::instance();
// Copy of triSurfaceMesh::writeObject except for the sorting of
// triangles by region. This is done so we preserve region names,
// even if locally we have zero triangles.
{
fileName fullPath(searchableSurface::objectPath());
if (!mkDir(fullPath.path()))
{
return false;
}
// Important: preserve any zero-sized patches
triSurface::write(fullPath, true);
if (!isFile(fullPath))
{
return false;
}
}
// Dictionary needs to be written in ascii - binary output not supported. // Dictionary needs to be written in ascii - binary output not supported.
return return dict_.writeObject(IOstream::ASCII, ver, cmp);
triSurfaceMesh::writeObject(fmt, ver, cmp)
&& dict_.writeObject(IOstream::ASCII, ver, cmp);
} }

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -446,6 +446,10 @@ public:
// regIOobject implementation // regIOobject implementation
//- Write using given format, version and compression //- Write using given format, version and compression
// Do not use the triSurfaceMesh::writeObject since it
// would filter out empty regions. These need to be preserved
// in case we want to make decisions based on the number of
// regions.
virtual bool writeObject virtual bool writeObject
( (
IOstream::streamFormat fmt, IOstream::streamFormat fmt,