From: leicht Date: Fri, 9 Feb 2007 06:52:36 +0000 (+0000) Subject: Modify GridReordering: Instead of throwing an Assertion, return the original connecti... X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=35b9eb831491ac0e156a9fc8d272bbf509f0fd23;p=dealii-svn.git Modify GridReordering: Instead of throwing an Assertion, return the original connectivity if the grid could not be oriented. This is a partial merge from branch_general_meshes. git-svn-id: https://svn.dealii.org/trunk@14443 0785d39b-7218-0410-832d-ea1e28bc413d --- diff --git a/deal.II/deal.II/include/grid/grid_reordering.h b/deal.II/deal.II/include/grid/grid_reordering.h index 79407be889..77f2ca91c9 100644 --- a/deal.II/deal.II/include/grid/grid_reordering.h +++ b/deal.II/deal.II/include/grid/grid_reordering.h @@ -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 face_rotation, + * face_flip and line_orientation 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. * * *

Examples of problems

@@ -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 > &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 diff --git a/deal.II/deal.II/include/grid/grid_reordering_internal.h b/deal.II/deal.II/include/grid/grid_reordering_internal.h index f1321e1548..54f40cad68 100644 --- a/deal.II/deal.II/include/grid/grid_reordering_internal.h +++ b/deal.II/deal.II/include/grid/grid_reordering_internal.h @@ -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 > &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, diff --git a/deal.II/deal.II/source/grid/grid_reordering.cc b/deal.II/deal.II/source/grid/grid_reordering.cc index c0620f368c..e0700537f2 100644 --- a/deal.II/deal.II/source/grid/grid_reordering.cc +++ b/deal.II/deal.II/source/grid/grid_reordering.cc @@ -1004,7 +1004,7 @@ namespace internal - void Orienter::orient_mesh (std::vector > &incubes) + bool Orienter::orient_mesh (std::vector > &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 > &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 > 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; }