]> https://gitweb.dealii.org/ - dealii-svn.git/commitdiff
Modify GridReordering: Instead of throwing an Assertion, return the original connecti...
authorleicht <leicht@0785d39b-7218-0410-832d-ea1e28bc413d>
Fri, 9 Feb 2007 06:52:36 +0000 (06:52 +0000)
committerleicht <leicht@0785d39b-7218-0410-832d-ea1e28bc413d>
Fri, 9 Feb 2007 06:52:36 +0000 (06:52 +0000)
git-svn-id: https://svn.dealii.org/trunk@14443 0785d39b-7218-0410-832d-ea1e28bc413d

deal.II/deal.II/include/grid/grid_reordering.h
deal.II/deal.II/include/grid/grid_reordering_internal.h
deal.II/deal.II/source/grid/grid_reordering.cc

index 79407be8895905f0aff6fd0b9175b267ef7812f9..77f2ca91c953692b757eb88184eab3d81814ff60 100644 (file)
@@ -24,10 +24,11 @@ DEAL_II_NAMESPACE_OPEN
 
 
 /**
- * This class reorders the vertices of cells such that they meet the
- * requirements of the Triangulation class when creating
- * grids. This class is mainly used when reading in grids from files
- * and converting them to deal.II triangulations.
+ * This class reorders the vertices of cells such that they meet the standard
+ * requirements of the Triangulation class when creating grids, i.e. all lines
+ * have a unique orientation with respect to all neighboring cells. This class
+ * is mainly used when reading in grids from files and converting them to
+ * deal.II triangulations.
  *
  * Note: In contrast to the rest of the deal.II library this class
  * uses the old deal.II numbering scheme, which was used up to deal.II
@@ -169,8 +170,13 @@ DEAL_II_NAMESPACE_OPEN
  * clockwise, and axially upward. However, if before joining the two
  * ends of the string of cells, the string is twisted by 180 degrees,
  * then no such orientation is possible any more, as can easily be
- * checked. In effect, some meshes cannot be used in deal.II,
- * unfortunately.
+ * checked. In effect, some meshes could not be used in deal.II.
+ * In order to overcome this problem, the <code>face_rotation</code>, 
+ * <code>face_flip</code> and <code>line_orientation</code> flags have
+ * been introduced. With these, it is possible to treat all purely hexahedral
+ * meshes. However, in order to reduce the effect of possible bugs, it should
+ * still be tried to reorder a grid. Only if this procedure fails, the original
+ * connectivity information should be used.
  *
  *
  * <h3>Examples of problems</h3>
@@ -648,6 +654,10 @@ class GridReordering
                                      *  the general documentation of
                                      *  this class for dim=2 and 3
                                      *  and doing nothing for dim=1.
+                                     *
+                                     *  If a consistent reordering is not
+                                     *  possible in dim=3, the original
+                                     *  connectivity data is restored.
                                      */
     static void reorder_cells (std::vector<CellData<dim> > &original_cells);
 
@@ -658,12 +668,12 @@ class GridReordering
                                      * the inverse of the orientation
                                      * required by deal.II.
                                      *
-                                     * In 3d this function checks
+                                     * In 2d and 3d this function checks
                                      * whether all cells have
                                      * negative or positiv
                                      * measure/volume. In the former
                                      * case, all cells are inverted.
-                                     * It does nothing in 1 and 2d.
+                                     * It does nothing in 1d.
                                      *
                                      * The invertion of cells might
                                      * also work when only a subset
index f1321e154831ecc18d4485412e9b953bc9bd908d..54f40cad68cddb8b7bc862df9785fca801bd0d9c 100644 (file)
@@ -710,9 +710,13 @@ namespace internal
                                           * single entry point to the
                                           * functionality of this
                                           * class.
+                                         *
+                                         * Returns, whether a consistent
+                                         * orientation of lines was possible
+                                         * for the given mesh.
                                           */
         static
-        void
+        bool
         orient_mesh (std::vector<CellData<3> > &incubes);
 
       private:
@@ -781,8 +785,11 @@ namespace internal
                                          /**
                                           * Orient all the edges of a
                                           * mesh.
+                                         *
+                                         * Returns, whether this action was
+                                         * carried out successfully.
                                           */
-        void orient_edges ();
+        bool orient_edges ();
 
                                          /**
                                           * Given oriented edges,
index c0620f368ccb42afae83adc2b70cdf18b8696ce7..e0700537f21666d498ec30bec889dab718ea9e83 100644 (file)
@@ -1004,7 +1004,7 @@ namespace internal
 
 
     
-    void Orienter::orient_mesh (std::vector<CellData<3> > &incubes)
+    bool Orienter::orient_mesh (std::vector<CellData<3> > &incubes)
     {
       Orienter orienter (incubes);
       
@@ -1013,7 +1013,11 @@ namespace internal
       orienter.mesh.sanity_check ();
 
                                        // Orient the mesh
-      orienter.orient_edges ();
+
+                                      // if not successful, break here, else go
+                                      // on
+      if (!orienter.orient_edges ())
+       return false;
 
                                        // Now we have a bunch of oriented
                                        // edges int the structure we only
@@ -1025,6 +1029,8 @@ namespace internal
                                        // internal structure back into
                                        // their original location.
       orienter.mesh.export_to_deal_format (incubes);
+                                      // reordering was successful
+      return true;
     }
 
                                     /**
@@ -1033,7 +1039,7 @@ namespace internal
                                      * cube is a rotated Deal.II
                                      * cube.
                                      */
-    void Orienter::orient_edges ()
+    bool Orienter::orient_edges ()
     {
                                       // While there are still cubes
                                       // to orient
@@ -1059,9 +1065,9 @@ namespace internal
                                                  // Cube doesn't
                                                  // have a
                                                  // contradiction
-                AssertThrow(cell_is_consistent(cur_posn),
-                            ExcGridOrientError("Mesh is Unorientable"));
-
+                if (!cell_is_consistent(cur_posn))
+                 return false;
+               
                                                  // If we needed to
                                                  // orient any edges
                                                  // in the current
@@ -1076,7 +1082,8 @@ namespace internal
                                              // (equivalence class
                                              // of edges)
             ++cur_edge_group;
-          }    
+          }
+      return true;
     }
 
 
@@ -1474,9 +1481,21 @@ GridReordering<3>::reorder_cells (std::vector<CellData<3> > &incubes)
 
   Assert (incubes.size() != 0,
          ExcMessage("List of elements to orient was of zero length"));
+
+                                  // create a backup to use if GridReordering
+                                  // was not successful
+  std::vector<CellData<3> > backup=incubes;
   
                                   // This does the real work
-  internal::GridReordering3d::Orienter::orient_mesh (incubes);
+  bool success=
+    internal::GridReordering3d::Orienter::orient_mesh (incubes);
+
+                                  // if reordering was not successful use
+                                  // original connectivity, otherwiese do
+                                  // nothing (i.e. use the reordered
+                                  // connectivity)
+  if (!success)
+    incubes=backup;
 }
 
 

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.