]> https://gitweb.dealii.org/ - dealii-svn.git/commitdiff
do something in invert_all_cells_of_negative_grid() also in 2d
authorleicht <leicht@0785d39b-7218-0410-832d-ea1e28bc413d>
Wed, 13 Dec 2006 13:33:14 +0000 (13:33 +0000)
committerleicht <leicht@0785d39b-7218-0410-832d-ea1e28bc413d>
Wed, 13 Dec 2006 13:33:14 +0000 (13:33 +0000)
git-svn-id: https://svn.dealii.org/trunk@14234 0785d39b-7218-0410-832d-ea1e28bc413d

deal.II/deal.II/source/grid/grid_reordering.cc
deal.II/doc/news/changes.html

index 88a39a654c76b37f9d5a8df0fcfefeaac5d03160..c0620f368ccb42afae83adc2b70cdf18b8696ce7 100644 (file)
@@ -588,13 +588,46 @@ GridReordering<2>::reorder_cells (std::vector<CellData<2> > &original_cells)
 
 template<>
 void
-GridReordering<2>::invert_all_cells_of_negative_grid(const std::vector<Point<2> > &,
-                                                    std::vector<CellData<2> > &)
+GridReordering<2>::invert_all_cells_of_negative_grid(const std::vector<Point<2> > &all_vertices,
+                                                    std::vector<CellData<2> >    &cells)
 {
-                                  // nothing to be done in 2d
+  unsigned int vertices_lex[GeometryInfo<2>::vertices_per_cell];
+  unsigned int n_negative_cells=0;
+  for (unsigned int cell_no=0; cell_no<cells.size(); ++cell_no)
+    {
+                                      // GridTools::cell_measure
+                                      // requires the vertices to be
+                                      // in lexicographic ordering
+      for (unsigned int i=0; i<GeometryInfo<2>::vertices_per_cell; ++i)
+       vertices_lex[GeometryInfo<2>::ucd_to_deal[i]]=cells[cell_no].vertices[i];
+      if (GridTools::cell_measure<2>(all_vertices, vertices_lex) < 0)
+       {
+         ++n_negative_cells;
+         std::swap(cells[cell_no].vertices[1], cells[cell_no].vertices[3]);
+         
+                                          // check whether the
+                                          // resulting cell is now ok.
+                                          // if not, then the grid is
+                                          // seriously broken and
+                                          // should be sticked into the
+                                          // bin
+         for (unsigned int i=0; i<GeometryInfo<2>::vertices_per_cell; ++i)
+           vertices_lex[GeometryInfo<2>::ucd_to_deal[i]]=cells[cell_no].vertices[i];
+         AssertThrow(GridTools::cell_measure<2>(all_vertices, vertices_lex) > 0,
+                     ExcInternalError());
+       }
+    }
+  
+                                  // We assume that all cells of a grid have
+                                  // either positive or negative volumes but
+                                  // not both mixed. Although above reordering
+                                  // might work also on single cells, grids
+                                  // with both kind of cells are very likely to
+                                  // be broken. Check for this here.
+  AssertThrow(n_negative_cells==0 || n_negative_cells==cells.size(), ExcInternalError());
 }
 
-#endif
+#endif // deal_II_dimension == 2
 
 
 
@@ -1465,6 +1498,7 @@ GridReordering<3>::invert_all_cells_of_negative_grid(
       if (GridTools::cell_measure<3>(all_vertices, vertices_lex) < 0)
        {
          ++n_negative_cells;
+         // reorder vertices: swap front and back face
          for (unsigned int i=0; i<4; ++i)
            std::swap(cells[cell_no].vertices[i], cells[cell_no].vertices[i+4]);
          
@@ -1481,7 +1515,7 @@ GridReordering<3>::invert_all_cells_of_negative_grid(
        }
     }
   
-                                  // We assuming that all cells of a
+                                  // We assume that all cells of a
                                   // grid have either positive or
                                   // negative volumes but not both
                                   // mixed. Although above reordering
index e564a39fd61d9142ccd4e253fb5fcf4bc151a7c2..19cc56e4c1b59171eed72a5c9c2d366603c5439c 100644 (file)
@@ -928,6 +928,14 @@ inconvenience this causes.
 
 <ol>
 
+  <li> <p> Extended: So far, the
+       <code>GridReordering::invert_all_cells_of_negative_grid</code> function
+       did nothing in 2d. Now, it inverts cells from clockwise to
+       counterclockwise sense (in the old numbering scheme).
+                <br>
+                (Tobias Leicht 2006/12/13)
+       </p>
+
   <li> <p> New: There is now a function
        <code>GridTools::delete_duplicated_vertices</code> that deletes duplicate
        vertices which can occur if structured grids are read into deal, leading

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.