ENH: pointInCell, findCell: switchable in-cell algorithm

This commit is contained in:
mattijs
2011-10-28 11:33:30 +01:00
parent 6b44617c68
commit ee11f9c0e8
45 changed files with 496 additions and 268 deletions

View File

@ -715,7 +715,7 @@ int main(int argc, char *argv[])
triSurfaceSearch querySurf(surf); triSurfaceSearch querySurf(surf);
// Search engine on mesh. No face decomposition since mesh unwarped. // Search engine on mesh. No face decomposition since mesh unwarped.
meshSearch queryMesh(mesh, false); meshSearch queryMesh(mesh, polyMesh::FACEPLANES);
// Check all 'outside' points // Check all 'outside' points
forAll(outsidePts, outsideI) forAll(outsidePts, outsideI)

View File

@ -381,7 +381,7 @@ int main(int argc, char *argv[])
(void)edgeCalc.minLen(Info); (void)edgeCalc.minLen(Info);
// Search engine on mesh. Face decomposition since faces might be warped. // Search engine on mesh. Face decomposition since faces might be warped.
meshSearch queryMesh(mesh, true); meshSearch queryMesh(mesh, polyMesh::FACEDIAGTETS);
// Check all 'outside' points // Check all 'outside' points
forAll(outsidePts, outsideI) forAll(outsidePts, outsideI)

View File

@ -971,7 +971,7 @@ Foam::backgroundMeshDecomposition::distribute
{ {
// Map cellVertices, cellVertexIndices and cellVertexTypes // Map cellVertices, cellVertexIndices and cellVertexTypes
meshSearch cellSearch(mesh_); meshSearch cellSearch(mesh_, polyMesh::FACEPLANES);
const labelList& reverseCellMap = map().reverseCellMap(); const labelList& reverseCellMap = map().reverseCellMap();

View File

@ -1405,7 +1405,7 @@ bool Foam::conformalVoronoiMesh::distributeBackground()
zeroGradientFvPatchScalarField::typeName zeroGradientFvPatchScalarField::typeName
); );
meshSearch cellSearch(bMesh); meshSearch cellSearch(bMesh, polyMesh::FACEPLANES);
List<DynamicList<Foam::point> > cellVertices(bMesh.nCells()); List<DynamicList<Foam::point> > cellVertices(bMesh.nCells());
List<DynamicList<label> > cellVertexIndices(bMesh.nCells()); List<DynamicList<label> > cellVertexIndices(bMesh.nCells());

View File

@ -2194,7 +2194,7 @@ int main(int argc, char *argv[])
label regionI = -1; label regionI = -1;
label cellI = mesh.findCell(insidePoint); label cellI = mesh.findCell(insidePoint, polyMesh::FACEDIAGTETS);
Info<< nl << "Found point " << insidePoint << " in cell " << cellI Info<< nl << "Found point " << insidePoint << " in cell " << cellI
<< endl; << endl;

View File

@ -528,7 +528,11 @@ int main(int argc, char *argv[])
<< "Cell number should be between 0 and " << "Cell number should be between 0 and "
<< mesh.nCells()-1 << nl << mesh.nCells()-1 << nl
<< "On this mesh the particle should be in cell " << "On this mesh the particle should be in cell "
<< mesh.findCell(iter().position()) << mesh.findCell
(
iter().position(),
polyMesh::FACEDIAGTETS
)
<< exit(FatalError); << exit(FatalError);
} }

View File

@ -56,7 +56,11 @@ static label findCell(const Cloud<passiveParticle>& cloud, const point& pt)
// See if particle on face by finding nearest face and shifting // See if particle on face by finding nearest face and shifting
// particle. // particle.
meshSearch meshSearcher(mesh, false); meshSearch meshSearcher
(
mesh,
polyMesh::FACEPLANES // no decomposition needed
);
label faceI = meshSearcher.findNearestBoundaryFace(pt); label faceI = meshSearcher.findNearestBoundaryFace(pt);

View File

@ -25,7 +25,7 @@ License
#include "treeDataCell.H" #include "treeDataCell.H"
#include "indexedOctree.H" #include "indexedOctree.H"
#include "primitiveMesh.H" #include "polyMesh.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
@ -83,13 +83,15 @@ void Foam::treeDataCell::update()
Foam::treeDataCell::treeDataCell Foam::treeDataCell::treeDataCell
( (
const bool cacheBb, const bool cacheBb,
const primitiveMesh& mesh, const polyMesh& mesh,
const labelUList& cellLabels const labelUList& cellLabels,
const polyMesh::cellRepresentation decompMode
) )
: :
mesh_(mesh), mesh_(mesh),
cellLabels_(cellLabels), cellLabels_(cellLabels),
cacheBb_(cacheBb) cacheBb_(cacheBb),
decompMode_(decompMode)
{ {
update(); update();
} }
@ -98,13 +100,15 @@ Foam::treeDataCell::treeDataCell
Foam::treeDataCell::treeDataCell Foam::treeDataCell::treeDataCell
( (
const bool cacheBb, const bool cacheBb,
const primitiveMesh& mesh, const polyMesh& mesh,
const Xfer<labelList>& cellLabels const Xfer<labelList>& cellLabels,
const polyMesh::cellRepresentation decompMode
) )
: :
mesh_(mesh), mesh_(mesh),
cellLabels_(cellLabels), cellLabels_(cellLabels),
cacheBb_(cacheBb) cacheBb_(cacheBb),
decompMode_(decompMode)
{ {
update(); update();
} }
@ -113,12 +117,14 @@ Foam::treeDataCell::treeDataCell
Foam::treeDataCell::treeDataCell Foam::treeDataCell::treeDataCell
( (
const bool cacheBb, const bool cacheBb,
const primitiveMesh& mesh const polyMesh& mesh,
const polyMesh::cellRepresentation decompMode
) )
: :
mesh_(mesh), mesh_(mesh),
cellLabels_(identity(mesh_.nCells())), cellLabels_(identity(mesh_.nCells())),
cacheBb_(cacheBb) cacheBb_(cacheBb),
decompMode_(decompMode)
{ {
update(); update();
} }
@ -162,7 +168,7 @@ bool Foam::treeDataCell::contains
const point& sample const point& sample
) const ) const
{ {
return mesh_.pointInCell(sample, cellLabels_[index]); return mesh_.pointInCell(sample, cellLabels_[index], decompMode_);
} }

View File

