From c731cfdca409bb183c3d509bc329a1065d1ed731 Mon Sep 17 00:00:00 2001
From: mattijs <mattijs@hunt.opencfd.co.uk>
Date: Wed, 23 Apr 2008 15:51:54 +0100
Subject: [PATCH] initial mattijsLib merge

---
 .../mesh/advanced/selectCells/selectCells.C   |  18 +-
 .../mesh/manipulation/checkMesh/checkMesh.C   |   3 +-
 .../execFlowFunctionObjects/Make/files        |   2 +-
 .../velocityField/divPhi/Make/files           |   2 +-
 .../surfaceFeatureExtract.C                   |   5 +-
 src/Allwmake                                  |   2 +-
 .../mapDistributeLagrangian.H                 | 161 ---------
 .../mapDistributePolyMesh.C                   | 246 -------------
 .../mapDistributePolyMesh.H                   | 335 ------------------
 .../mapDistributePolyMeshTemplates.C          |  83 -----
 .../PrimitivePatchProjectPoints.C             |   2 +-
 .../polyTopoChange/refinementHistory.C        |  11 +-
 .../fvMotionSolver/fvMotionSolver.C           |   2 +-
 src/meshTools/Make/files                      |   4 +
 .../cellClassification/cellClassification.C   |  20 +-
 src/meshTools/indexedOctree/indexedOctree.C   |  10 -
 src/meshTools/indexedOctree/treeDataFace.H    |   2 +-
 .../surfaceIntersection/edgeIntersections.C   |   6 +-
 .../triSurfaceSearch/triSurfaceSearch.H       |   3 +-
 src/triSurface/triSurface/triSurfaceMesh.H    |  91 -----
 20 files changed, 40 insertions(+), 968 deletions(-)
 delete mode 100644 src/OpenFOAM/meshes/polyMesh/mapPolyMesh/mapDistributePolyMesh/mapDistributeLagrangian.H
 delete mode 100644 src/OpenFOAM/meshes/polyMesh/mapPolyMesh/mapDistributePolyMesh/mapDistributePolyMesh.C
 delete mode 100644 src/OpenFOAM/meshes/polyMesh/mapPolyMesh/mapDistributePolyMesh/mapDistributePolyMesh.H
 delete mode 100644 src/OpenFOAM/meshes/polyMesh/mapPolyMesh/mapDistributePolyMesh/mapDistributePolyMeshTemplates.C
 delete mode 100644 src/triSurface/triSurface/triSurfaceMesh.H

diff --git a/applications/utilities/mesh/advanced/selectCells/selectCells.C b/applications/utilities/mesh/advanced/selectCells/selectCells.C
index 5979abf4685..d8e5b502b55 100644
--- a/applications/utilities/mesh/advanced/selectCells/selectCells.C
+++ b/applications/utilities/mesh/advanced/selectCells/selectCells.C
@@ -54,8 +54,8 @@ Description
 #include "cellInfo.H"
 #include "MeshWave.H"
 #include "edgeStats.H"
-#include "octreeDataTriSurface.H"
-#include "octree.H"
+#include "treeDataTriSurface.H"
+#include "indexedOctree.H"
 
 using namespace Foam;
 
@@ -185,7 +185,7 @@ void cutBySurface
             << " to the surface ..." << nl << endl;
 
         const pointField& pts = mesh.points();
-        const octree<octreeDataTriSurface>& tree = querySurf.tree();
+        const indexedOctree<treeDataTriSurface>& tree = querySurf.tree();
 
         label nRemoved = 0;
 
