From 80ef6e2392a4d4479dbb9dc6535d33b8293c52c8 Mon Sep 17 00:00:00 2001
From: mattijs <mattijs>
Date: Fri, 20 Dec 2013 16:01:18 +0000
Subject: [PATCH] ENH: hexRef8: test more

---
 applications/test/hexRef8/Test-hexRef8.C      | 148 ++++++++++--------
 .../test/hexRef8/block/system/controlDict     |   9 +-
 2 files changed, 92 insertions(+), 65 deletions(-)

diff --git a/applications/test/hexRef8/Test-hexRef8.C b/applications/test/hexRef8/Test-hexRef8.C
index ed108078095..0e913ff0110 100644
--- a/applications/test/hexRef8/Test-hexRef8.C
+++ b/applications/test/hexRef8/Test-hexRef8.C
@@ -41,6 +41,7 @@ Description
 #include "Random.H"
 #include "zeroGradientFvPatchFields.H"
 #include "calculatedPointPatchFields.H"
+#include "pointConstraints.H"
 #include "fvcDiv.H"
 
 using namespace Foam;
@@ -63,6 +64,8 @@ int main(int argc, char *argv[])
 #   include "createMesh.H"
 
 
+    const pointConstraints& pc = pointConstraints::New(pointMesh::New(mesh));
+
     const Switch inflate(args.args()[1]);
 
     if (inflate)
@@ -188,89 +191,107 @@ int main(int argc, char *argv[])
         }
 
 
+        mesh.moving(false);
+        mesh.topoChanging(false);
 
-        // Mesh changing engine.
-        polyTopoChange meshMod(mesh);
 
