]> https://gitweb.dealii.org/ - dealii-svn.git/commitdiff
counter?clockwise renumbering
authorguido <guido@0785d39b-7218-0410-832d-ea1e28bc413d>
Fri, 8 Aug 2003 20:05:47 +0000 (20:05 +0000)
committerguido <guido@0785d39b-7218-0410-832d-ea1e28bc413d>
Fri, 8 Aug 2003 20:05:47 +0000 (20:05 +0000)
must be tested

git-svn-id: https://svn.dealii.org/trunk@7908 0785d39b-7218-0410-832d-ea1e28bc413d

deal.II/deal.II/include/dofs/dof_renumbering.h
deal.II/deal.II/source/dofs/dof_renumbering.cc

index dbff2d8893470266d199f16d5ef0ba0442517d1c..ff86e725f43a61a6f90d32c308249622941a5d2a 100644 (file)
@@ -434,6 +434,19 @@ class DoFRenumbering
     template <int dim>
     static void
     downstream_dg (DoFHandler<dim>  &dof_handler,
+                  const Point<dim> &direction);
+
+                                    /**
+                                     * Cell-wise downstream numbering
+                                     * with respect to a constant
+                                     * flow direction on one
+                                     * level. See the other function
+                                     * with the same name.
+                                     */
+    template <int dim>
+    static void
+    downstream_dg (MGDoFHandler<dim>  &dof_handler,
+                  const unsigned int level,
                   const Point<dim> &direction);
 
                                     /**
@@ -452,18 +465,51 @@ class DoFRenumbering
                           const DoFHandler<dim>  &dof_handler,
                           const Point<dim> &direction);
 
+//TODO:[GK] Documentation!    
                                     /**
-                                     * Cell-wise downstream numbering
-                                     * with respect to a constant
-                                     * flow direction on one
-                                     * level. See the other function
-                                     * with the same name.
+                                     * Cell-wise clockwise numbering.
+                                     *
+                                     * This function produces a
+                                     * clockwise ordering of the
+                                     * mesh cells and calls
+                                     * @ref{cell_wise_dg}.
+                                     * Therefore, it only works with
+                                     * Discontinuous Galerkin Finite
+                                     * Elements, i.e. all degrees of
+                                     * freedom have to be associated
+                                     * with the interior of the cell.
                                      */
     template <int dim>
     static void