@@ -193,17 +193,9 @@ void cutBySurface
         {
             const point& pt = pts[pointI];
 
-            // Search in tight bounding box around pt.
-            treeBoundBox tightest
-            (
-                pt - vector(nearDist, nearDist, nearDist),
-                pt + vector(nearDist, nearDist, nearDist)
-            );
-            scalar tightestDist = mag(tightest.max() - tightest.min());
-
-            label triI = tree.findNearest(pt, tightest, tightestDist);
+            pointIndexHit hitInfo = tree.findNearest(pt, sqr(nearDist));
 
-            if (triI != -1 && tightestDist < nearDist)
+            if (hitInfo.hit())
             {
                 const labelList& pCells = mesh.pointCells()[pointI];
 
diff --git a/applications/utilities/mesh/manipulation/checkMesh/checkMesh.C b/applications/utilities/mesh/manipulation/checkMesh/checkMesh.C
index 277d61aad43..dcbab5c1b96 100644
--- a/applications/utilities/mesh/manipulation/checkMesh/checkMesh.C
+++ b/applications/utilities/mesh/manipulation/checkMesh/checkMesh.C
@@ -45,6 +45,7 @@ using namespace Foam;
 
 int main(int argc, char *argv[])
 {
+#   include "addRegionOption.H"
 
 #   include "addTimeOptionsNoConstant.H"
 
@@ -67,7 +68,7 @@ int main(int argc, char *argv[])
 
     runTime.setTime(Times[startTime], startTime);
 
-#   include "createPolyMesh.H"
+#   include "createNamedPolyMesh.H"
 
     bool firstCheck = true;
 
diff --git a/applications/utilities/postProcessing/miscellaneous/execFlowFunctionObjects/Make/files b/applications/utilities/postProcessing/miscellaneous/execFlowFunctionObjects/Make/files
index 81fb4e070c8..a2ac93809c4 100644
--- a/applications/utilities/postProcessing/miscellaneous/execFlowFunctionObjects/Make/files
+++ b/applications/utilities/postProcessing/miscellaneous/execFlowFunctionObjects/Make/files
@@ -1,4 +1,4 @@
 execFlowFunctionObjects.C
 
-EXE = $(FOAM_USER_APPBIN)/execFlowFunctionObjects
+EXE = $(FOAM_APPBIN)/execFlowFunctionObjects
 
diff --git a/applications/utilities/postProcessing/velocityField/divPhi/Make/files b/applications/utilities/postProcessing/velocityField/divPhi/Make/files
index c224d55bcb4..cd54b4a42a0 100644
--- a/applications/utilities/postProcessing/velocityField/divPhi/Make/files
+++ b/applications/utilities/postProcessing/velocityField/divPhi/Make/files
@@ -1,3 +1,3 @@
 calcDivPhi.C
 
-EXE = $(FOAM_USER_APPBIN)/divPhi
+EXE = $(FOAM_APPBIN)/divPhi
diff --git a/applications/utilities/surface/surfaceFeatureExtract/surfaceFeatureExtract.C b/applications/utilities/surface/surfaceFeatureExtract/surfaceFeatureExtract.C
index a48c9fef361..263077329b6 100644
--- a/applications/utilities/surface/surfaceFeatureExtract/surfaceFeatureExtract.C
+++ b/applications/utilities/surface/surfaceFeatureExtract/surfaceFeatureExtract.C
@@ -51,16 +51,15 @@ void dumpBox(const treeBoundBox& bb, const fileName& fName)
 
 
     pointField boxPoints(bb.points());
-    edgeList boxEdges(bb.edges());
 
     forAll(boxPoints, i)
     {
         meshTools::writeOBJ(str, boxPoints[i]);
     }
 
-    forAll(boxEdges, i)
+    forAll(treeBoundBox::edges, i)
     {
-        const edge& e = boxEdges[i];
+        const edge& e = treeBoundBox::edges[i];
 
         str<< "l " << e[0]+1 <<  ' ' << e[1]+1 << nl;
     }
diff --git a/src/Allwmake b/src/Allwmake
index 1a6c80560b8..29dfe503c37 100755
--- a/src/Allwmake
+++ b/src/Allwmake
@@ -1,7 +1,7 @@
 #!/bin/sh
 set -x
 
-#( cd $FOAM_SRC/other && ./Allwmake )
+( cd $FOAM_SRC/other && ./Allwmake )
 
 ( cd $FOAM_SRC/OpenFOAM && wmakeLnInclude . )
 
diff --git a/src/OpenFOAM/meshes/polyMesh/mapPolyMesh/mapDistributePolyMesh/mapDistributeLagrangian.H b/src/OpenFOAM/meshes/polyMesh/mapPolyMesh/mapDistributePolyMesh/mapDistributeLagrangian.H
deleted file mode 100644
index 85192393edd..00000000000
--- a/src/OpenFOAM/meshes/polyMesh/mapPolyMesh/mapDistributePolyMesh/mapDistributeLagrangian.H
+++ /dev/null
@@ -1,161 +0,0 @@
-/*---------------------------------------------------------------------------*\
-  =========                 |
-  \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
-   \\    /   O peration     |
-    \\  /    A nd           | Copyright (C) 1991-2007 OpenCFD Ltd.
-     \\/     M anipulation  |
--------------------------------------------------------------------------------
-License
-    This file is part of OpenFOAM.
-
-    OpenFOAM is free software; you can redistribute it and/or modify it
-    under the terms of the GNU General Public License as published by the
-    Free Software Foundation; either version 2 of the License, or (at your
-    option) any later version.
-
-    OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
-    ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
-    FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
-    for more details.
-
-    You should have received a copy of the GNU General Public License
-    along with OpenFOAM; if not, write to the Free Software Foundation,
-    Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
-
-Class
-    Foam::mapDistributeLagrangian
-
-Description
-    Class containing mesh-to-mesh mapping information for particles
-
-SourceFiles
-    mapDistributeLagrangian.C
-
-\*---------------------------------------------------------------------------*/
-
-#ifndef mapDistributeLagrangian_H
-#define mapDistributeLagrangian_H
-
-#include "mapDistributePolyMesh.H"
-
-// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
-
-namespace Foam
-{
-
-class mapPolyMesh;
-
-/*---------------------------------------------------------------------------*\
-                           Class mapDistributeLagrangian Declaration
-\*---------------------------------------------------------------------------*/
-
-class mapDistributeLagrangian
-{
-    // Private data
-
-        const label nNewParticles_;
-
-        //- Maps from subsetted mesh back to original mesh
-        const labelListList subParticleMap_;
-
-        //- Maps from subsetted mesh to new reconstructed mesh
-        const labelListList constructParticleMap_;
-
-        //- Per element in subsetted mesh the cell label
-        const labelListList constructCellLabels_;
-
-
-public:
-
-    // Constructors
-
-        //- Construct from components
-        mapDistributeLagrangian
-        (
-            const label nNewParticles,
-            const labelListList& subParticleMap,
-            const labelListList& constructParticleMap,
-            const labelListList& constructCellLabels
-        )
-        :
-            nNewParticles_(nNewParticles),
-            subParticleMap_(subParticleMap),
-            constructParticleMap_(constructParticleMap),
-            constructCellLabels_(constructCellLabels)
-        {}
-
-        //- Construct from components and steal storage
-        mapDistributeLagrangian
-        (
-            const label nNewParticles,
-            labelListList& subParticleMap,
-            labelListList& constructParticleMap,
-            labelListList& constructCellLabels,
-            const bool reUse
-        )
-        :
-            nNewParticles_(nNewParticles),
-            subParticleMap_(subParticleMap, reUse),
-            constructParticleMap_(constructParticleMap, reUse),
-            constructCellLabels_(constructCellLabels, reUse)
-        {}
-
-
-    // Member Functions
-
-        // Access
-
-            //- From subsetted lagrangian particles back to original particles
-            const labelListList& subParticleMap() const
-            {
-                return subParticleMap_;
-            }
-
-            //- From received particles to new reconstructed particles
-            const labelListList& constructParticleMap() const
-            {
-                return constructParticleMap_;
-            }
-
-            //- Per received particle the destination cell label
-            const labelListList& constructCellLabels() const
-            {
-                return constructCellLabels_;
-            }
-
-
-        // Edit
-
-            //- distribute list of lagrangian data
-            template<class T>
-            void distributeLagrangianData(List<T>& lst) const
-            {
-                mapDistributePolyMesh::distribute
-                (
-                    nNewParticles_,
-                    subParticleMap(),
-                    constructParticleMap(),
-                    lst
-                );
-            }
-
-            //- Correct for topo change.
-            void updateMesh(const mapPolyMesh&)
-            {
-                notImplemented
-                (
-                    "mapDistributeLagrangian::updateMesh(const mapPolyMesh&)"
-                );
-            }
-};
-
-
-// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
-
-} // End namespace Foam
-
-// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
-
-#endif
-
-// ************************************************************************* //
diff --git a/src/OpenFOAM/meshes/polyMesh/mapPolyMesh/mapDistributePolyMesh/mapDistributePolyMesh.C b/src/OpenFOAM/meshes/polyMesh/mapPolyMesh/mapDistributePolyMesh/mapDistributePolyMesh.C
deleted file mode 100644
index 39c06ea2955..00000000000
--- a/src/OpenFOAM/meshes/polyMesh/mapPolyMesh/mapDistributePolyMesh/mapDistributePolyMesh.C
+++ /dev/null
@@ -1,246 +0,0 @@
-/*---------------------------------------------------------------------------*\
-  =========                 |
-  \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
-   \\    /   O peration     |
-    \\  /    A nd           | Copyright (C) 1991-2007 OpenCFD Ltd.
-     \\/     M anipulation  |
--------------------------------------------------------------------------------
-License
-    This file is part of OpenFOAM.
-
-    OpenFOAM is free software; you can redistribute it and/or modify it
-    under the terms of the GNU General Public License as published by the
-    Free Software Foundation; either version 2 of the License, or (at your
-    option) any later version.
-
-    OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
-    ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
-    FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
-    for more details.
-
-    You should have received a copy of the GNU General Public License
-    along with OpenFOAM; if not, write to the Free Software Foundation,
-    Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
-
-\*---------------------------------------------------------------------------*/
-
-#include "ListOps.H"
-#include "mapDistributePolyMesh.H"
-
-
-// * * * * * * * * * * * * * Private Member Functions  * * * * * * * * * * * //
-
-void Foam::mapDistributePolyMesh::calcPatchSizes()
-{
-    oldPatchSizes_.setSize(oldPatchStarts_.size());
-
-    // Calculate old patch sizes
-    for (label patchI = 0; patchI < oldPatchStarts_.size() - 1; patchI++)
-    {
-        oldPatchSizes_[patchI] =
-            oldPatchStarts_[patchI + 1] - oldPatchStarts_[patchI];
-    }
-
-    // Set the last one by hand
-    const label lastPatchID = oldPatchStarts_.size() - 1;
-
-    oldPatchSizes_[lastPatchID] = nOldFaces_ - oldPatchStarts_[lastPatchID];
-
-    if (min(oldPatchSizes_) < 0)
-    {
-        FatalErrorIn("mapDistributePolyMesh::calcPatchSizes()")
-            << "Calculated negative old patch size:" << oldPatchSizes_ << nl
-            << "Error in mapping data" << abort(FatalError);
-    }
-}
-
-
-// * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
-
-//- Construct from components
-Foam::mapDistributePolyMesh::mapDistributePolyMesh
-(
-    const polyMesh& mesh,
-
-    // mesh before changes
-    const label nOldPoints,
-    const label nOldFaces,
-    const label nOldCells,
-    const labelList& oldPatchStarts,
-    const labelList& oldPatchNMeshPoints,
-
-    // how to subset pieces of mesh to send across
-    const labelListList& subPointMap,
-    const labelListList& subFaceMap,
-    const labelListList& subCellMap,
-    const labelListList& subPatchMap,
-
-    // how to reconstruct received mesh
-    const labelListList& constructPointMap,
-    const labelListList& constructFaceMap,
-    const labelListList& constructCellMap,
-    const labelListList& constructPatchMap
-)
-:
-    mesh_(mesh),
-    nOldPoints_(nOldPoints),
-    nOldFaces_(nOldFaces),
-    nOldCells_(nOldCells),
-    oldPatchSizes_(oldPatchStarts.size()),
-    oldPatchStarts_(oldPatchStarts),
-    oldPatchNMeshPoints_(oldPatchNMeshPoints),
-    subPointMap_(subPointMap),
-    subFaceMap_(subFaceMap),
-    subCellMap_(subCellMap),
-    subPatchMap_(subPatchMap),
-    constructPointMap_(constructPointMap),
-    constructFaceMap_(constructFaceMap),
-    constructCellMap_(constructCellMap),
-    constructPatchMap_(constructPatchMap)
-{
-    calcPatchSizes();
-}
-
-
-//- (optionally destructively) construct from components
-Foam::mapDistributePolyMesh::mapDistributePolyMesh
-(
-    const polyMesh& mesh,
-    const label nOldPoints,
-    const label nOldFaces,
-    const label nOldCells,
-    labelList& oldPatchStarts,
-    labelList& oldPatchNMeshPoints,
-
-    labelListList& subPointMap,
-    labelListList& subFaceMap,
-    labelListList& subCellMap,
-    labelListList& subPatchMap,
-    labelListList& constructPointMap,
-    labelListList& constructFaceMap,
-    labelListList& constructCellMap,
-    labelListList& constructPatchMap,
-    const bool reUse                // clone or reuse
-)
-:
-    mesh_(mesh),
-    nOldPoints_(nOldPoints),
-    nOldFaces_(nOldFaces),
-    nOldCells_(nOldCells),
-    oldPatchSizes_(oldPatchStarts.size()),
-    oldPatchStarts_(oldPatchStarts, reUse),
-    oldPatchNMeshPoints_(oldPatchNMeshPoints, reUse),
-    subPointMap_(subPointMap, reUse),
-    subFaceMap_(subFaceMap, reUse),
-    subCellMap_(subCellMap, reUse),
-    subPatchMap_(subPatchMap, reUse),
-    constructPointMap_(constructPointMap, reUse),
-    constructFaceMap_(constructFaceMap, reUse),
-    constructCellMap_(constructCellMap, reUse),
-    constructPatchMap_(constructPatchMap, reUse)
-{
-    calcPatchSizes();
-}
-
-
-// * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
-
-void Foam::mapDistributePolyMesh::distributePointIndices(labelList& lst)
- const
-{
-    // Construct boolList from selected elements
-    boolList isSelected
-    (
-        createWithValues<boolList>
-        (
-            nOldPoints(),
-            false,
-            lst,
-            true
-        )
-    );
-
-    // Distribute
-    distributePointData(isSelected);
-
-    // Collect selected elements
-    lst = findIndices(isSelected, true);
-}
-
-
-void Foam::mapDistributePolyMesh::distributeFaceIndices(labelList& lst)
- const
-{
-    // Construct boolList from selected elements
-    boolList isSelected
-    (
-        createWithValues<boolList>
-        (
-            nOldFaces(),
-            false,
-            lst,
-            true
-        )
-    );
-
-    // Distribute
-    distributeFaceData(isSelected);
-
-    // Collect selected elements
-    lst = findIndices(isSelected, true);
-}
-
-
-void Foam::mapDistributePolyMesh::distributeCellIndices(labelList& lst)
- const
-{
-    // Construct boolList from selected elements
-    boolList isSelected
-    (
-        createWithValues<boolList>
-        (
-            nOldCells(),
-            false,
-            lst,
-            true
-        )
-    );
-
-    // Distribute
-    distributeCellData(isSelected);
-
-    // Collect selected elements
-    lst = findIndices(isSelected, true);
-}
-
-
-void Foam::mapDistributePolyMesh::distributePatchIndices(labelList& lst)
- const
-{
-    // Construct boolList from selected elements
-    boolList isSelected
-    (
-        createWithValues<boolList>
-        (
-            oldPatchStarts().size(),    // nOldPatches
-            false,
-            lst,
-            true
-        )
-    );
-
-    // Distribute
-    distributePatchData(isSelected);
-
-    // Collect selected elements
-    lst = findIndices(isSelected, true);
-}
-
-
-// * * * * * * * * * * * * * * * Friend Functions  * * * * * * * * * * * * * //
-
-
-// * * * * * * * * * * * * * * * Friend Operators  * * * * * * * * * * * * * //
-
-
-// ************************************************************************* //
diff --git a/src/OpenFOAM/meshes/polyMesh/mapPolyMesh/mapDistributePolyMesh/mapDistributePolyMesh.H b/src/OpenFOAM/meshes/polyMesh/mapPolyMesh/mapDistributePolyMesh/mapDistributePolyMesh.H
deleted file mode 100644
index 6930bd5111c..00000000000
--- a/src/OpenFOAM/meshes/polyMesh/mapPolyMesh/mapDistributePolyMesh/mapDistributePolyMesh.H
+++ /dev/null
@@ -1,335 +0,0 @@
-/*---------------------------------------------------------------------------*\
-  =========                 |
-  \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
-   \\    /   O peration     |
-    \\  /    A nd           | Copyright (C) 1991-2007 OpenCFD Ltd.
-     \\/     M anipulation  |
--------------------------------------------------------------------------------
-License
-    This file is part of OpenFOAM.
-
-    OpenFOAM is free software; you can redistribute it and/or modify it
-    under the terms of the GNU General Public License as published by the
-    Free Software Foundation; either version 2 of the License, or (at your
-    option) any later version.
-
-    OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
-    ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
-    FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
-    for more details.
-
-    You should have received a copy of the GNU General Public License
-    along with OpenFOAM; if not, write to the Free Software Foundation,
-    Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
-
-Class
-    Foam::mapDistributePolyMesh
-
-Description
-    Class containing mesh-to-mesh mapping information after a mesh distribution
-    where we send parts of meshes (using subsetting) to other processors 
-    and receive and reconstruct mesh.
-
-    We store mapping from the bits-to-send to the complete starting mesh
-    (subXXXMap) and from the received bits to their location in the new
-    mesh (constructXXXMap).
-
-SourceFiles
-    mapDistributePolyMesh.C
-
-\*---------------------------------------------------------------------------*/
-
-#ifndef mapDistributePolyMesh_H
-#define mapDistributePolyMesh_H
-
-#include "labelList.H"
-#include "polyMesh.H"
-
-// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
-
-namespace Foam
-{
-
-class mapPolyMesh;
-
-/*---------------------------------------------------------------------------*\
-                           Class mapDistributePolyMesh Declaration
-\*---------------------------------------------------------------------------*/
-
-class mapDistributePolyMesh
-{
-    // Private data
-
-        const polyMesh& mesh_;
-
-        //- Number of old live points
-        const label nOldPoints_;
-
-        //- Number of old live faces
-        const label nOldFaces_;
-
-        //- Number of old live cells
-        const label nOldCells_;
-
-        //- List of the old patch sizes
-        labelList oldPatchSizes_;
-
-        //- List of the old patch start labels
-        const labelList oldPatchStarts_;
-
-        //- List of numbers of mesh points per old patch
-        const labelList oldPatchNMeshPoints_;
-
-        //- Maps from subsetted mesh back to original mesh
-        const labelListList subPointMap_;
-        const labelListList subFaceMap_;
-        const labelListList subCellMap_;
-        const labelListList subPatchMap_;
-
-        //- Maps from subsetted mesh to new reconstructed mesh
-        const labelListList constructPointMap_;
-        const labelListList constructFaceMap_;
-        const labelListList constructCellMap_;
-        const labelListList constructPatchMap_;
-
-    // Private Member Functions
-
-        void calcPatchSizes();
-
-
-public:
-
-    // Constructors
-
-        //- Construct from components
-        mapDistributePolyMesh
-        (
-            const polyMesh& mesh,
-
-            // mesh before changes
-            const label nOldPoints,
-            const label nOldFaces,
-            const label nOldCells,
-            const labelList& oldPatchStarts,
-            const labelList& oldPatchNMeshPoints,
-
-            // how to subset pieces of mesh to send across
-            const labelListList& subPointMap,
-            const labelListList& subFaceMap,
-            const labelListList& subCellMap,
-            const labelListList& subPatchMap,
-
-            // how to reconstruct received mesh
-            const labelListList& constructPointMap,
-            const labelListList& constructFaceMap,
-            const labelListList& constructCellMap,
-            const labelListList& constructPatchMap
-        );
-
-        //- (optionally destructively) construct from components
-        mapDistributePolyMesh
-        (
-            const polyMesh& mesh,
-            const label nOldPoints,
-            const label nOldFaces,
-            const label nOldCells,
-            labelList& oldPatchStarts,
-            labelList& oldPatchNMeshPoints,
-
-            labelListList& subPointMap,
-            labelListList& subFaceMap,
-            labelListList& subCellMap,
-            labelListList& subPatchMap,
-            labelListList& constructPointMap,
-            labelListList& constructFaceMap,
-            labelListList& constructCellMap,
-            labelListList& constructPatchMap,
-            const bool reUse                // clone or reuse
-        );
-
-
-    // Member Functions
-
-        // Access
-
-            const polyMesh& mesh() const
-            {
-                return mesh_;
-            }
-
-            //- Number of points in mesh before distribution
-            label nOldPoints() const
-            {
-                return nOldPoints_;
-            }
-
-            //- Number of faces in mesh before distribution
-            label nOldFaces() const
-            {
-                return nOldFaces_;
-            }
-
-            //- Number of cells in mesh before distribution
-            label nOldCells() const
-            {
-                return nOldCells_;
-            }
-
-            //- List of the old patch sizes
-            const labelList& oldPatchSizes() const
-            {
-                return oldPatchSizes_;
-            }
-
-            //- List of the old patch start labels
-            const labelList& oldPatchStarts() const
-            {
-                return oldPatchStarts_;
-            }
-
-            //- List of numbers of mesh points per old patch
-            const labelList& oldPatchNMeshPoints() const
-            {
-                return oldPatchNMeshPoints_;
-            }
-
-            //- From subsetted mesh back to original mesh
-            //  (these are like the maps in fvMeshSubset)
-            const labelListList& subPointMap() const
-            {
-                return subPointMap_;
-            }
-            //- From subsetted mesh back to original mesh
-            const labelListList& subFaceMap() const
-            {
-                return subFaceMap_;
-            }
-            //- From subsetted mesh back to original mesh
-            const labelListList& subCellMap() const
-            {
-                return subCellMap_;
-            }
-            //- From subsetted mesh back to original mesh
-            const labelListList& subPatchMap() const
-            {
-                return subPatchMap_;
-            }
-
-            //- From subsetted mesh to new reconstructed mesh
-            //  (like the pointProcAddressing in reconstructPar)
-            const labelListList& constructPointMap() const
-            {
-                return constructPointMap_;
-            }
-            //- From subsetted mesh to new reconstructed mesh
-            const labelListList& constructFaceMap() const
-            {
-                return constructFaceMap_;
-            }
-            //- From subsetted mesh to new reconstructed mesh
-            const labelListList& constructCellMap() const
-            {
-                return constructCellMap_;
-            }
-            //- From subsetted mesh to new reconstructed mesh
-            const labelListList& constructPatchMap() const
-            {
-                return constructPatchMap_;
-            }
-
-        // Edit
-
-            //- Helper function: distribute list data
-            template<class T>
-            static void distribute
-            (
-                const label newSize,
-                const labelListList& subMap,        // from subset to original
-                const labelListList& constructMap,  // from subset to new
-                List<T>&
-            );
-
-            //- distribute list of point data
-            template<class T>
-            void distributePointData(List<T>& lst) const
-            {
-                distribute
-                (
-                    mesh_.nPoints(),
-                    subPointMap(),
-                    constructPointMap(),
-                    lst
-                );
-            }
-            //- distribute list of face data
-            template<class T>
-            void distributeFaceData(List<T>& lst) const
-            {
-                distribute
-                (
-                    mesh_.nFaces(),
-                    subFaceMap(),
-                    constructFaceMap(),
-                    lst
-                );
-            }
-            //- distribute list of cell data
-            template<class T>
-            void distributeCellData(List<T>& lst) const
-            {
-                distribute
-                (
-                    mesh_.nCells(),
-                    subCellMap(),
-                    constructCellMap(),
-                    lst
-                );
-            }
-            //- distribute list of patch data
-            template<class T>
-            void distributePatchData(List<T>& lst) const
-            {
-                distribute
-                (
-                    mesh_.boundaryMesh().size(),
-                    subPatchMap(),
-                    constructPatchMap(),
-                    lst
-                );
-            }
-
-
-            //- distribute list of point/face/cell/patch indices.
-            //  (Converts to boolList, distributes boolList and reconstructs)
-            void distributePointIndices(labelList& pointIDs) const;
-            void distributeFaceIndices(labelList& faceIDs) const;
-            void distributeCellIndices(labelList& cellIDs) const;
-            void distributePatchIndices(labelList& patchIDs) const;
-
-
-            //- Correct for topo change.
-            void updateMesh(const mapPolyMesh&)
-            {
-                notImplemented
-                (
-                    "mapDistributePolyMesh::updateMesh(const mapPolyMesh&)"
-                );
-            }
-};
-
-
-// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
-
-} // End namespace Foam
-
-// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
-
-#ifdef NoRepository
-#   include "mapDistributePolyMeshTemplates.C"
-#endif
-
-// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
-
-#endif
-
-// ************************************************************************* //
diff --git a/src/OpenFOAM/meshes/polyMesh/mapPolyMesh/mapDistributePolyMesh/mapDistributePolyMeshTemplates.C b/src/OpenFOAM/meshes/polyMesh/mapPolyMesh/mapDistributePolyMesh/mapDistributePolyMeshTemplates.C
deleted file mode 100644
index ace494d6d94..00000000000
--- a/src/OpenFOAM/meshes/polyMesh/mapPolyMesh/mapDistributePolyMesh/mapDistributePolyMeshTemplates.C
+++ /dev/null
@@ -1,83 +0,0 @@
-/*---------------------------------------------------------------------------*\
-  =========                 |
-  \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
-   \\    /   O peration     |
-    \\  /    A nd           | Copyright (C) 1991-2007 OpenCFD Ltd.
-     \\/     M anipulation  |
--------------------------------------------------------------------------------
-License
-    This file is part of OpenFOAM.
-
-    OpenFOAM is free software; you can redistribute it and/or modify it
-    under the terms of the GNU General Public License as published by the
-    Free Software Foundation; either version 2 of the License, or (at your
-    option) any later version.
-
-    OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
-    ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
-    FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
-    for more details.
-
-    You should have received a copy of the GNU General Public License
-    along with OpenFOAM; if not, write to the Free Software Foundation,
-    Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
-
-\*---------------------------------------------------------------------------*/
-
-
-// * * * * * * * * * * * * * Private Member Functions  * * * * * * * * * * * //
-
-// Distribute list.
-template<class T>
-void Foam::mapDistributePolyMesh::distribute
-(
-    const label newSize,
-    const labelListList& subMap,        // from subset to original
-    const labelListList& constructMap,  // from subset to new
-    List<T>& field
-)
-{
-    // Send sub field to neighbour
-    for (label domain = 0; domain < Pstream::nProcs(); domain++)
-    {
-        if (domain != Pstream::myProcNo())
-        {
-            OPstream toNbr(Pstream::blocking, domain);
-            toNbr << IndirectList<T>(field, subMap[domain])();
-        }
-    }
-
-    // Subset myself
-    List<T> subField(IndirectList<T>(field, subMap[Pstream::myProcNo()]));
-
-    // Receive sub field from myself (subField)
-    field.setSize(newSize);
-
-    const labelList& map = constructMap[Pstream::myProcNo()];
-
-    forAll(map, i)
-    {
-        field[map[i]] = subField[i];
-    }
-
-
-    // Receive sub field from neighbour
-    for (label domain = 0; domain < Pstream::nProcs(); domain++)
-    {
-        if (domain != Pstream::myProcNo())
-        {
-            IPstream fromNbr(Pstream::blocking, domain);
-            List<T> subField(fromNbr);
-
-            const labelList& map = constructMap[domain];
-
-            forAll(map, i)
-            {
-                field[map[i]] = subField[i];
-            }
-        }
-    }
-}
-
-
-// ************************************************************************* //
diff --git a/src/OpenFOAM/meshes/primitiveMesh/PrimitivePatch/PrimitivePatchProjectPoints.C b/src/OpenFOAM/meshes/primitiveMesh/PrimitivePatch/PrimitivePatchProjectPoints.C
index f30e3089a4e..387768bf6b7 100644
--- a/src/OpenFOAM/meshes/primitiveMesh/PrimitivePatch/PrimitivePatchProjectPoints.C
+++ b/src/OpenFOAM/meshes/primitiveMesh/PrimitivePatch/PrimitivePatchProjectPoints.C
@@ -86,7 +86,7 @@ projectPoints
 
     const ToPatch& masterFaces = targetPatch;
 
-    const typename ToPatch::PointFieldType& masterPoints = targetPatch.points();
+    const Field<PointType>& masterPoints = targetPatch.points();
 
     // Estimate face centre of target side
     Field<PointType> masterFaceCentres(targetPatch.size());
diff --git a/src/dynamicMesh/polyTopoChange/polyTopoChange/refinementHistory.C b/src/dynamicMesh/polyTopoChange/polyTopoChange/refinementHistory.C
index 04fb36ddcc1..c1885350041 100644
--- a/src/dynamicMesh/polyTopoChange/polyTopoChange/refinementHistory.C
+++ b/src/dynamicMesh/polyTopoChange/polyTopoChange/refinementHistory.C
@@ -29,6 +29,7 @@ License
 #include "ListOps.H"
 #include "mapPolyMesh.H"
 #include "mapDistributePolyMesh.H"
+#include "polyMesh.H"
 
 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
 
@@ -663,9 +664,11 @@ void Foam::refinementHistory::distribute(const mapDistributePolyMesh& map)
     // Per visible cell the processor it goes to.
     labelList destination(visibleCells_.size());
 
-    forAll(map.subCellMap(), procI)
+    const labelListList& subCellMap = map.cellMap().subMap();
+
+    forAll(subCellMap, procI)
     {
-        const labelList& newToOld = map.subCellMap()[procI];
+        const labelList& newToOld = subCellMap[procI];
 
         forAll(newToOld, i)
         {
@@ -792,7 +795,7 @@ Pout<< "refinementHistory::distribute :"
         }
 
 
-        const labelList& subMap = map.subCellMap()[procI];
+        const labelList& subMap = subCellMap[procI];
 
         // New visible cells.
         labelList newVisibleCells(subMap.size(), -1);
@@ -873,7 +876,7 @@ Pout<< "refinementHistory::distribute :"
 
 
         // Combine visibleCell.
-        const labelList& constructMap = map.constructCellMap()[procI];
+        const labelList& constructMap = map.cellMap().constructMap()[procI];
 
         forAll(newVisibleCells, i)
         {
diff --git a/src/fvMotionSolver/fvMotionSolvers/fvMotionSolver/fvMotionSolver.C b/src/fvMotionSolver/fvMotionSolvers/fvMotionSolver/fvMotionSolver.C
index c1aa4b6031f..83535606e45 100644
--- a/src/fvMotionSolver/fvMotionSolvers/fvMotionSolver/fvMotionSolver.C
+++ b/src/fvMotionSolver/fvMotionSolvers/fvMotionSolver/fvMotionSolver.C
@@ -62,7 +62,7 @@ void Foam::fvMotionSolver::movePoints(const pointField& p)
 
 void Foam::fvMotionSolver::updateMesh(const mapPolyMesh& mpm)
 {
-    motionSolver::updateMesh();
+    motionSolver::updateMesh(mpm);
     pointMesh_.updateMesh(mpm);
     vpi_.updateMesh();
 }
diff --git a/src/meshTools/Make/files b/src/meshTools/Make/files
index fee0bed5db1..e9a79be0b5b 100644
--- a/src/meshTools/Make/files
+++ b/src/meshTools/Make/files
@@ -47,6 +47,10 @@ octree/treeLeafName.C
 octree/pointIndexHitIOList.C
 
 indexedOctree/indexedOctreeName.C
+indexedOctree/treeDataCell.C
+indexedOctree/treeDataEdge.C
+indexedOctree/treeDataFace.C
+indexedOctree/treeDataPoint.C
 indexedOctree/treeDataTriSurface.C
 
 topoSets = sets/topoSets
diff --git a/src/meshTools/cellClassification/cellClassification.C b/src/meshTools/cellClassification/cellClassification.C
index e116b254255..1b9fe0ec7fa 100644
--- a/src/meshTools/cellClassification/cellClassification.C
+++ b/src/meshTools/cellClassification/cellClassification.C
@@ -28,8 +28,8 @@ Description
 
 #include "cellClassification.H"
 #include "triSurfaceSearch.H"
-#include "octree.H"
-#include "octreeDataTriSurface.H"
+#include "indexedOctree.H"
+#include "treeDataFace.H"
 #include "meshSearch.H"
 #include "cellInfo.H"
 #include "polyMesh.H"
@@ -141,11 +141,9 @@ Foam::boolList Foam::cellClassification::markFaces
         }
     }
 
-    octreeDataFace shapes(mesh_, allFaces);
-
     if (debug)
     {
-        Pout<< "Testing " << shapes.size() << " faces for piercing by surface"
+        Pout<< "Testing " << allFaceI << " faces for piercing by surface"
             << endl;
     }
 
@@ -164,13 +162,13 @@ Foam::boolList Foam::cellClassification::markFaces
     bbMax.y() += 2*tol;
     bbMax.z() += 2*tol;
 
-    octree<octreeDataFace> faceTree
+    indexedOctree<treeDataFace> faceTree
     (
+        treeDataFace(false, mesh_, allFaces),
         allBb,      // overall search domain
-        shapes,     // all information needed to do checks on faces
-        1,          // min levels
-        20.0,       // maximum ratio of cubes v.s. faces
-        10.0
+        8,      // maxLevel
+        10,     // leafsize
+        3.0     // duplicity
     );
 
     const triSurface& surf = search.surface();
@@ -210,7 +208,7 @@ Foam::boolList Foam::cellClassification::markFaces
             }
             else
             {
-                label faceI = shapes.meshFaces()[pHit.index()];
+                label faceI = faceTree.shapes().faceLabels()[pHit.index()];
 
                 if (!cutFace[faceI])
                 {
diff --git a/src/meshTools/indexedOctree/indexedOctree.C b/src/meshTools/indexedOctree/indexedOctree.C
index 7d12b934e2e..69b77e91d1b 100644
--- a/src/meshTools/indexedOctree/indexedOctree.C
+++ b/src/meshTools/indexedOctree/indexedOctree.C
@@ -915,14 +915,9 @@ void indexedOctree<Type>::traverseNode
         {
             faceID = 0;
 
-            //WarningIn("indexedOctree<Type>::traverseNode")
-            FatalErrorIn("indexedOctree<Type>::traverseNode")
-                << "Did not hit side of node box " << subBb
             WarningIn("indexedOctree<Type>::traverseNode")
                 << "Did not hit side of box " << subBb
                 << " with ray from " << start << " to " << end
-                //<< endl;
-                << abort(FatalError);
                 << endl;
         }
         else
@@ -938,14 +933,9 @@ void indexedOctree<Type>::traverseNode
         {
             faceID = 0;
 
-            //WarningIn("indexedOctree<Type>::traverseNode")
-            FatalErrorIn("indexedOctree<Type>::traverseNode")
-                << "Did not hit side of content box " << subBb
             WarningIn("indexedOctree<Type>::traverseNode")
                 << "Did not hit side of box " << subBb
                 << " with ray from " << start << " to " << end
-                //<< endl;
-                << abort(FatalError);
                 << endl;
         }
         else
diff --git a/src/meshTools/indexedOctree/treeDataFace.H b/src/meshTools/indexedOctree/treeDataFace.H
index 60d12df3fcf..b8f751e1f6c 100644
--- a/src/meshTools/indexedOctree/treeDataFace.H
+++ b/src/meshTools/indexedOctree/treeDataFace.H
@@ -97,7 +97,7 @@ public:
 
     // Constructors
 
-        //- Construct from mesh and subset of cells.
+        //- Construct from mesh and subset of faces.
         treeDataFace
         (
             const bool cacheBb,
diff --git a/src/meshTools/triSurface/booleanOps/surfaceIntersection/edgeIntersections.C b/src/meshTools/triSurface/booleanOps/surfaceIntersection/edgeIntersections.C
index 3ebd776aa1f..2988798fb96 100644
--- a/src/meshTools/triSurface/booleanOps/surfaceIntersection/edgeIntersections.C
+++ b/src/meshTools/triSurface/booleanOps/surfaceIntersection/edgeIntersections.C
@@ -34,8 +34,8 @@ Description
 #include "labelHashSet.H"
 #include "triSurface.H"
 #include "pointIndexHit.H"
-#include "octreeDataTriSurface.H"
-#include "octree.H"
+#include "treeDataTriSurface.H"
+#include "indexedOctree.H"
 #include "meshTools.H"
 #include "plane.H"
 #include "Random.H"
@@ -120,7 +120,7 @@ void Foam::edgeIntersections::intersectEdges
     }
 
     // Construct octree.
-    const octree<octreeDataTriSurface>& tree = querySurf2.tree();
+    const indexedOctree<treeDataTriSurface>& tree = querySurf2.tree();
 
 
     label nHits = 0;
diff --git a/src/meshTools/triSurface/triSurfaceSearch/triSurfaceSearch.H b/src/meshTools/triSurface/triSurfaceSearch/triSurfaceSearch.H
index 12c703d55e2..50421f0a4a3 100644
--- a/src/meshTools/triSurface/triSurfaceSearch/triSurfaceSearch.H
+++ b/src/meshTools/triSurface/triSurfaceSearch/triSurfaceSearch.H
@@ -40,7 +40,8 @@ SourceFiles
 #include "pointField.H"
 #include "boolList.H"
 #include "pointIndexHit.H"
-#include "treeBoundBox.H"
+#include "indexedOctree.H"
+#include "treeDataTriSurface.H"
 
 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
 
diff --git a/src/triSurface/triSurface/triSurfaceMesh.H b/src/triSurface/triSurface/triSurfaceMesh.H
deleted file mode 100644
index e4b07b8ec09..00000000000
--- a/src/triSurface/triSurface/triSurfaceMesh.H
+++ /dev/null
@@ -1,91 +0,0 @@
-/*---------------------------------------------------------------------------*\
-  =========                 |
-  \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
-   \\    /   O peration     |
-    \\  /    A nd           | Copyright (C) 1991-2007 OpenCFD Ltd.
-     \\/     M anipulation  |
--------------------------------------------------------------------------------
-License
-    This file is part of OpenFOAM.
-
-    OpenFOAM is free software; you can redistribute it and/or modify it
-    under the terms of the GNU General Public License as published by the
-    Free Software Foundation; either version 2 of the License, or (at your
-    option) any later version.
-
-    OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
-    ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
-    FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
-    for more details.
-
-    You should have received a copy of the GNU General Public License
-    along with OpenFOAM; if not, write to the Free Software Foundation,
-    Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
-
-Class
-    Foam::triSurfaceMesh
-
-Description
-    A triSurface with objectRegistry so it can hold fields.
-
-SourceFiles
-    triSurfaceMesh.C
-
-\*---------------------------------------------------------------------------*/
-
-#ifndef triSurfaceMesh_H
-#define triSurfaceMesh_H
-
-#include "triSurface.H"
-#include "objectRegistry.H"
-
-// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
-
-namespace Foam
-{
-
-/*---------------------------------------------------------------------------*\
-                           Class triSurfaceMesh Declaration
-\*---------------------------------------------------------------------------*/
-
-class triSurfaceMesh
-:
-    public objectRegistry,
-    public triSurface
-{
-
-public:
-
-    // Constructors
-
-        //- Construct from triangles, patches, points.
-        triSurfaceMesh
-        (
-            const IOobject& io,
-            const List<labelledTri>& faces,
-            const geometricSurfacePatchList& patches,
-            const pointField& points
-        )
-        :
-            objectRegistry(io),
-            triSurface(faces, patches, points)
-        {}
-
-        //- Construct from file name (uses extension to determine type)
-        triSurfaceMesh(const IOobject& io, const fileName& fName)
-        :
-            objectRegistry(io),
-            triSurface(fName)
-        {}
-};
-
-
-// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
-
-} // End namespace Foam
-
-// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
-
-#endif
-
-// ************************************************************************* //
-- 
GitLab