]> https://gitweb.dealii.org/ - dealii.git/commitdiff
run indent and add comments to describe test 2131/head
authorSpencer Patty <srobertp@gmail.com>
Wed, 10 Feb 2016 16:53:21 +0000 (10:53 -0600)
committerSpencer Patty <srobertp@gmail.com>
Wed, 10 Feb 2016 16:53:21 +0000 (10:53 -0600)
tests/grid/get_dof_to_support_patch_map_01.cc

index fee6dd97e3b6418e5541925f1f4c5dc89cffca6d..adf0ca5c5273bb286746d79bc46ab1272616d1b2 100644 (file)
 // ---------------------------------------------------------------------
 
 
-// Test GridTools::map_dof_to_support_patch ()
+// Test GridTools::map_dof_to_support_patch () using a quadratic FE_Q<dim>
+// space.  We output the barycenter of each cell in the patch around the dof
+// for a few dofs in the triangulation.  We have three layers of refinement in
+// the triangulation which represents the various patches that could arise in
+// practice.
 
 
 
@@ -28,7 +32,6 @@
 #include <deal.II/grid/tria_iterator.h>
 #include <deal.II/grid/grid_generator.h>
 #include <deal.II/grid/grid_tools.h>
-
 #include <deal.II/dofs/dof_handler.h>
 
 #include <fstream>
@@ -49,39 +52,41 @@ void test()
   triangulation.refine_global (2);
   {
 
+    // choose barycenters of cells to refine or coarsen to end up with
+    // a three level triangulation.
     std::vector<Point<dim> > refine_centers;
     std::vector<Point<dim> > coarsen_centers;
 
-    if(dim==1)
-    {
-      refine_centers.push_back(Point<dim> (1./8.));
+    if (dim==1)
+      {
+        refine_centers.push_back(Point<dim> (1./8.));
 
-      coarsen_centers.push_back(Point<dim> (5./8.));
-      coarsen_centers.push_back(Point<dim> (7./8.));
-    }
+        coarsen_centers.push_back(Point<dim> (5./8.));
+        coarsen_centers.push_back(Point<dim> (7./8.));
+      }
     else if (dim==2)
-    {
-      refine_centers.push_back(Point<dim> (1./8., 7./8.));
+      {
+        refine_centers.push_back(Point<dim> (1./8., 7./8.));
 
-      coarsen_centers.push_back(Point<dim> (5./8., 5./8.));
-      coarsen_centers.push_back(Point<dim> (5./8., 7./8.));
-      coarsen_centers.push_back(Point<dim> (7./8., 5./8.));
-      coarsen_centers.push_back(Point<dim> (7./8., 7./8.));
+        coarsen_centers.push_back(Point<dim> (5./8., 5./8.));
+        coarsen_centers.push_back(Point<dim> (5./8., 7./8.));
+        coarsen_centers.push_back(Point<dim> (7./8., 5./8.));
+        coarsen_centers.push_back(Point<dim> (7./8., 7./8.));
 
-    }
+      }
     else if (dim==3)
-    {
-      refine_centers.push_back(Point<dim> (1./8., 7./8., 1./8.));
-
-      coarsen_centers.push_back(Point<dim> (7./8., 7./8., 7./8.));
-      coarsen_centers.push_back(Point<dim> (5./8., 7./8., 7./8.));
-      coarsen_centers.push_back(Point<dim> (7./8., 5./8., 7./8.));
-      coarsen_centers.push_back(Point<dim> (5./8., 5./8., 7./8.));
-      coarsen_centers.push_back(Point<dim> (7./8., 7./8., 5./8.));
-      coarsen_centers.push_back(Point<dim> (5./8., 7./8., 5./8.));
-      coarsen_centers.push_back(Point<dim> (7./8., 5./8., 5./8.));
-      coarsen_centers.push_back(Point<dim> (5./8., 5./8., 5./8.));
-    }
+      {
+        refine_centers.push_back(Point<dim> (1./8., 7./8., 1./8.));
+
+        coarsen_centers.push_back(Point<dim> (7./8., 7./8., 7./8.));
+        coarsen_centers.push_back(Point<dim> (5./8., 7./8., 7./8.));
+        coarsen_centers.push_back(Point<dim> (7./8., 5./8., 7./8.));
+        coarsen_centers.push_back(Point<dim> (5./8., 5./8., 7./8.));
+        coarsen_centers.push_back(Point<dim> (7./8., 7./8., 5./8.));
+        coarsen_centers.push_back(Point<dim> (5./8., 7./8., 5./8.));
+        coarsen_centers.push_back(Point<dim> (7./8., 5./8., 5./8.));
+        coarsen_centers.push_back(Point<dim> (5./8., 5./8., 5./8.));
+      }
     else
       Assert(false, ExcNotImplemented() );
 
@@ -90,38 +95,38 @@ void test()
          cell = triangulation.begin_active();
          cell != triangulation.end(); ++cell, ++index)
 
