From ee11f9c0e8e1ea963088cd5c3fcf3452aac94723 Mon Sep 17 00:00:00 2001 From: mattijs Date: Fri, 28 Oct 2011 11:33:30 +0100 Subject: [PATCH] ENH: pointInCell, findCell: switchable in-cell algorithm --- .../advanced/autoRefineMesh/autoRefineMesh.C | 2 +- .../mesh/advanced/selectCells/selectCells.C | 2 +- .../backgroundMeshDecomposition.C | 2 +- .../conformalVoronoiMesh.C | 2 +- .../splitMeshRegions/splitMeshRegions.C | 2 +- .../decomposePar/decomposePar.C | 6 +- .../preProcessing/mapFields/mapLagrangian.C | 6 +- .../algorithms/indexedOctree/treeDataCell.C | 26 ++- .../algorithms/indexedOctree/treeDataCell.H | 30 ++- src/OpenFOAM/meshes/polyMesh/polyMesh.C | 181 +++++++++++++++-- src/OpenFOAM/meshes/polyMesh/polyMesh.H | 43 +++- src/OpenFOAM/meshes/polyMesh/polyMeshClear.C | 15 +- .../meshes/polyMesh/polyMeshFromShapeMesh.C | 7 + src/OpenFOAM/meshes/polyMesh/polyMeshUpdate.C | 8 +- .../meshes/primitiveMesh/primitiveMesh.C | 38 ---- .../meshes/primitiveMesh/primitiveMesh.H | 14 -- .../meshes/primitiveMesh/primitiveMeshClear.C | 17 -- src/engine/ignition/ignitionSite.C | 2 +- .../basicSource/basicSource/basicSource.C | 6 +- .../TimeActivatedExplicitSource.C | 6 +- .../general/findRefCell/findRefCell.C | 6 +- .../basic/InteractionLists/InteractionLists.C | 10 +- .../dieselSpray/spray/findInjectorCell.H | 9 +- .../InjectionModel/InjectionModel.C | 10 +- .../refinementParameters.C | 2 +- .../meshRefinement/meshRefinement.C | 2 +- .../meshRefinement/meshRefinementBaffles.C | 6 +- .../mappedPolyPatch/mappedPatchBase.C | 4 +- src/meshTools/meshSearch/meshSearch.C | 191 +++++++++--------- src/meshTools/meshSearch/meshSearch.H | 25 ++- src/meshTools/octree/octreeDataCell.C | 7 +- .../cellSources/nearestToCell/nearestToCell.C | 2 - .../cellSources/regionToCell/regionToCell.C | 2 +- .../cellSources/surfaceToCell/surfaceToCell.C | 2 +- .../nearestToPoint/nearestToPoint.C | 2 - .../surfaceToPoint/surfaceToPoint.C | 1 - src/meshTools/surfaceSets/surfaceSets.C | 2 +- .../field/streamLine/streamLine.C | 2 +- .../calculateMeshToMeshAddressing.C | 24 ++- src/sampling/probes/patchProbes.C | 1 - src/sampling/probes/probes.C | 2 +- .../sampledSet/sampledSet/sampledSet.C | 17 +- .../sampledSet/sampledSets/sampledSets.C | 2 +- .../triSurfaceMeshPointSet.C | 6 +- .../sampledTriSurfaceMesh.C | 12 +- 45 files changed, 496 insertions(+), 268 deletions(-) diff --git a/applications/utilities/mesh/advanced/autoRefineMesh/autoRefineMesh.C b/applications/utilities/mesh/advanced/autoRefineMesh/autoRefineMesh.C index db7585039a..2f99404f9a 100644 --- a/applications/utilities/mesh/advanced/autoRefineMesh/autoRefineMesh.C +++ b/applications/utilities/mesh/advanced/autoRefineMesh/autoRefineMesh.C @@ -715,7 +715,7 @@ int main(int argc, char *argv[]) triSurfaceSearch querySurf(surf); // Search engine on mesh. No face decomposition since mesh unwarped. - meshSearch queryMesh(mesh, false); + meshSearch queryMesh(mesh, polyMesh::FACEPLANES); // Check all 'outside' points forAll(outsidePts, outsideI) diff --git a/applications/utilities/mesh/advanced/selectCells/selectCells.C b/applications/utilities/mesh/advanced/selectCells/selectCells.C index 424826284d..ae7525f127 100644 --- a/applications/utilities/mesh/advanced/selectCells/selectCells.C +++ b/applications/utilities/mesh/advanced/selectCells/selectCells.C @@ -381,7 +381,7 @@ int main(int argc, char *argv[]) (void)edgeCalc.minLen(Info); // Search engine on mesh. Face decomposition since faces might be warped. - meshSearch queryMesh(mesh, true); + meshSearch queryMesh(mesh, polyMesh::FACEDIAGTETS); // Check all 'outside' points forAll(outsidePts, outsideI) diff --git a/applications/utilities/mesh/generation/cvMesh/conformalVoronoiMesh/backgroundMeshDecomposition/backgroundMeshDecomposition.C b/applications/utilities/mesh/generation/cvMesh/conformalVoronoiMesh/backgroundMeshDecomposition/backgroundMeshDecomposition.C index f8ce438b1f..ad420d096f 100644 --- a/applications/utilities/mesh/generation/cvMesh/conformalVoronoiMesh/backgroundMeshDecomposition/backgroundMeshDecomposition.C +++ b/applications/utilities/mesh/generation/cvMesh/conformalVoronoiMesh/backgroundMeshDecomposition/backgroundMeshDecomposition.C @@ -971,7 +971,7 @@ Foam::backgroundMeshDecomposition::distribute { // Map cellVertices, cellVertexIndices and cellVertexTypes - meshSearch cellSearch(mesh_); + meshSearch cellSearch(mesh_, polyMesh::FACEPLANES); const labelList& reverseCellMap = map().reverseCellMap(); diff --git a/applications/utilities/mesh/generation/cvMesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMesh.C b/applications/utilities/mesh/generation/cvMesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMesh.C index 5d4961e93e..3c7720e92a 100644 --- a/applications/utilities/mesh/generation/cvMesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMesh.C +++ b/applications/utilities/mesh/generation/cvMesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMesh.C @@ -1405,7 +1405,7 @@ bool Foam::conformalVoronoiMesh::distributeBackground() zeroGradientFvPatchScalarField::typeName ); - meshSearch cellSearch(bMesh); + meshSearch cellSearch(bMesh, polyMesh::FACEPLANES); List > cellVertices(bMesh.nCells()); List > cellVertexIndices(bMesh.nCells()); diff --git a/applications/utilities/mesh/manipulation/splitMeshRegions/splitMeshRegions.C b/applications/utilities/mesh/manipulation/splitMeshRegions/splitMeshRegions.C index b34676fac5..2d75cc36ef 100644 --- a/applications/utilities/mesh/manipulation/splitMeshRegions/splitMeshRegions.C +++ b/applications/utilities/mesh/manipulation/splitMeshRegions/splitMeshRegions.C @@ -2194,7 +2194,7 @@ int main(int argc, char *argv[]) label regionI = -1; - label cellI = mesh.findCell(insidePoint); + label cellI = mesh.findCell(insidePoint, polyMesh::FACEDIAGTETS); Info<< nl << "Found point " << insidePoint << " in cell " << cellI << endl; diff --git a/applications/utilities/parallelProcessing/decomposePar/decomposePar.C b/applications/utilities/parallelProcessing/decomposePar/decomposePar.C index 50c5f9b592..1a92c9bc39 100644 --- a/applications/utilities/parallelProcessing/decomposePar/decomposePar.C +++ b/applications/utilities/parallelProcessing/decomposePar/decomposePar.C @@ -528,7 +528,11 @@ int main(int argc, char *argv[]) << "Cell number should be between 0 and " << mesh.nCells()-1 << nl << "On this mesh the particle should be in cell " - << mesh.findCell(iter().position()) + << mesh.findCell + ( + iter().position(), + polyMesh::FACEDIAGTETS + ) << exit(FatalError); } diff --git a/applications/utilities/preProcessing/mapFields/mapLagrangian.C b/applications/utilities/preProcessing/mapFields/mapLagrangian.C index ee0e2aa4d3..f73029529e 100644 --- a/applications/utilities/preProcessing/mapFields/mapLagrangian.C +++ b/applications/utilities/preProcessing/mapFields/mapLagrangian.C @@ -56,7 +56,11 @@ static label findCell(const Cloud& cloud, const point& pt) // See if particle on face by finding nearest face and shifting // particle. - meshSearch meshSearcher(mesh, false); + meshSearch meshSearcher + ( + mesh, + polyMesh::FACEPLANES // no decomposition needed + ); label faceI = meshSearcher.findNearestBoundaryFace(pt); diff --git a/src/OpenFOAM/algorithms/indexedOctree/treeDataCell.C b/src/OpenFOAM/algorithms/indexedOctree/treeDataCell.C index 9dab19abe4..1bb57a44d7 100644 --- a/src/OpenFOAM/algorithms/indexedOctree/treeDataCell.C +++ b/src/OpenFOAM/algorithms/indexedOctree/treeDataCell.C @@ -25,7 +25,7 @@ License #include "treeDataCell.H" #include "indexedOctree.H" -#include "primitiveMesh.H" +#include "polyMesh.H" // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // @@ -83,13 +83,15 @@ void Foam::treeDataCell::update() Foam::treeDataCell::treeDataCell ( const bool cacheBb, - const primitiveMesh& mesh, - const labelUList& cellLabels + const polyMesh& mesh, + const labelUList& cellLabels, + const polyMesh::cellRepresentation decompMode ) : mesh_(mesh), cellLabels_(cellLabels), - cacheBb_(cacheBb) + cacheBb_(cacheBb), + decompMode_(decompMode) { update(); } @@ -98,13 +100,15 @@ Foam::treeDataCell::treeDataCell Foam::treeDataCell::treeDataCell ( const bool cacheBb, - const primitiveMesh& mesh, - const Xfer& cellLabels + const polyMesh& mesh, + const Xfer& cellLabels, + const polyMesh::cellRepresentation decompMode ) : mesh_(mesh), cellLabels_(cellLabels), - cacheBb_(cacheBb) + cacheBb_(cacheBb), + decompMode_(decompMode) { update(); } @@ -113,12 +117,14 @@ Foam::treeDataCell::treeDataCell Foam::treeDataCell::treeDataCell ( const bool cacheBb, - const primitiveMesh& mesh + const polyMesh& mesh, + const polyMesh::cellRepresentation decompMode ) : mesh_(mesh), cellLabels_(identity(mesh_.nCells())), - cacheBb_(cacheBb) + cacheBb_(cacheBb), + decompMode_(decompMode) { update(); } @@ -162,7 +168,7 @@ bool Foam::treeDataCell::contains const point& sample ) const { - return mesh_.pointInCell(sample, cellLabels_[index]); + return mesh_.pointInCell(sample, cellLabels_[index], decompMode_); } diff --git a/src/OpenFOAM/algorithms/indexedOctree/treeDataCell.H b/src/OpenFOAM/algorithms/indexedOctree/treeDataCell.H index 62bf4b4a4f..476266faf9 100644 --- a/src/OpenFOAM/algorithms/indexedOctree/treeDataCell.H +++ b/src/OpenFOAM/algorithms/indexedOctree/treeDataCell.H @@ -36,6 +36,7 @@ SourceFiles #ifndef treeDataCell_H #define treeDataCell_H +#include "polyMesh.H" #include "treeBoundBoxList.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -44,7 +45,6 @@ namespace Foam { // Forward declaration of classes -class primitiveMesh; template class indexedOctree; /*---------------------------------------------------------------------------*\ @@ -55,7 +55,7 @@ class treeDataCell { // Private data - const primitiveMesh& mesh_; + const polyMesh& mesh_; //- Subset of cells to work on const labelList cellLabels_; @@ -63,6 +63,9 @@ class treeDataCell //- Whether to precalculate and store cell bounding box const bool cacheBb_; + //- How to decide if point is inside cell + const polyMesh::cellRepresentation decompMode_; + //- cell bounding boxes (valid only if cacheBb_) treeBoundBoxList bbs_; @@ -87,20 +90,27 @@ public: treeDataCell ( const bool cacheBb, - const primitiveMesh&, - const labelUList& + const polyMesh&, + const labelUList&, + const polyMesh::cellRepresentation decompMode ); //- Construct from mesh and subset of cells, transferring contents treeDataCell ( const bool cacheBb, - const primitiveMesh&, - const Xfer& + const polyMesh&, + const Xfer&, + const polyMesh::cellRepresentation decompMode ); //- 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 @@ -112,11 +122,15 @@ public: return cellLabels_; } - inline const primitiveMesh& mesh() const + inline const polyMesh& mesh() const { return mesh_; } + inline polyMesh::cellRepresentation decompMode() const + { + return decompMode_; + } inline label size() const { diff --git a/src/OpenFOAM/meshes/polyMesh/polyMesh.C b/src/OpenFOAM/meshes/polyMesh/polyMesh.C index 7a2f5afa96..cbc223c583 100644 --- a/src/OpenFOAM/meshes/polyMesh/polyMesh.C +++ b/src/OpenFOAM/meshes/polyMesh/polyMesh.C @@ -32,7 +32,6 @@ License #include "globalMeshData.H" #include "processorPolyPatch.H" #include "OSspecific.H" -#include "demandDrivenData.H" #include "polyMeshTetDecomposition.H" #include "indexedOctree.H" #include "treeDataCell.H" @@ -209,6 +208,7 @@ Foam::polyMesh::polyMesh(const IOobject& io) geometricD_(Vector