]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Overload perpare_coarsening_and_refinement for the periodic case
authorMartin Kronbichler <kronbichler@lnm.mw.tum.de>
Wed, 27 Jan 2016 17:41:16 +0000 (18:41 +0100)
committerMartin Kronbichler <kronbichler@lnm.mw.tum.de>
Thu, 28 Jan 2016 08:08:21 +0000 (09:08 +0100)
include/deal.II/distributed/tria.h
include/deal.II/grid/tria.h
source/distributed/tria.cc
tests/mpi/distribute_mg_dofs_periodicity_02.mpirun=7.output

index 4e4184d4e62fe1103ab9c151c6df47cf5982846d..7d5a97a8247f10549c34d71d346a05408e1716d7 100644 (file)
@@ -501,6 +501,14 @@ namespace parallel
        */
       virtual void execute_coarsening_and_refinement ();
 
+      /**
+       * Override the implementation of prepare_coarsening_and_refinement from
+       * the base class. This is necessary if periodic boundaries are enabled
+       * and the level difference over vertices over the periodic boundary
+       * must be not more than 2:1.
+       */
+      virtual bool prepare_coarsening_and_refinement ();
+
       /**
        * Manually repartition the active cells between processors. Normally
        * this repartitioning will happen automatically when calling
index d243cf37d96ac014eb590d6a138f7d677b47df8e..89a1016540dcd9d4adc47e057a7c5aa0671188f3 100644 (file)
@@ -1897,7 +1897,7 @@ public:
    * This function uses the user flags, so store them if you still need them
    * afterwards.
    */
-  bool prepare_coarsening_and_refinement ();
+  virtual bool prepare_coarsening_and_refinement ();
 
   /*
    * @}
index fe6b63bd7ac947a0d3e7785ff37dfc73a724228a..f025a845496ecf3062218dac172926690bdd0811 100644 (file)
@@ -3192,21 +3192,26 @@ namespace parallel
       }
 
       template <int dim, int spacedim>
-      void enforce_mesh_balance_over_periodic_boundaries
+      bool enforce_mesh_balance_over_periodic_boundaries
       (Triangulation<dim,spacedim> &tria,
        std::vector<GridTools::PeriodicFacePair<typename dealii::Triangulation<dim,spacedim>::cell_iterator> > periodic_face_pairs_level_0)
       {
         if (periodic_face_pairs_level_0.empty())
-          return;
+          return false;
+
+        std::vector<bool> flags_before[2];
+        tria.save_coarsen_flags (flags_before[0]);
+        tria.save_refine_flags (flags_before[1]);
 
         std::vector<unsigned int> topological_vertex_numbering(tria.n_vertices());
         for (unsigned int i=0; i<topological_vertex_numbering.size(); ++i)
           topological_vertex_numbering[i] = i;
         for (unsigned int i=0; i<periodic_face_pairs_level_0.size(); ++i)
           {
-          identify_periodic_vertices_recursively(periodic_face_pairs_level_0[i],
-                                                 topological_vertex_numbering);
+            identify_periodic_vertices_recursively(periodic_face_pairs_level_0[i],
+                                                   topological_vertex_numbering);
           }
+
         // this code is replicated from grid/tria.cc but using an indirection
         // for periodic boundary conditions
         bool continue_iterating = true;
@@ -3316,11 +3321,43 @@ namespace parallel
                       cell->child(child)->clear_coarsen_flag();
               }
           }
+        std::vector<bool> flags_after[2];
+        tria.save_coarsen_flags (flags_after[0]);
+        tria.save_refine_flags (flags_after[1]);
+        return ((flags_before[0] != flags_after[0]) ||
+                (flags_before[1] != flags_after[1]));
       }
     }
 
 
 
+    template <int dim, int spacedim>
+    bool
+    Triangulation<dim,spacedim>::prepare_coarsening_and_refinement()
+    {
+      std::vector<bool> flags_before[2];
+      this->save_coarsen_flags (flags_before[0]);
+      this->save_refine_flags (flags_before[1]);
+
+      do
+        {
+          this->dealii::Triangulation<dim,spacedim>::prepare_coarsening_and_refinement();
+        }
+      // enforce 2:1 mesh balance over periodic boundaries
+      while ((this->smooth_grid & dealii::Triangulation<dim,spacedim>::limit_level_difference_at_vertices)
+             &&
+             enforce_mesh_balance_over_periodic_boundaries(*this,
+                                                           periodic_face_pairs_level_0));
+
+      std::vector<bool> flags_after[2];
+      this->save_coarsen_flags (flags_after[0]);
+      this->save_refine_flags (flags_after[1]);
+      return ((flags_before[0] != flags_after[0]) ||
+              (flags_before[1] != flags_after[1]));
+    }
+
+
+
     template <int dim, int spacedim>
     void
     Triangulation<dim,spacedim>::copy_local_forest_to_triangulation ()
@@ -3471,11 +3508,6 @@ namespace parallel
           // fix all the flags to make sure we have a consistent mesh
           this->prepare_coarsening_and_refinement ();
 
-          // enforce 2:1 mesh balance over periodic boundaries
-          if (this->smooth_grid & dealii::Triangulation<dim,spacedim>::limit_level_difference_at_vertices)
-            enforce_mesh_balance_over_periodic_boundaries(*this,
-                                                          periodic_face_pairs_level_0);
-
           // see if any flags are still set
           mesh_changed = false;
           for (typename Triangulation<dim,spacedim>::active_cell_iterator
index b74e1dedec18e20442586453a19a0abb59a121e1..eed327ead052a566d5319a127bd48b5fc82ee854 100644 (file)
@@ -50,6 +50,10 @@ DEAL:1::6_1:0 4294967294
 DEAL:1::6_1:1 4294967294
 DEAL:1::6_1:2 4
 DEAL:1::6_1:3 4
+DEAL:1::8_1:0 4294967294
+DEAL:1::8_1:1 4294967294
+DEAL:1::8_1:2 4294967294
+DEAL:1::8_1:3 4294967294
 DEAL:1::0_2:00 4294967294
 DEAL:1::0_2:01 0
 DEAL:1::0_2:02 0

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.