-        if (rndGen.bit())
-        {
-            // Refine
-            label nRefine = mesh.nCells()/20;
-            DynamicList<label> refineCandidates(nRefine);
+        label action = rndGen.integer(0, 5);
 
-            for (label i=0; i<nRefine; i++)
-            {
-                refineCandidates.append(rndGen.integer(0, mesh.nCells()-1));
-            }
 
-            labelList cellsToRefine
-            (
-                meshCutter.consistentRefinement
-                (
-                    refineCandidates,
-                    true                  // buffer layer
-                )
-            );
-            Info<< nl << "-- selected "
-                << returnReduce(cellsToRefine.size(), sumOp<label>())
-                << " cells out of " << mesh.globalData().nTotalCells()
-                << " for refinement" << endl;
-
-            // Play refinement commands into mesh changer.
-            meshCutter.setRefinement(cellsToRefine, meshMod);
+        if (action == 0)
+        {
+            Info<< nl << "-- moving only" << endl;
+            mesh.movePoints(pointField(mesh.points()));
         }
-        else
+        else if (action == 1 || action == 2)
         {
-            // Unrefine
-            labelList allSplitPoints(meshCutter.getSplitPoints());
+            // Mesh changing engine.
+            polyTopoChange meshMod(mesh);
 
-            label nUnrefine = allSplitPoints.size()/20;
-            labelHashSet candidates(2*nUnrefine);
+            if (action == 1)
+            {
+                // Refine
+                label nRefine = mesh.nCells()/20;
+                DynamicList<label> refineCandidates(nRefine);
+
+                for (label i=0; i<nRefine; i++)
+                {
+                    refineCandidates.append(rndGen.integer(0, mesh.nCells()-1));
+                }
+
+                labelList cellsToRefine
+                (
+                    meshCutter.consistentRefinement
+                    (
+                        refineCandidates,
+                        true                  // buffer layer
+                    )
+                );
+                Info<< nl << "-- selected "
+                    << returnReduce(cellsToRefine.size(), sumOp<label>())
+                    << " cells out of " << mesh.globalData().nTotalCells()
+                    << " for refinement" << endl;
 
-            for (label i=0; i<nUnrefine; i++)
+                // Play refinement commands into mesh changer.
+                meshCutter.setRefinement(cellsToRefine, meshMod);
+            }
+            else
             {
-                candidates.insert
+                // Unrefine
+                labelList allSplitPoints(meshCutter.getSplitPoints());
+
+                label nUnrefine = allSplitPoints.size()/20;
+                labelHashSet candidates(2*nUnrefine);
+
+                for (label i=0; i<nUnrefine; i++)
+                {
+                    label index = rndGen.integer(0, allSplitPoints.size()-1);
+                    candidates.insert(allSplitPoints[index]);
+                }
+
+                labelList splitPoints = meshCutter.consistentUnrefinement
                 (
-                    allSplitPoints[rndGen.integer(0, allSplitPoints.size()-1)]
+                    candidates.toc(),
+                    false
                 );
+                Info<< nl << "-- selected "
+                    << returnReduce(splitPoints.size(), sumOp<label>())
+                    << " points out of "
+                    << returnReduce(allSplitPoints.size(), sumOp<label>())
+                    << " for unrefinement" << endl;
+
+                // Play refinement commands into mesh changer.
+                meshCutter.setUnrefinement(splitPoints, meshMod);
             }
 
-            labelList splitPoints = meshCutter.consistentUnrefinement
-            (
-                candidates.toc(),
-                false
-            );
-            Info<< nl << "-- selected "
-                << returnReduce(splitPoints.size(), sumOp<label>())
-                << " points out of "
-                << returnReduce(allSplitPoints.size(), sumOp<label>())
-                << " for unrefinement" << endl;
-
-            // Play refinement commands into mesh changer.
-            meshCutter.setUnrefinement(splitPoints, meshMod);
-        }
 
 
 
+            // Create mesh, return map from old to new mesh.
+            Info<< nl << "-- actually changing mesh" << endl;
+            autoPtr<mapPolyMesh> map = meshMod.changeMesh(mesh, inflate);
 
-        // Create mesh, return map from old to new mesh.
-        Info<< nl << "-- actually changing mesh" << endl;
-        autoPtr<mapPolyMesh> map = meshMod.changeMesh(mesh, inflate);
+            // Update fields
+            Info<< nl << "-- mapping mesh data" << endl;
+            mesh.updateMesh(map);
 
-        // Update fields
-        Info<< nl << "-- mapping mesh data" << endl;
-        mesh.updateMesh(map);
+            // Inflate mesh
+            if (map().hasMotionPoints())
+            {
+                Info<< nl << "-- moving mesh" << endl;
+                mesh.movePoints(map().preMotionPoints());
+            }
 
-        // Inflate mesh
-        if (map().hasMotionPoints())
-        {
-            Info<< nl << "-- moving mesh" << endl;
-            mesh.movePoints(map().preMotionPoints());
+            // Update numbering of cells/vertices.
+            Info<< nl << "-- mapping hexRef8 data" << endl;
+            meshCutter.updateMesh(map);
         }
 
-        // Update numbering of cells/vertices.
-        Info<< nl << "-- mapping hexRef8 data" << endl;
-        meshCutter.updateMesh(map);
+
+        Info<< nl<< "-- Mesh : moving:" << mesh.moving()
+            << " topoChanging:" << mesh.topoChanging()
+            << " changing:" << mesh.changing()
+            << endl;
 
 
 
@@ -387,6 +408,9 @@ int main(int argc, char *argv[])
             << nl << endl;
     }
 
+    Info<< "pc:" << pc.patchPatchPointConstraintPoints().size() << endl;
+
+
     Info<< "End\n" << endl;
 
     return 0;
diff --git a/applications/test/hexRef8/block/system/controlDict b/applications/test/hexRef8/block/system/controlDict
index 1ed64adf616..0c8cfee218e 100644
--- a/applications/test/hexRef8/block/system/controlDict
+++ b/applications/test/hexRef8/block/system/controlDict
@@ -17,9 +17,12 @@ FoamFile
 
 DebugSwitches
 {
-    primitiveMesh   1;
-    polyMesh        1;
-    fvMesh          1;
+    primitiveMesh       1;
+    polyMesh            1;
+    fvMesh              1;
+    polyTopoChange      1;
+    pointMesh           1;
+    pointConstraints    1;
 }
 
 application     icoFoam;
-- 
GitLab