@ -36,6 +36,7 @@ SourceFiles
#ifndef treeDataCell_H #ifndef treeDataCell_H
#define treeDataCell_H #define treeDataCell_H
#include "polyMesh.H"
#include "treeBoundBoxList.H" #include "treeBoundBoxList.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -44,7 +45,6 @@ namespace Foam
{ {
// Forward declaration of classes // Forward declaration of classes
class primitiveMesh;
template<class Type> class indexedOctree; template<class Type> class indexedOctree;
/*---------------------------------------------------------------------------*\ /*---------------------------------------------------------------------------*\
@ -55,7 +55,7 @@ class treeDataCell
{ {
// Private data // Private data
const primitiveMesh& mesh_; const polyMesh& mesh_;
//- Subset of cells to work on //- Subset of cells to work on
const labelList cellLabels_; const labelList cellLabels_;
@ -63,6 +63,9 @@ class treeDataCell
//- Whether to precalculate and store cell bounding box //- Whether to precalculate and store cell bounding box
const bool cacheBb_; const bool cacheBb_;
//- How to decide if point is inside cell
const polyMesh::cellRepresentation decompMode_;
//- cell bounding boxes (valid only if cacheBb_) //- cell bounding boxes (valid only if cacheBb_)
treeBoundBoxList bbs_; treeBoundBoxList bbs_;
@ -87,20 +90,27 @@ public:
treeDataCell treeDataCell
( (
const bool cacheBb, const bool cacheBb,
const primitiveMesh&, const polyMesh&,
const labelUList& const labelUList&,
const polyMesh::cellRepresentation decompMode
); );
//- Construct from mesh and subset of cells, transferring contents //- Construct from mesh and subset of cells, transferring contents
treeDataCell treeDataCell
( (
const bool cacheBb, const bool cacheBb,
const primitiveMesh&, const polyMesh&,
const Xfer<labelList>& const Xfer<labelList>&,
const polyMesh::cellRepresentation decompMode
); );
//- Construct from mesh. Uses all cells in mesh. //- Construct from mesh. Uses all cells in mesh.
treeDataCell(const bool cacheBb, const primitiveMesh&); treeDataCell
(
const bool cacheBb,
const polyMesh&,
const polyMesh::cellRepresentation decompMode
);
// Member Functions // Member Functions
@ -112,11 +122,15 @@ public:
return cellLabels_; return cellLabels_;
} }
inline const primitiveMesh& mesh() const inline const polyMesh& mesh() const
{ {
return mesh_; return mesh_;
} }
inline polyMesh::cellRepresentation decompMode() const
{
return decompMode_;
}
inline label size() const inline label size() const
{ {

View File

@ -32,7 +32,6 @@ License
#include "globalMeshData.H" #include "globalMeshData.H"
#include "processorPolyPatch.H" #include "processorPolyPatch.H"
#include "OSspecific.H" #include "OSspecific.H"
#include "demandDrivenData.H"
#include "polyMeshTetDecomposition.H" #include "polyMeshTetDecomposition.H"
#include "indexedOctree.H" #include "indexedOctree.H"
#include "treeDataCell.H" #include "treeDataCell.H"
@ -209,6 +208,7 @@ Foam::polyMesh::polyMesh(const IOobject& io)
geometricD_(Vector<label>::zero), geometricD_(Vector<label>::zero),
solutionD_(Vector<label>::zero), solutionD_(Vector<label>::zero),
tetBasePtIsPtr_(NULL), tetBasePtIsPtr_(NULL),
cellTreePtr_(NULL),
pointZones_ pointZones_
( (
IOobject IOobject
@ -401,6 +401,7 @@ Foam::polyMesh::polyMesh
geometricD_(Vector<label>::zero), geometricD_(Vector<label>::zero),
solutionD_(Vector<label>::zero), solutionD_(Vector<label>::zero),
tetBasePtIsPtr_(NULL), tetBasePtIsPtr_(NULL),
cellTreePtr_(NULL),
pointZones_ pointZones_
( (
IOobject IOobject
@ -558,6 +559,7 @@ Foam::polyMesh::polyMesh
geometricD_(Vector<label>::zero), geometricD_(Vector<label>::zero),
solutionD_(Vector<label>::zero), solutionD_(Vector<label>::zero),
tetBasePtIsPtr_(NULL), tetBasePtIsPtr_(NULL),
cellTreePtr_(NULL),
pointZones_ pointZones_
( (
IOobject IOobject
@ -859,7 +861,7 @@ Foam::label Foam::polyMesh::nSolutionD() const
const Foam::labelList& Foam::polyMesh::tetBasePtIs() const const Foam::labelList& Foam::polyMesh::tetBasePtIs() const
{ {
if (!tetBasePtIsPtr_) if (tetBasePtIsPtr_.empty())
{ {
if (debug) if (debug)
{ {
@ -869,13 +871,51 @@ const Foam::labelList& Foam::polyMesh::tetBasePtIs() const
<< endl; << endl;
} }
tetBasePtIsPtr_ = new labelList tetBasePtIsPtr_.reset
(
new labelList
( (
polyMeshTetDecomposition::findFaceBasePts(*this) polyMeshTetDecomposition::findFaceBasePts(*this)
)
); );
} }
return *tetBasePtIsPtr_; return tetBasePtIsPtr_();
}
const Foam::indexedOctree<Foam::treeDataCell>&
Foam::polyMesh::cellTree() const
{
if (cellTreePtr_.empty())
{
treeBoundBox overallBb(points());
Random rndGen(261782);
overallBb = overallBb.extend(rndGen, 1E-4);
overallBb.min() -= point(ROOTVSMALL, ROOTVSMALL, ROOTVSMALL);
overallBb.max() += point(ROOTVSMALL, ROOTVSMALL, ROOTVSMALL);
cellTreePtr_.reset
(
new indexedOctree<treeDataCell>
(
treeDataCell
(
false, // not cache bb
*this,
FACEDIAGTETS // use tetDecomposition for any inside test
),
overallBb,
8, // maxLevel
10, // leafsize
5.0 // duplicity
)
);
}
return cellTreePtr_();
} }
@ -911,7 +951,7 @@ void Foam::polyMesh::addPatches
// recalculation. Problem: should really be done in removeBoundary but // recalculation. Problem: should really be done in removeBoundary but
// there is some info in parallelData which might be interesting inbetween // there is some info in parallelData which might be interesting inbetween
// removeBoundary and addPatches. // removeBoundary and addPatches.
deleteDemandDrivenData(globalMeshDataPtr_); globalMeshDataPtr_.clear();
if (validBoundary) if (validBoundary)
{ {
@ -1033,7 +1073,7 @@ const Foam::labelList& Foam::polyMesh::faceNeighbour() const
// Return old mesh motion points // Return old mesh motion points
const Foam::pointField& Foam::polyMesh::oldPoints() const const Foam::pointField& Foam::polyMesh::oldPoints() const
{ {
if (!oldPointsPtr_) if (oldPointsPtr_.empty())
{ {
if (debug) if (debug)
{ {
@ -1042,11 +1082,11 @@ const Foam::pointField& Foam::polyMesh::oldPoints() const
<< endl; << endl;
} }
oldPointsPtr_ = new pointField(points_); oldPointsPtr_.reset(new pointField(points_));
curMotionTimeIndex_ = time().timeIndex(); curMotionTimeIndex_ = time().timeIndex();
} }
return *oldPointsPtr_; return oldPointsPtr_();
} }
@ -1068,8 +1108,8 @@ Foam::tmp<Foam::scalarField> Foam::polyMesh::movePoints
if (curMotionTimeIndex_ != time().timeIndex()) if (curMotionTimeIndex_ != time().timeIndex())
{ {
// Mesh motion in the new time step // Mesh motion in the new time step
deleteDemandDrivenData(oldPointsPtr_); oldPointsPtr_.clear();
oldPointsPtr_ = new pointField(points_); oldPointsPtr_.reset(new pointField(points_));
curMotionTimeIndex_ = time().timeIndex(); curMotionTimeIndex_ = time().timeIndex();
} }
@ -1099,9 +1139,9 @@ Foam::tmp<Foam::scalarField> Foam::polyMesh::movePoints
); );
// Adjust parallel shared points // Adjust parallel shared points
if (globalMeshDataPtr_) if (globalMeshDataPtr_.valid())
{ {
globalMeshDataPtr_->movePoints(points_); globalMeshDataPtr_().movePoints(points_);
} }
// Force recalculation of all geometric data with new points // Force recalculation of all geometric data with new points
@ -1141,14 +1181,14 @@ Foam::tmp<Foam::scalarField> Foam::polyMesh::movePoints
void Foam::polyMesh::resetMotion() const void Foam::polyMesh::resetMotion() const
{ {
curMotionTimeIndex_ = 0; curMotionTimeIndex_ = 0;
deleteDemandDrivenData(oldPointsPtr_); oldPointsPtr_.clear();
} }
// Return parallel info // Return parallel info
const Foam::globalMeshData& Foam::polyMesh::globalData() const const Foam::globalMeshData& Foam::polyMesh::globalData() const
{ {
if (!globalMeshDataPtr_) if (globalMeshDataPtr_.empty())
{ {
if (debug) if (debug)
{ {
@ -1158,10 +1198,10 @@ const Foam::globalMeshData& Foam::polyMesh::globalData() const
<< endl; << endl;
} }
// Construct globalMeshData using processorPatch information only. // Construct globalMeshData using processorPatch information only.
globalMeshDataPtr_ = new globalMeshData(*this); globalMeshDataPtr_.reset(new globalMeshData(*this));
} }
return *globalMeshDataPtr_; return globalMeshDataPtr_();
} }
@ -1308,4 +1348,111 @@ void Foam::polyMesh::findTetFacePt
} }
bool Foam::polyMesh::pointInCell
(
const point& p,
label cellI,
const cellRepresentation decompMode
) const
{
switch (decompMode)
{
case FACEPLANES:
{
return primitiveMesh::pointInCell(p, cellI);
}
break;
case FACECENTRETETS:
{
const point& cc = cellCentres()[cellI];
const cell& cFaces = cells()[cellI];
forAll(cFaces, cFaceI)
{
label faceI = cFaces[cFaceI];
const face& f = faces_[faceI];
const point& fc = faceCentres()[faceI];
bool isOwn = (owner_[faceI] == cellI);
forAll(f, fp)
{
label pointI;
label nextPointI;
if (isOwn)
{
pointI = f[fp];
nextPointI = f.nextLabel(fp);
}
else
{
pointI = f.nextLabel(fp);
nextPointI = f[fp];
}
if
(
tetPointRef
(
points()[nextPointI],
points()[pointI],
fc,
cc
).inside(p)
)
{
return true;
}
}
}
return false;
}
break;
case FACEDIAGTETS:
{
label tetFaceI, tetPtI;
findTetFacePt(cellI, p, tetFaceI, tetPtI);
return tetFaceI != -1;
}
break;
}
return false;
}
Foam::label Foam::polyMesh::findCell
(
const point& location,
const cellRepresentation decompMode
) const
{
if (nCells() == 0)
{
return -1;
}
// Find the nearest cell centre to this location
label cellI = findNearestCell(location);
// If point is in the nearest cell return
if (pointInCell(location, cellI, decompMode))
{
return cellI;
}
else // point is not in the nearest cell so search all cells
{
for (label cellI = 0; cellI < nCells(); cellI++)
{
if (pointInCell(location, cellI, decompMode))
{
return cellI;
}
}
return -1;
}
}
// ************************************************************************* // // ************************************************************************* //

View File

@ -34,7 +34,6 @@ SourceFiles
polyMeshFromShapeMesh.C polyMeshFromShapeMesh.C
polyMeshIO.C polyMeshIO.C
polyMeshUpdate.C polyMeshUpdate.C
polyMeshFindCell.C
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
@ -61,9 +60,12 @@ SourceFiles
namespace Foam namespace Foam
{ {
// Forward declaration of classes
class globalMeshData; class globalMeshData;
class mapPolyMesh; class mapPolyMesh;
class polyMeshTetDecomposition; class polyMeshTetDecomposition;
class treeDataCell;
template<class Type> class indexedOctree;
/*---------------------------------------------------------------------------*\ /*---------------------------------------------------------------------------*\
Class polyMesh Declaration Class polyMesh Declaration
@ -91,6 +93,15 @@ public:
TOPO_PATCH_CHANGE TOPO_PATCH_CHANGE
}; };
//- Enumeration defining the representation of the cell for
// inside checking
enum cellRepresentation
{
FACEPLANES, // cell bound by planes of faces
FACECENTRETETS, // tet decomposition using facectr and cellctr
FACEDIAGTETS // tet decomposition using face diagonal and cellctr
};
private: private:
@ -130,7 +141,10 @@ private:
mutable Vector<label> solutionD_; mutable Vector<label> solutionD_;
//- Base point for face decomposition into tets //- Base point for face decomposition into tets
mutable labelList* tetBasePtIsPtr_; mutable autoPtr<labelList> tetBasePtIsPtr_;
//- Search tree to allow spatial cell searching
mutable autoPtr<indexedOctree<treeDataCell> > cellTreePtr_;
// Zoning information // Zoning information
@ -146,7 +160,7 @@ private:
//- Parallel info //- Parallel info
mutable globalMeshData* globalMeshDataPtr_; mutable autoPtr<globalMeshData> globalMeshDataPtr_;
// Mesh motion related data // Mesh motion related data
@ -161,7 +175,7 @@ private:
mutable label curMotionTimeIndex_; mutable label curMotionTimeIndex_;
//- Old points (for the last mesh motion) //- Old points (for the last mesh motion)
mutable pointField* oldPointsPtr_; mutable autoPtr<pointField> oldPointsPtr_;
// Private Member Functions // Private Member Functions
@ -365,6 +379,9 @@ public:
//- Return the tetBasePtIs //- Return the tetBasePtIs
const labelList& tetBasePtIs() const; const labelList& tetBasePtIs() const;
//- Return the cell search tree
const indexedOctree<treeDataCell>& cellTree() const;
//- Return point zone mesh //- Return point zone mesh
const pointZoneMesh& pointZones() const const pointZoneMesh& pointZones() const
{ {
@ -505,6 +522,9 @@ public:
//- Clear primitive data (points, faces and cells) //- Clear primitive data (points, faces and cells)
void clearPrimitives(); void clearPrimitives();
//- Clear cell tree data
void clearCellTree();
//- Remove all files from mesh instance //- Remove all files from mesh instance
void removeFiles(const fileName& instanceDir) const; void removeFiles(const fileName& instanceDir) const;
@ -532,6 +552,21 @@ public:
label& tetFaceI, label& tetFaceI,
label& tetPtI label& tetPtI
) const; ) const;
//- Is the point in the cell
bool pointInCell
(
const point&,
label cellI,
const cellRepresentation
) const;
//- Find cell enclosing this location (-1 if not in mesh)
label findCell
(
const point&,
const cellRepresentation
) const;
}; };

View File

@ -26,9 +26,10 @@ License
#include "polyMesh.H" #include "polyMesh.H"
#include "primitiveMesh.H" #include "primitiveMesh.H"
#include "globalMeshData.H" #include "globalMeshData.H"
#include "demandDrivenData.H"
#include "pointMesh.H" #include "pointMesh.H"
#include "Time.H" #include "Time.H"
#include "indexedOctree.H"
#include "treeDataCell.H"
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
@ -72,7 +73,9 @@ void Foam::polyMesh::clearGeom()
solutionD_ = Vector<label>::zero; solutionD_ = Vector<label>::zero;
// Remove the stored tet base points // Remove the stored tet base points
deleteDemandDrivenData(tetBasePtIsPtr_); tetBasePtIsPtr_.clear();
// Remove the cell tree
cellTreePtr_.clear();
pointMesh::Delete(*this); pointMesh::Delete(*this);
} }
@ -91,7 +94,7 @@ void Foam::polyMesh::clearAddressing()
// parallelData depends on the processorPatch ordering so force // parallelData depends on the processorPatch ordering so force
// recalculation // recalculation
deleteDemandDrivenData(globalMeshDataPtr_); globalMeshDataPtr_.clear();
// Reset valid directions // Reset valid directions
geometricD_ = Vector<label>::zero; geometricD_ = Vector<label>::zero;
@ -121,4 +124,10 @@ void Foam::polyMesh::clearOut()
} }
void Foam::polyMesh::clearCellTree()
{
cellTreePtr_.clear();
}
// ************************************************************************* // // ************************************************************************* //

View File

@ -30,6 +30,9 @@ Description
#include "Time.H" #include "Time.H"
#include "primitiveMesh.H" #include "primitiveMesh.H"
#include "DynamicList.H" #include "DynamicList.H"
#include "indexedOctree.H"
#include "treeDataCell.H"
#include "globalMeshData.H"
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
@ -504,6 +507,7 @@ Foam::polyMesh::polyMesh
geometricD_(Vector<label>::zero), geometricD_(Vector<label>::zero),
solutionD_(Vector<label>::zero), solutionD_(Vector<label>::zero),
tetBasePtIsPtr_(NULL), tetBasePtIsPtr_(NULL),
cellTreePtr_(NULL),
pointZones_ pointZones_
( (
IOobject IOobject
@ -548,6 +552,7 @@ Foam::polyMesh::polyMesh
), ),
globalMeshDataPtr_(NULL), globalMeshDataPtr_(NULL),
moving_(false), moving_(false),
changing_(false),
curMotionTimeIndex_(time().timeIndex()), curMotionTimeIndex_(time().timeIndex()),
oldPointsPtr_(NULL) oldPointsPtr_(NULL)
{ {
@ -778,6 +783,7 @@ Foam::polyMesh::polyMesh
geometricD_(Vector<label>::zero), geometricD_(Vector<label>::zero),
solutionD_(Vector<label>::zero), solutionD_(Vector<label>::zero),
tetBasePtIsPtr_(NULL), tetBasePtIsPtr_(NULL),
cellTreePtr_(NULL),
pointZones_ pointZones_
( (
IOobject IOobject
@ -822,6 +828,7 @@ Foam::polyMesh::polyMesh
), ),
globalMeshDataPtr_(NULL), globalMeshDataPtr_(NULL),
moving_(false), moving_(false),
changing_(false),
curMotionTimeIndex_(time().timeIndex()), curMotionTimeIndex_(time().timeIndex()),
oldPointsPtr_(NULL) oldPointsPtr_(NULL)
{ {

View File

@ -45,7 +45,7 @@ void Foam::polyMesh::updateMesh(const mapPolyMesh& mpm)
cellZones_.clearAddressing(); cellZones_.clearAddressing();
// Update parallel data // Update parallel data
if (globalMeshDataPtr_) if (globalMeshDataPtr_.valid())
{ {
globalMeshDataPtr_->updateMesh(); globalMeshDataPtr_->updateMesh();
} }
@ -53,12 +53,12 @@ void Foam::polyMesh::updateMesh(const mapPolyMesh& mpm)
setInstance(time().timeName()); setInstance(time().timeName());
// Map the old motion points if present // Map the old motion points if present
if (oldPointsPtr_) if (oldPointsPtr_.valid())
{ {
// Make a copy of the original points // Make a copy of the original points
pointField oldMotionPoints = *oldPointsPtr_; pointField oldMotionPoints = oldPointsPtr_();
pointField& newMotionPoints = *oldPointsPtr_; pointField& newMotionPoints = oldPointsPtr_();
// Resize the list to new size // Resize the list to new size
newMotionPoints.setSize(points_.size()); newMotionPoints.setSize(points_.size());

View File

@ -25,8 +25,6 @@ License
#include "primitiveMesh.H" #include "primitiveMesh.H"
#include "demandDrivenData.H" #include "demandDrivenData.H"
#include "indexedOctree.H"
#include "treeDataCell.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
@ -63,8 +61,6 @@ Foam::primitiveMesh::primitiveMesh()
ppPtr_(NULL), ppPtr_(NULL),
cpPtr_(NULL), cpPtr_(NULL),
cellTreePtr_(NULL),
labels_(0), labels_(0),
cellCentresPtr_(NULL), cellCentresPtr_(NULL),
@ -107,8 +103,6 @@ Foam::primitiveMesh::primitiveMesh
ppPtr_(NULL), ppPtr_(NULL),
cpPtr_(NULL), cpPtr_(NULL),
cellTreePtr_(NULL),
labels_(0), labels_(0),
cellCentresPtr_(NULL), cellCentresPtr_(NULL),
@ -351,36 +345,4 @@ const Foam::cellShapeList& Foam::primitiveMesh::cellShapes() const
} }
const Foam::indexedOctree<Foam::treeDataCell>&
Foam::primitiveMesh::cellTree() const
{
if (!cellTreePtr_)
{
treeBoundBox overallBb(points());
Random rndGen(261782);
overallBb = overallBb.extend(rndGen, 1E-4);
overallBb.min() -= point(ROOTVSMALL, ROOTVSMALL, ROOTVSMALL);
overallBb.max() += point(ROOTVSMALL, ROOTVSMALL, ROOTVSMALL);
cellTreePtr_ =
new indexedOctree<treeDataCell>
(
treeDataCell
(
false, // not cache bb
*this
),
overallBb,
8, // maxLevel
10, // leafsize
5.0 // duplicity
);
}
return *cellTreePtr_;
}
// ************************************************************************* // // ************************************************************************* //

View File

@ -69,10 +69,6 @@ SourceFiles
namespace Foam namespace Foam
{ {
// Forward declaration of classes
class treeDataCell;
template<class Type> class indexedOctree;
/*---------------------------------------------------------------------------*\ /*---------------------------------------------------------------------------*\
Class primitiveMesh Declaration Class primitiveMesh Declaration
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
@ -155,9 +151,6 @@ class primitiveMesh
//- Cell-points //- Cell-points
mutable labelListList* cpPtr_; mutable labelListList* cpPtr_;
//- Search tree to allow spatial tet searching
mutable indexedOctree<treeDataCell>* cellTreePtr_;
// On-the-fly edge addresing storage // On-the-fly edge addresing storage
@ -485,10 +478,6 @@ public:
const labelListList& cellPoints() const; const labelListList& cellPoints() const;
//- Build (if necessary) and return the cell search tree
const indexedOctree<treeDataCell>& cellTree() const;
// Geometric data (raw!) // Geometric data (raw!)
const vectorField& cellCentres() const; const vectorField& cellCentres() const;
@ -821,9 +810,6 @@ public:
//- Clear topological data //- Clear topological data
void clearAddressing(); void clearAddressing();
//- Clear cell tree data
void clearCellTree();
//- Clear all geometry and addressing unnecessary for CFD //- Clear all geometry and addressing unnecessary for CFD
void clearOut(); void clearOut();
}; };

View File

@ -24,11 +24,7 @@ License
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
#include "primitiveMesh.H" #include "primitiveMesh.H"
#include "indexedOctree.H"
#include "treeDataCell.H"
#include "demandDrivenData.H" #include "demandDrivenData.H"
#include "indexedOctree.H"
#include "treeDataCell.H"
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
@ -102,11 +98,6 @@ void Foam::primitiveMesh::printAllocated() const
Pout<< " Cell-point" << endl; Pout<< " Cell-point" << endl;
} }
if (cellTreePtr_)
{
Pout<< " Cell-tree" << endl;
}
// Geometry // Geometry
if (cellCentresPtr_) if (cellCentresPtr_)
{ {
@ -173,14 +164,6 @@ void Foam::primitiveMesh::clearAddressing()
deleteDemandDrivenData(pePtr_); deleteDemandDrivenData(pePtr_);
deleteDemandDrivenData(ppPtr_); deleteDemandDrivenData(ppPtr_);
deleteDemandDrivenData(cpPtr_); deleteDemandDrivenData(cpPtr_);
deleteDemandDrivenData(cellTreePtr_);
}
void Foam::primitiveMesh::clearCellTree()
{
deleteDemandDrivenData(cellTreePtr_);
} }

View File

@ -36,7 +36,7 @@ void Foam::ignitionSite::findIgnitionCells(const fvMesh& mesh)
const volVectorField& centres = mesh.C(); const volVectorField& centres = mesh.C();
const scalarField& vols = mesh.V(); const scalarField& vols = mesh.V();
label ignCell = mesh.findCell(location_); label ignCell = mesh.findCell(location_, polyMesh::FACEDIAGTETS);
if (ignCell == -1) if (ignCell == -1)
{ {
return; return;

View File

@ -107,7 +107,11 @@ void Foam::basicSource::setCellSet()
forAll(points_, i) forAll(points_, i)
{ {
label cellI = mesh_.findCell(points_[i]); label cellI = mesh_.findCell
(
points_[i],
polyMesh::FACEDIAGTETS
);
if (cellI >= 0) if (cellI >= 0)
{ {
selectedCells.insert(cellI); selectedCells.insert(cellI);

View File

@ -234,7 +234,11 @@ void Foam::TimeActivatedExplicitSource<Type>::setCellSet()
forAll(points_, i) forAll(points_, i)
{ {
label cellI = mesh_.findCell(points_[i]); label cellI = mesh_.findCell
(
points_[i],
polyMesh::FACEDIAGTETS
);
if (cellI >= 0) if (cellI >= 0)
{ {
selectedCells.insert(cellI); selectedCells.insert(cellI);

View File

@ -76,7 +76,11 @@ void Foam::setRefCell
else if (dict.found(refPointName)) else if (dict.found(refPointName))
{ {
point refPointi(dict.lookup(refPointName)); point refPointi(dict.lookup(refPointName));
refCelli = field.mesh().findCell(refPointi); refCelli = field.mesh().findCell
(
refPointi,
polyMesh::FACEDIAGTETS
);
label hasRef = (refCelli >= 0 ? 1 : 0); label hasRef = (refCelli >= 0 ? 1 : 0);
label sumHasRef = returnReduce<label>(hasRef, sumOp<label>()); label sumHasRef = returnReduce<label>(hasRef, sumOp<label>());
if (sumHasRef != 1) if (sumHasRef != 1)

View File

@ -163,7 +163,13 @@ void Foam::InteractionLists<ParticleType>::buildInteractionLists()
indexedOctree<treeDataCell> coupledPatchRangeTree indexedOctree<treeDataCell> coupledPatchRangeTree
( (
treeDataCell(true, mesh_, coupledPatchRangeCells), treeDataCell
(
true, // cache cell bb
mesh_,
coupledPatchRangeCells, // subset of mesh
polyMesh::FACEDIAGTETS // consistent with tracking
),
procBbRndExt, procBbRndExt,
8, // maxLevel, 8, // maxLevel,
10, // leafSize, 10, // leafSize,
@ -382,7 +388,7 @@ void Foam::InteractionLists<ParticleType>::buildInteractionLists()
indexedOctree<treeDataCell> allCellsTree indexedOctree<treeDataCell> allCellsTree
( (
treeDataCell(true, mesh_), treeDataCell(true, mesh_, polyMesh::FACEDIAGTETS),
procBbRndExt, procBbRndExt,
8, // maxLevel, 8, // maxLevel,
10, // leafSize, 10, // leafSize,

View File

@ -9,7 +9,8 @@ if (injectorCell >= 0)
foundCell = mesh_.pointInCell foundCell = mesh_.pointInCell
( (
injectionPosition, injectionPosition,
injectorCell injectorCell,
polyMesh::FACEDIAGTETS
); );
} }
@ -39,7 +40,8 @@ if (!foundCell)
foundCell = mesh_.pointInCell foundCell = mesh_.pointInCell
( (
injectionPosition, injectionPosition,
injectorCell injectorCell,
polyMesh::FACEDIAGTETS
); );
} }
reduce(foundCell, orOp<bool>()); reduce(foundCell, orOp<bool>());
@ -61,7 +63,8 @@ if (!foundCell)
foundCell = mesh_.pointInCell foundCell = mesh_.pointInCell
( (
injectionPosition, injectionPosition,
injectorCell injectorCell,
polyMesh::FACEDIAGTETS
); );
} }
reduce(foundCell, orOp<bool>()); reduce(foundCell, orOp<bool>());

View File

@ -205,7 +205,15 @@ bool Foam::InjectionModel<CloudType>::findCellAtPosition
{ {
position += SMALL*(cellCentres[cellI] - position); position += SMALL*(cellCentres[cellI] - position);
if (this->owner().mesh().pointInCell(position, cellI)) if
(
this->owner().mesh().pointInCell
(
position,
cellI,
polyMesh::FACEDIAGTETS
)
)
{ {
procI = Pstream::myProcNo(); procI = Pstream::myProcNo();
} }

View File

@ -86,7 +86,7 @@ Foam::labelList Foam::refinementParameters::findCells(const polyMesh& mesh)
{ {
const point& keepPoint = keepPoints_[i]; const point& keepPoint = keepPoints_[i];
label localCellI = mesh.findCell(keepPoint); label localCellI = mesh.findCell(keepPoint, polyMesh::FACEDIAGTETS);
label globalCellI = -1; label globalCellI = -1;

View File

@ -1825,7 +1825,7 @@ Foam::autoPtr<Foam::mapPolyMesh> Foam::meshRefinement::splitMeshRegions
label regionI = -1; label regionI = -1;
label cellI = mesh_.findCell(keepPoint); label cellI = mesh_.findCell(keepPoint, polyMesh::FACEDIAGTETS);
if (cellI != -1) if (cellI != -1)
{ {

View File

@ -1248,7 +1248,7 @@ void Foam::meshRefinement::findCellZoneInsideWalk
// Find the region containing the insidePoint // Find the region containing the insidePoint
label keepRegionI = -1; label keepRegionI = -1;
label cellI = mesh_.findCell(insidePoint); label cellI = mesh_.findCell(insidePoint, polyMesh::FACEDIAGTETS);
if (cellI != -1) if (cellI != -1)
{ {
@ -1418,7 +1418,7 @@ void Foam::meshRefinement::findCellZoneTopo
// Find the region containing the keepPoint // Find the region containing the keepPoint
label keepRegionI = -1; label keepRegionI = -1;
label cellI = mesh_.findCell(keepPoint); label cellI = mesh_.findCell(keepPoint, polyMesh::FACEDIAGTETS);
if (cellI != -1) if (cellI != -1)
{ {
@ -1959,7 +1959,7 @@ Foam::autoPtr<Foam::mapPolyMesh> Foam::meshRefinement::splitMesh
// Find the region containing the keepPoint // Find the region containing the keepPoint
label keepRegionI = -1; label keepRegionI = -1;
label cellI = mesh_.findCell(keepPoint); label cellI = mesh_.findCell(keepPoint, polyMesh::FACEDIAGTETS);
if (cellI != -1) if (cellI != -1)
{ {

View File

@ -174,7 +174,7 @@ void Foam::mappedPatchBase::findSamples
} }
// Octree based search engine // Octree based search engine
meshSearch meshSearchEngine(mesh, false); meshSearch meshSearchEngine(mesh, polyMesh::FACEDIAGTETS);
forAll(samples, sampleI) forAll(samples, sampleI)
{ {
@ -291,7 +291,7 @@ void Foam::mappedPatchBase::findSamples
} }
// Octree based search engine // Octree based search engine
meshSearch meshSearchEngine(mesh, false); meshSearch meshSearchEngine(mesh, polyMesh::FACEDIAGTETS);
forAll(samples, sampleI) forAll(samples, sampleI)
{ {

View File

@ -302,7 +302,7 @@ Foam::label Foam::meshSearch::findCellLinear(const point& location) const
while ((!cellFound) && (n < mesh_.nCells())) while ((!cellFound) && (n < mesh_.nCells()))
{ {
if (pointInCell(location, n)) if (mesh_.pointInCell(location, n, cellDecompMode_))
{ {
cellFound = true; cellFound = true;
cellI = n; cellI = n;
@ -338,7 +338,7 @@ Foam::label Foam::meshSearch::findCellWalk
) << "illegal seedCell:" << seedCellI << exit(FatalError); ) << "illegal seedCell:" << seedCellI << exit(FatalError);
} }
if (pointInCell(location, seedCellI)) if (mesh_.pointInCell(location, seedCellI, cellDecompMode_))
{ {
return seedCellI; return seedCellI;
} }
@ -368,7 +368,7 @@ Foam::label Foam::meshSearch::findCellWalk
} }
// Check if this is the correct cell // Check if this is the correct cell
if (pointInCell(location, cellI)) if (mesh_.pointInCell(location, cellI, cellDecompMode_))
{ {
return cellI; return cellI;
} }
@ -500,10 +500,14 @@ Foam::vector Foam::meshSearch::offset
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
// Construct from components // Construct from components
Foam::meshSearch::meshSearch(const polyMesh& mesh, const bool faceDecomp) Foam::meshSearch::meshSearch
(
const polyMesh& mesh,
const polyMesh::cellRepresentation cellDecompMode
)
: :
mesh_(mesh), mesh_(mesh),
faceDecomp_(faceDecomp) cellDecompMode_(cellDecompMode)
{} {}
@ -512,11 +516,11 @@ Foam::meshSearch::meshSearch
( (
const polyMesh& mesh, const polyMesh& mesh,
const treeBoundBox& bb, const treeBoundBox& bb,
const bool faceDecomp const polyMesh::cellRepresentation cellDecompMode
) )
: :
mesh_(mesh), mesh_(mesh),
faceDecomp_(faceDecomp) cellDecompMode_(cellDecompMode)
{ {
overallBbPtr_.reset(new treeBoundBox(bb)); overallBbPtr_.reset(new treeBoundBox(bb));
} }
@ -616,7 +620,8 @@ const
treeDataCell treeDataCell
( (
false, // not cache bb false, // not cache bb
mesh_ mesh_,
cellDecompMode_ // cell decomposition mode for inside tests
), ),
overallBbPtr_(), overallBbPtr_(),
8, // maxLevel 8, // maxLevel
@ -630,90 +635,90 @@ const
} }
// Is the point in the cell //// Is the point in the cell
// Works by checking if there is a face inbetween the point and the cell //// Works by checking if there is a face inbetween the point and the cell
// centre. //// centre.
// Check for internal uses proper face decomposition or just average normal. //// Check for internal uses proper face decomposition or just average normal.
bool Foam::meshSearch::pointInCell(const point& p, label cellI) const //bool Foam::meshSearch::pointInCell(const point& p, label cellI) const
{ //{
if (faceDecomp_) // if (faceDecomp_)
{ // {
const point& ctr = mesh_.cellCentres()[cellI]; // const point& ctr = mesh_.cellCentres()[cellI];
//
vector dir(p - ctr); // vector dir(p - ctr);
scalar magDir = mag(dir); // scalar magDir = mag(dir);
//
// Check if any faces are hit by ray from cell centre to p. // // Check if any faces are hit by ray from cell centre to p.
// If none -> p is in cell. // // If none -> p is in cell.
const labelList& cFaces = mesh_.cells()[cellI]; // const labelList& cFaces = mesh_.cells()[cellI];
//
// Make sure half_ray does not pick up any faces on the wrong // // Make sure half_ray does not pick up any faces on the wrong
// side of the ray. // // side of the ray.
scalar oldTol = intersection::setPlanarTol(0.0); // scalar oldTol = intersection::setPlanarTol(0.0);
//
forAll(cFaces, i) // forAll(cFaces, i)
{ // {
label faceI = cFaces[i]; // label faceI = cFaces[i];
//
pointHit inter = mesh_.faces()[faceI].ray // pointHit inter = mesh_.faces()[faceI].ray
( // (
ctr, // ctr,
dir, // dir,
mesh_.points(), // mesh_.points(),
intersection::HALF_RAY, // intersection::HALF_RAY,
intersection::VECTOR // intersection::VECTOR
); // );
//
if (inter.hit()) // if (inter.hit())
{ // {
scalar dist = inter.distance(); // scalar dist = inter.distance();
//
if (dist < magDir) // if (dist < magDir)
{ // {
// Valid hit. Hit face so point is not in cell. // // Valid hit. Hit face so point is not in cell.
intersection::setPlanarTol(oldTol); // intersection::setPlanarTol(oldTol);
//
return false; // return false;
} // }
} // }
} // }
//
intersection::setPlanarTol(oldTol); // intersection::setPlanarTol(oldTol);
//
// No face inbetween point and cell centre so point is inside. // // No face inbetween point and cell centre so point is inside.
return true; // return true;
} // }
else // else
{ // {
const labelList& f = mesh_.cells()[cellI]; // const labelList& f = mesh_.cells()[cellI];
const labelList& owner = mesh_.faceOwner(); // const labelList& owner = mesh_.faceOwner();
const vectorField& cf = mesh_.faceCentres(); // const vectorField& cf = mesh_.faceCentres();
const vectorField& Sf = mesh_.faceAreas(); // const vectorField& Sf = mesh_.faceAreas();
//
forAll(f, facei) // forAll(f, facei)
{ // {
label nFace = f[facei]; // label nFace = f[facei];
vector proj = p - cf[nFace]; // vector proj = p - cf[nFace];
vector normal = Sf[nFace]; // vector normal = Sf[nFace];
if (owner[nFace] == cellI) // if (owner[nFace] == cellI)
{ // {
if ((normal & proj) > 0) // if ((normal & proj) > 0)
{ // {
return false; // return false;
} // }
} // }
else // else
{ // {
if ((normal & proj) < 0) // if ((normal & proj) < 0)
{ // {
return false; // return false;
} // }
} // }
} // }
//
return true; // return true;
} // }
} //}
Foam::label Foam::meshSearch::findNearestCell Foam::label Foam::meshSearch::findNearestCell

View File

@ -38,6 +38,7 @@ SourceFiles
#include "pointIndexHit.H" #include "pointIndexHit.H"
#include "pointField.H" #include "pointField.H"
#include "polyMesh.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -45,7 +46,6 @@ namespace Foam
{ {
// Forward declaration of classes // Forward declaration of classes
class polyMesh;
class treeDataCell; class treeDataCell;
class treeDataFace; class treeDataFace;
template<class Type> class indexedOctree; template<class Type> class indexedOctree;
@ -62,8 +62,8 @@ class meshSearch
//- Reference to mesh //- Reference to mesh
const polyMesh& mesh_; const polyMesh& mesh_;
//- Whether to use face decomposition for all geometric tests //- Whether to use cell decomposition for all geometric tests
const bool faceDecomp_; const polyMesh::cellRepresentation cellDecompMode_;
//- data bounding box //- data bounding box
mutable autoPtr<treeBoundBox> overallBbPtr_; mutable autoPtr<treeBoundBox> overallBbPtr_;
@ -168,7 +168,11 @@ public:
//- Construct from components. Constructs bb slightly bigger than //- Construct from components. Constructs bb slightly bigger than
// mesh points bb. // mesh points bb.
meshSearch(const polyMesh& mesh, const bool faceDecomp = true); meshSearch
(
const polyMesh& mesh,
const polyMesh::cellRepresentation = polyMesh::FACEDIAGTETS
);
//- Construct with a custom bounding box. Any mesh element outside //- Construct with a custom bounding box. Any mesh element outside
// bb will not be found. Up to user to make sure bb // bb will not be found. Up to user to make sure bb
@ -177,7 +181,7 @@ public:
( (
const polyMesh& mesh, const polyMesh& mesh,
const treeBoundBox& bb, const treeBoundBox& bb,
const bool faceDecomp = true const polyMesh::cellRepresentation = polyMesh::FACEDIAGTETS
); );
//- Destructor //- Destructor
@ -193,6 +197,11 @@ public:
return mesh_; return mesh_;
} }
polyMesh::cellRepresentation decompMode() const
{
return cellDecompMode_;
}
//- Get (demand driven) reference to octree holding all //- Get (demand driven) reference to octree holding all
// boundary faces // boundary faces
const indexedOctree<treeDataFace>& boundaryTree() const; const indexedOctree<treeDataFace>& boundaryTree() const;
@ -203,10 +212,6 @@ public:
// Queries // Queries
//- test for point in cell. Does not handle cells with center
// outside cell.
bool pointInCell(const point& p, const label celli) const;
//- Find nearest cell in terms of cell centre. //- Find nearest cell in terms of cell centre.
// Options: // Options:
// - use octree // - use octree
@ -227,7 +232,7 @@ public:
const bool useTreeSearch = true const bool useTreeSearch = true
) const; ) const;
//- Find cell containing (using pointInCell) location. //- Find cell containing location.
// If seed provided walks and falls back to linear/tree search. // If seed provided walks and falls back to linear/tree search.
// (so handles holes correctly)s // (so handles holes correctly)s
// Returns -1 if not in domain. // Returns -1 if not in domain.

View File

@ -116,7 +116,12 @@ bool Foam::octreeDataCell::contains
const point& sample const point& sample
) const ) const
{ {
return mesh_.pointInCell(sample, cellLabels_[index]); return mesh_.pointInCell
(
sample,
cellLabels_[index],
polyMesh::FACEDIAGTETS
);
} }

View File

@ -25,8 +25,6 @@ License
#include "nearestToCell.H" #include "nearestToCell.H"
#include "polyMesh.H" #include "polyMesh.H"
#include "meshSearch.H"
#include "addToRunTimeSelectionTable.H" #include "addToRunTimeSelectionTable.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //

View File

@ -60,7 +60,7 @@ Foam::topoSetSource::addToUsageTable Foam::regionToCell::usage_
void Foam::regionToCell::combine(topoSet& set, const bool add) const void Foam::regionToCell::combine(topoSet& set, const bool add) const
{ {
label cellI = mesh_.findCell(insidePoint_); label cellI = mesh_.findCell(insidePoint_, polyMesh::FACEDIAGTETS);
// Load the subset of cells // Load the subset of cells
boolList blockedFace(mesh_.nFaces(), false); boolList blockedFace(mesh_.nFaces(), false);

View File

@ -166,7 +166,7 @@ void Foam::surfaceToCell::combine(topoSet& set, const bool add) const
// Construct search engine on mesh // Construct search engine on mesh
meshSearch queryMesh(mesh_, true); meshSearch queryMesh(mesh_, polyMesh::FACEDIAGTETS);
// Check all 'outside' points // Check all 'outside' points

View File

@ -25,8 +25,6 @@ License
#include "nearestToPoint.H" #include "nearestToPoint.H"
#include "polyMesh.H" #include "polyMesh.H"
#include "meshSearch.H"
#include "addToRunTimeSelectionTable.H" #include "addToRunTimeSelectionTable.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //

View File

@ -25,7 +25,6 @@ License
#include "surfaceToPoint.H" #include "surfaceToPoint.H"
#include "polyMesh.H" #include "polyMesh.H"
#include "meshSearch.H"
#include "triSurfaceSearch.H" #include "triSurfaceSearch.H"
#include "cpuTime.H" #include "cpuTime.H"

View File

@ -235,7 +235,7 @@ void Foam::surfaceSets::getSurfaceSets
) )
{ {
// Construct search engine on mesh // Construct search engine on mesh
meshSearch queryMesh(mesh, true); meshSearch queryMesh(mesh, polyMesh::FACEDIAGTETS);
// Cut faces with surface and classify cells // Cut faces with surface and classify cells
cellClassification cellType cellClassification cellType

View File

@ -363,7 +363,7 @@ void Foam::streamLine::read(const dictionary& dict)
const fvMesh& mesh = dynamic_cast<const fvMesh&>(obr_); const fvMesh& mesh = dynamic_cast<const fvMesh&>(obr_);
meshSearchPtr_.reset(new meshSearch(mesh, false)); meshSearchPtr_.reset(new meshSearch(mesh, polyMesh::FACEDIAGTETS));
const dictionary& coeffsDict = dict.subDict(seedSet_ + "Coeffs"); const dictionary& coeffsDict = dict.subDict(seedSet_ + "Coeffs");
sampledSetPtr_ = sampledSet::New sampledSetPtr_ = sampledSet::New

View File

@ -102,7 +102,7 @@ void Foam::meshToMesh::calcAddressing()
indexedOctree<treeDataCell> oc indexedOctree<treeDataCell> oc
( (
treeDataCell(false, fromMesh_), treeDataCell(false, fromMesh_, polyMesh::FACEDIAGTETS),
shiftedBb, // overall bounding box shiftedBb, // overall bounding box
8, // maxLevel 8, // maxLevel
10, // leafsize 10, // leafsize
@ -267,7 +267,7 @@ void Foam::meshToMesh::cellAddresses
cellAddressing_[toI] = -1; cellAddressing_[toI] = -1;
// Check point is actually in the nearest cell // Check point is actually in the nearest cell
if (fromMesh.pointInCell(p, curCell)) if (fromMesh.pointInCell(p, curCell, polyMesh::FACEDIAGTETS))
{ {
cellAddressing_[toI] = curCell; cellAddressing_[toI] = curCell;
} }
@ -292,7 +292,15 @@ void Foam::meshToMesh::cellAddresses
{ {
// search through all the neighbours. // search through all the neighbours.
// If point is in neighbour reset current cell // If point is in neighbour reset current cell
if (fromMesh.pointInCell(p, neighbours[nI])) if
(
fromMesh.pointInCell
(
p,
neighbours[nI],
polyMesh::FACEDIAGTETS
)
)
{ {
cellAddressing_[toI] = neighbours[nI]; cellAddressing_[toI] = neighbours[nI];
found = true; found = true;
@ -316,7 +324,15 @@ void Foam::meshToMesh::cellAddresses
{ {
// search through all the neighbours. // search through all the neighbours.
// If point is in neighbour reset current cell // If point is in neighbour reset current cell
if (fromMesh.pointInCell(p, nn[nI])) if
(
fromMesh.pointInCell
(
p,
nn[nI],
polyMesh::FACEDIAGTETS
)
)
{ {
cellAddressing_[toI] = nn[nI]; cellAddressing_[toI] = nn[nI];
found = true; found = true;

View File

@ -28,7 +28,6 @@ License
#include "IOmanip.H" #include "IOmanip.H"
// For 'nearInfo' helper class only // For 'nearInfo' helper class only
#include "mappedPatchBase.H" #include "mappedPatchBase.H"
//#include "meshSearch.H"
#include "treeBoundBox.H" #include "treeBoundBox.H"
#include "treeDataFace.H" #include "treeDataFace.H"

View File

@ -45,7 +45,7 @@ void Foam::probes::findElements(const fvMesh& mesh)
{ {
const vector& location = operator[](probeI); const vector& location = operator[](probeI);
elementList_[probeI] = mesh.findCell(location); elementList_[probeI] = mesh.findCell(location, polyMesh::FACEDIAGTETS);
if (debug && elementList_[probeI] != -1) if (debug && elementList_[probeI] != -1)
{ {

View File

@ -68,7 +68,7 @@ Foam::label Foam::sampledSet::getCell
{ {
label cellI = getBoundaryCell(faceI); label cellI = getBoundaryCell(faceI);
if (!mesh().pointInCell(sample, cellI)) if (!mesh().pointInCell(sample, cellI, searchEngine_.decompMode()))
{ {
FatalErrorIn FatalErrorIn
( (
@ -85,7 +85,7 @@ Foam::label Foam::sampledSet::getCell
label cellI = mesh().faceOwner()[faceI]; label cellI = mesh().faceOwner()[faceI];
if (mesh().pointInCell(sample, cellI)) if (mesh().pointInCell(sample, cellI, searchEngine_.decompMode()))
{ {
return cellI; return cellI;
} }
@ -93,7 +93,7 @@ Foam::label Foam::sampledSet::getCell
{ {
cellI = mesh().faceNeighbour()[faceI]; cellI = mesh().faceNeighbour()[faceI];
if (mesh().pointInCell(sample, cellI)) if (mesh().pointInCell(sample, cellI, searchEngine_.decompMode()))
{ {
return cellI; return cellI;
} }
@ -261,12 +261,17 @@ bool Foam::sampledSet::getTrackingPoint
if (bFaceI == -1) if (bFaceI == -1)
{ {
// No boundary intersection. Try and find cell samplePt is in // No boundary intersection. Try and find cell samplePt is in
trackCellI = mesh().findCell(samplePt); trackCellI = mesh().findCell(samplePt, searchEngine_.decompMode());
if if
( (
(trackCellI == -1) (trackCellI == -1)
|| !mesh().pointInCell(samplePt, trackCellI) || !mesh().pointInCell
(
samplePt,
trackCellI,
searchEngine_.decompMode()
)
) )
{ {
// Line samplePt - end_ does not intersect domain at all. // Line samplePt - end_ does not intersect domain at all.
@ -316,7 +321,7 @@ bool Foam::sampledSet::getTrackingPoint
// samplePt inside or marginally outside. // samplePt inside or marginally outside.
trackPt = samplePt; trackPt = samplePt;
trackFaceI = -1; trackFaceI = -1;
trackCellI = mesh().findCell(trackPt); trackCellI = mesh().findCell(trackPt, searchEngine_.decompMode());
isGoodSample = true; isGoodSample = true;
} }

View File

@ -138,7 +138,7 @@ Foam::sampledSets::sampledSets
mesh_(refCast<const fvMesh>(obr)), mesh_(refCast<const fvMesh>(obr)),
loadFromFiles_(loadFromFiles), loadFromFiles_(loadFromFiles),
outputPath_(fileName::null), outputPath_(fileName::null),
searchEngine_(mesh_, true), searchEngine_(mesh_, polyMesh::FACEDIAGTETS),
interpolationScheme_(word::null), interpolationScheme_(word::null),
writeFormat_(word::null) writeFormat_(word::null)
{ {

View File

@ -53,7 +53,11 @@ void Foam::triSurfaceMeshPointSet::calcSamples
{ {
forAll(sampleCoords_, sampleI) forAll(sampleCoords_, sampleI)
{ {
label cellI = searchEngine().findCell(sampleCoords_[sampleI]); label cellI = searchEngine().findCell
(
sampleCoords_[sampleI],
polyMesh::FACEDIAGTETS
);
if (cellI != -1) if (cellI != -1)
{ {

View File

@ -241,7 +241,7 @@ bool Foam::sampledTriSurfaceMesh::update()
const pointField& fc = surface_.faceCentres(); const pointField& fc = surface_.faceCentres();
// Mesh search engine, no triangulation of faces. // Mesh search engine, no triangulation of faces.
meshSearch meshSearcher(mesh(), false); meshSearch meshSearcher(mesh(), polyMesh::FACEPLANES);
List<nearInfo> nearest(fc.size()); List<nearInfo> nearest(fc.size());
@ -435,7 +435,15 @@ bool Foam::sampledTriSurfaceMesh::update()
sampleElements_[pointI] = cellI; sampleElements_[pointI] = cellI;
// Check if point inside cell // Check if point inside cell
if (mesh().pointInCell(pt, sampleElements_[pointI])) if
(
mesh().pointInCell
(
pt,
sampleElements_[pointI],
meshSearcher.decompMode()
)
)
{ {
samplePoints_[pointI] = pt; samplePoints_[pointI] = pt;
} }