-    downstream_dg (MGDoFHandler<dim>  &dof_handler,
+    clockwise_dg (DoFHandler<dim>  &dof_handler,
+                  const Point<dim> &center);
+
+                                    /**
+                                     * Cell-wise clockwise numbering
+                                     * on one level. See the other
+                                     * function with the same name.
+                                     */
+    template <int dim>
+    static void
+    clockwise_dg (MGDoFHandler<dim>  &dof_handler,
                   const unsigned int level,
-                  const Point<dim> &direction);
+                  const Point<dim> &center);
+
+                                    /**
+                                     * Computes the renumbering
+                                     * vector needed by the
+                                     * @p{clockwise_dg}
+                                     * functions. Does not perform the
+                                     * renumbering on the
+                                     * @p{DoFHandler} dofs but
+                                     * returns the renumbering
+                                     * vector.
+                                     */
+    template <int dim>
+    static void
+    compute_clockwise_dg (std::vector<unsigned int>&,
+                          const DoFHandler<dim>  &dof_handler,
+                          const Point<dim> &center);
 
                                     /**
                                      * Sort those degrees of freedom
index c13771225a44105ca2d76bc7b1b42565949374de..719d679d1c91e5c9e65b486f3bdbc255b85b9390 100644 (file)
@@ -973,7 +973,6 @@ DoFRenumbering::compute_downstream_dg (
 }
 
 
-#ifdef ENABLE_MULTIGRID
 template <int dim>
 void DoFRenumbering::downstream_dg (MGDoFHandler<dim>& dof,
                                    const unsigned int level,
@@ -991,7 +990,93 @@ void DoFRenumbering::downstream_dg (MGDoFHandler<dim>& dof,
 
   cell_wise_dg(dof, level, ordered_cells);
 }
-#endif
+
+
+
+/**
+ * Provide comparator for DoFCellAccessors
+ */
+
+template <int dim>
+struct ClockCells
+{
+                                    /**
+                                     * Center of rotation.
+                                     */
+    const Point<dim>& center;
+                                    /**
+                                     * Constructor.
+                                     */
+    ClockCells (const Point<dim>& center) :
+                   center(center) 
+      {}
+                                    /**
+                                     * Return true if c1 < c2.
+                                     */    
+    bool operator () (const typename DoFHandler<dim>::cell_iterator& c1,
+                     const typename DoFHandler<dim>::cell_iterator&c2) const
+      {
+       
+       const Point<dim> v1 = c1->center() - center;
+       const Point<dim> v2 = c2->center() - center;
+       const double s1 = atan2(v1(0), v1(1));
+       const double s2 = atan2(v2(0), v2(1));
+       return (s1>s2);
+      }
+};
+
+
+template <int dim>
+void
+DoFRenumbering::clockwise_dg (DoFHandler<dim>& dof,
+                              const Point<dim>& center)
+{
+  std::vector<unsigned int> renumbering(dof.n_dofs());
+  compute_clockwise_dg(renumbering, dof, center);
+
+  dof.renumber_dofs(renumbering);
+}
+
+
+
+template <int dim>
+void
+DoFRenumbering::compute_clockwise_dg (
+  std::vector<unsigned int>& new_indices,
+  const DoFHandler<dim>& dof,
+  const Point<dim>& center)
+{
+  std::vector<typename DoFHandler<dim>::cell_iterator>
+    ordered_cells(dof.get_tria().n_active_cells());
+  ClockCells<dim> comparator(center);
+  
+  typename DoFHandler<dim>::active_cell_iterator begin = dof.begin_active();
+  typename DoFHandler<dim>::active_cell_iterator end = dof.end();
+  
+  copy (begin, end, ordered_cells.begin());
+  sort (ordered_cells.begin(), ordered_cells.end(), comparator);
+
+  compute_cell_wise_dg(new_indices, dof, ordered_cells);
+}
+
+
+template <int dim>
+void DoFRenumbering::clockwise_dg (MGDoFHandler<dim>& dof,
+                                   const unsigned int level,
+                                   const Point<dim>& center)
+{
+  std::vector<typename MGDoFHandler<dim>::cell_iterator>
+    ordered_cells(dof.get_tria().n_cells(level));
+  ClockCells<dim> comparator(center);
+  
+  typename MGDoFHandler<dim>::cell_iterator begin = dof.begin(level);
+  typename MGDoFHandler<dim>::cell_iterator end = dof.end(level);
+  
+  std::copy (begin, end, ordered_cells.begin());
+  std::sort (ordered_cells.begin(), ordered_cells.end(), comparator);
+
+  cell_wise_dg(dof, level, ordered_cells);
+}
 
 
 
@@ -1088,6 +1173,31 @@ DoFRenumbering::compute_downstream_dg<deal_II_dimension>
  const DoFHandler<deal_II_dimension>&,
  const Point<deal_II_dimension>&);
 
+template
+void DoFRenumbering::downstream_dg<deal_II_dimension>
+(MGDoFHandler<deal_II_dimension>&,
+ const unsigned int,
+ const Point<deal_II_dimension>&);
+
+template
+void
+DoFRenumbering::clockwise_dg<deal_II_dimension>
+(DoFHandler<deal_II_dimension>&,
+ const Point<deal_II_dimension>&);
+
+template
+void
+DoFRenumbering::compute_clockwise_dg<deal_II_dimension>
+(std::vector<unsigned int>&,
+ const DoFHandler<deal_II_dimension>&,
+ const Point<deal_II_dimension>&);
+
+template
+void DoFRenumbering::clockwise_dg<deal_II_dimension>
+(MGDoFHandler<deal_II_dimension>&,
+ const unsigned int,
+ const Point<deal_II_dimension>&);
+
 template
 void DoFRenumbering::sort_selected_dofs_back<deal_II_dimension>
 (DoFHandler<deal_II_dimension> &,
@@ -1110,7 +1220,6 @@ DoFRenumbering::compute_random<deal_II_dimension>
 (std::vector<unsigned int>&,
  const DoFHandler<deal_II_dimension> &);
 
-#ifdef ENABLE_MULTIGRID
 template
 void DoFRenumbering::Cuthill_McKee<deal_II_dimension>
 (MGDoFHandler<deal_II_dimension>&,
@@ -1124,10 +1233,3 @@ void DoFRenumbering::cell_wise_dg<deal_II_dimension>
  const unsigned int,
  const std::vector<MGDoFHandler<deal_II_dimension>::cell_iterator>&);
 
-template
-void DoFRenumbering::downstream_dg<deal_II_dimension>
-(MGDoFHandler<deal_II_dimension>&,
- const unsigned int,
- const Point<deal_II_dimension>&);
-
-#endif

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.