-    {
-      Point<dim> cell_bary = cell->barycenter();
-
-      // refine cells
-      for (unsigned int i=0; i<refine_centers.size(); ++i)
-      {
-        double diff = 0;
-        for (unsigned int d=0; d<dim; ++d)
-          diff += pow(cell_bary[d] - refine_centers[i][d], 2.);
-        diff = std::sqrt(diff);
-
-        if (diff < 1e-14)
-        {
-          cell->set_refine_flag ();
-          break;
-        }
-      }
-      // coarsen cells
-      for (unsigned int i=0; i<coarsen_centers.size(); ++i)
       {
-        double diff = 0;
-        for (unsigned int d=0; d<dim; ++d)
-          diff += pow(cell_bary[d] - coarsen_centers[i][d], 2.);
-        diff = std::sqrt(diff);
-
-        if (diff < 1e-14)
-        {
-          cell->set_coarsen_flag ();
-          break;
-        }
+        Point<dim> cell_bary = cell->barycenter();
+
+        // refine cells
+        for (unsigned int i=0; i<refine_centers.size(); ++i)
+          {
+            double diff = 0;
+            for (unsigned int d=0; d<dim; ++d)
+              diff += pow(cell_bary[d] - refine_centers[i][d], 2.);
+            diff = std::sqrt(diff);
+
+            if (diff < 1e-14)
+              {
+                cell->set_refine_flag ();
+                break;
+              }
+          }
+        // coarsen cells
+        for (unsigned int i=0; i<coarsen_centers.size(); ++i)
+          {
+            double diff = 0;
+            for (unsigned int d=0; d<dim; ++d)
+              diff += pow(cell_bary[d] - coarsen_centers[i][d], 2.);
+            diff = std::sqrt(diff);
+
+            if (diff < 1e-14)
+              {
+                cell->set_coarsen_flag ();
+                break;
+              }
+          }
       }
-    }
     triangulation.execute_coarsening_and_refinement ();
 
   }
@@ -136,28 +141,28 @@ void test()
   dof_to_cell_map = GridTools::get_dof_to_support_patch_map(dof_handler);
 
   for (unsigned int i=0; i<dof_handler.n_dofs(); ++i)
-  {
-    // loop through and print out barycenter of cells in patch of certain dofs
-    // in system
-    if (i % (dim == 1 ? 1 : (dim == 2 ? 5 : 25 )) == 0)
     {
-      deallog << "Patch around dof " << i << ": ";
-      typename std::vector<typename dealii::DoFHandler<dim>::active_cell_iterator>::iterator
-      patch_iter = dof_to_cell_map[i].begin(),
-      patch_iter_end = dof_to_cell_map[i].end();
-      for (; patch_iter != patch_iter_end ; ++patch_iter )
-      {
-        typename dealii::DoFHandler<dim>::active_cell_iterator patch_cell = *(patch_iter);
-        Point<dim> cell_bary = patch_cell->barycenter();
-        deallog << "(" ;
-        for (unsigned int d=0; d<dim-1; ++d)
-          deallog << cell_bary[d] << ", ";
-        deallog << cell_bary[dim-1] << ") ";
-      }
-      deallog << std::endl;
-    }
+      // loop through and print out barycenter of cells in patch of certain dofs
+      // in system
+      if (i % (dim == 1 ? 1 : (dim == 2 ? 5 : 25 )) == 0)
+        {
+          deallog << "Patch around dof " << i << ": ";
+          typename std::vector<typename dealii::DoFHandler<dim>::active_cell_iterator>::iterator
+          patch_iter = dof_to_cell_map[i].begin(),
+          patch_iter_end = dof_to_cell_map[i].end();
+          for (; patch_iter != patch_iter_end ; ++patch_iter )
+            {
+              typename dealii::DoFHandler<dim>::active_cell_iterator patch_cell = *(patch_iter);
+              Point<dim> cell_bary = patch_cell->barycenter();
+              deallog << "(" ;
+              for (unsigned int d=0; d<dim-1; ++d)
+                deallog << cell_bary[d] << ", ";
+              deallog << cell_bary[dim-1] << ") ";
+            }
+          deallog << std::endl;
+        }
 
-  }
+    }
 
 
   // clean up data

In the beginning the Universe was created. This has made a lot of people very angry and has been widely regarded as a bad move.

Douglas Adams


Typeset in Trocchi and Trocchi Bold Sans Serif.