mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
BUG: distributedTriSurfaceMesh: handle zero sized local surfaces
This commit is contained in:
@ -433,24 +433,28 @@ Foam::triSurfaceMesh::edgeTree() const
|
|||||||
+ nInternalEdges()
|
+ nInternalEdges()
|
||||||
);
|
);
|
||||||
|
|
||||||
treeBoundBox bb;
|
treeBoundBox bb(vector::zero, vector::zero);
|
||||||
label nPoints;
|
|
||||||
PatchTools::calcBounds
|
|
||||||
(
|
|
||||||
static_cast<const triSurface&>(*this),
|
|
||||||
bb,
|
|
||||||
nPoints
|
|
||||||
);
|
|
||||||
|
|
||||||
// Random number generator. Bit dodgy since not exactly random ;-)
|
if (bEdges.size())
|
||||||
Random rndGen(65431);
|
{
|
||||||
|
label nPoints;
|
||||||
|
PatchTools::calcBounds
|
||||||
|
(
|
||||||
|
static_cast<const triSurface&>(*this),
|
||||||
|
bb,
|
||||||
|
nPoints
|
||||||
|
);
|
||||||
|
|
||||||
// Slightly extended bb. Slightly off-centred just so on symmetric
|
// Random number generator. Bit dodgy since not exactly random ;-)
|
||||||
// geometry there are less face/edge aligned items.
|
Random rndGen(65431);
|
||||||
|
|
||||||
bb = bb.extend(rndGen, 1e-4);
|
// Slightly extended bb. Slightly off-centred just so on symmetric
|
||||||
bb.min() -= point(ROOTVSMALL, ROOTVSMALL, ROOTVSMALL);
|
// geometry there are less face/edge aligned items.
|
||||||
bb.max() += point(ROOTVSMALL, ROOTVSMALL, ROOTVSMALL);
|
|
||||||
|
bb = bb.extend(rndGen, 1e-4);
|
||||||
|
bb.min() -= 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();
|
||||||
|
|||||||
@ -121,33 +121,40 @@ 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);
|
||||||
label nPoints;
|
|
||||||
PatchTools::calcBounds
|
|
||||||
(
|
|
||||||
indirectRegionPatches_[regionI],
|
|
||||||
bb,
|
|
||||||
nPoints
|
|
||||||
);
|
|
||||||
|
|
||||||
// if (nPoints != surface().points().size())
|
if (indirectRegionPatches_[regionI].size())
|
||||||
// {
|
{
|
||||||
// WarningIn("triSurfaceRegionSearch::treeByRegion() const")
|
label nPoints;
|
||||||
// << "Surface does not have compact point numbering. "
|
PatchTools::calcBounds
|
||||||
// << "Of " << surface().points().size()
|
(
|
||||||
// << " only " << nPoints
|
indirectRegionPatches_[regionI],
|
||||||
// << " are used. This might give problems in some routines."
|
bb,
|
||||||
// << endl;
|
nPoints
|
||||||
// }
|
);
|
||||||
|
|
||||||
// Random number generator. Bit dodgy since not exactly random ;-)
|
// if (nPoints != surface().points().size())
|
||||||
Random rndGen(65431);
|
// {
|
||||||
|
// WarningIn("triSurfaceRegionSearch::treeByRegion() const")
|
||||||
|
// << "Surface does not have compact point numbering. "
|
||||||
|
// << "Of " << surface().points().size()
|
||||||
|
// << " only " << nPoints
|
||||||
|
// << " are used."
|
||||||
|
// << " This might give problems in some routines."
|
||||||
|
// << endl;
|
||||||
|
// }
|
||||||
|
|
||||||
// Slightly extended bb. Slightly off-centred just so on symmetric
|
// Random number generator. Bit dodgy since not exactly
|
||||||
// geometry there are fewer face/edge aligned items.
|
// random ;-)
|
||||||
bb = bb.extend(rndGen, 1e-4);
|
Random rndGen(65431);
|
||||||
bb.min() -= point(ROOTVSMALL, ROOTVSMALL, ROOTVSMALL);
|
|
||||||
bb.max() += point(ROOTVSMALL, ROOTVSMALL, ROOTVSMALL);
|
// Slightly extended bb. Slightly off-centred just so
|
||||||
|
// on symmetric geometry there are fewer face/edge
|
||||||
|
// aligned items.
|
||||||
|
bb = bb.extend(rndGen, 1e-4);
|
||||||
|
bb.min() -= point(ROOTVSMALL, ROOTVSMALL, ROOTVSMALL);
|
||||||
|
bb.max() += point(ROOTVSMALL, ROOTVSMALL, ROOTVSMALL);
|
||||||
|
}
|
||||||
|
|
||||||
treeByRegion_.set
|
treeByRegion_.set
|
||||||
(
|
(
|
||||||
|
|||||||
@ -200,28 +200,33 @@ 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);
|
||||||
label nPoints;
|
|
||||||
PatchTools::calcBounds(surface(), bb, nPoints);
|
|
||||||
|
|
||||||
if (nPoints != surface().points().size())
|
if (surface().size())
|
||||||
{
|
{
|
||||||
WarningIn("triSurfaceSearch::tree() const")
|
label nPoints;
|
||||||
<< "Surface does not have compact point numbering."
|
PatchTools::calcBounds(surface(), bb, nPoints);
|
||||||
<< " Of " << surface().points().size() << " only " << nPoints
|
|
||||||
<< " are used. This might give problems in some routines."
|
if (nPoints != surface().points().size())
|
||||||
<< endl;
|
{
|
||||||
|
WarningIn("triSurfaceSearch::tree() const")
|
||||||
|
<< "Surface does not have compact point numbering."
|
||||||
|
<< " Of " << surface().points().size()
|
||||||
|
<< " only " << nPoints
|
||||||
|
<< " are used. This might give problems in some routines."
|
||||||
|
<< endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Random number generator. Bit dodgy since not exactly random ;-)
|
||||||
|
Random rndGen(65431);
|
||||||
|
|
||||||
|
// Slightly extended bb. Slightly off-centred just so on symmetric
|
||||||
|
// geometry there are less face/edge aligned items.
|
||||||
|
bb = bb.extend(rndGen, 1e-4);
|
||||||
|
bb.min() -= point(ROOTVSMALL, ROOTVSMALL, ROOTVSMALL);
|
||||||
|
bb.max() += point(ROOTVSMALL, ROOTVSMALL, ROOTVSMALL);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Random number generator. Bit dodgy since not exactly random ;-)
|
|
||||||
Random rndGen(65431);
|
|
||||||
|
|
||||||
// Slightly extended bb. Slightly off-centred just so on symmetric
|
|
||||||
// geometry there are less face/edge aligned items.
|
|
||||||
bb = bb.extend(rndGen, 1e-4);
|
|
||||||
bb.min() -= 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_;
|
||||||
|
|
||||||
|
|||||||
@ -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);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -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,
|
||||||
|
|||||||
Reference in New Issue
Block a user