]> https://gitweb.dealii.org/ - dealii-svn.git/commitdiff
Fix another failure caused by assuming that the left neighbor of the right neighbor...
authorbangerth <bangerth@0785d39b-7218-0410-832d-ea1e28bc413d>
Tue, 7 Dec 2010 19:16:55 +0000 (19:16 +0000)
committerbangerth <bangerth@0785d39b-7218-0410-832d-ea1e28bc413d>
Tue, 7 Dec 2010 19:16:55 +0000 (19:16 +0000)
git-svn-id: https://svn.dealii.org/trunk@22938 0785d39b-7218-0410-832d-ea1e28bc413d

deal.II/include/deal.II/grid/tria_accessor.h
deal.II/include/deal.II/grid/tria_accessor.templates.h
deal.II/source/grid/tria.cc
deal.II/source/grid/tria_accessor.cc
tests/codim_one/extract_boundary_mesh_06.cc [new file with mode: 0644]
tests/codim_one/extract_boundary_mesh_06/cmp/generic [new file with mode: 0644]

index b47a171b4828686b6fbd79f954d83e5947b923de..b1cce904c960c75f13dd02fe718d7e9e86ed84b2 100644 (file)
@@ -2161,10 +2161,11 @@ class CellAccessor :  public TriaAccessor<dim,dim,spacedim>
                                      * Return the (global) index of the
                                      * @p ith face of this cell.
                                      *
-                                     * This function is not
-                                     * implemented in 1D, and maps to
-                                     * line_index in 2D and quad_index
-                                     * in 3D.
+                                     * This function returns the
+                                     * vertex_index() of the adjacent
+                                     * vertex in 1D, and maps to
+                                     * line_index() in 2D and
+                                     * quad_index() in 3D.
                                      */
     unsigned int
     face_index (const unsigned int i) const;
index 6b95623667b2f7264d1ca8f0cf2a0e06b4f2d749..b979367bea4bdf4b4fe6229d8865156d4df1190f 100644 (file)
@@ -2445,8 +2445,7 @@ CellAccessor<dim,spacedim>::face_index (const unsigned int i) const
     {
       case 1:
       {
-       Assert (false, ExcImpossibleInDim(1));
-       return numbers::invalid_unsigned_int;
+       return this->vertex_index(i);
       }
 
       case 2:
index 21ac85c0fc75465a16b69677dccbb15d95c06d33..8cf4b63d0be3d9be52dba5f13737c05942a4dbfd 100644 (file)
@@ -4408,7 +4408,8 @@ namespace internal
                                                             // set neighbor to
                                                             // cell on same
                                                             // level
-                           first_child->set_neighbor (0, cell->neighbor(0)->child(1));
+                           const unsigned int nbnb = cell->neighbor_of_neighbor (0);
+                           first_child->set_neighbor (0, cell->neighbor(0)->child(nbnb));
 
                                                             // reset neighbor
                                                             // info of all
@@ -4419,8 +4420,8 @@ namespace internal
                              left_neighbor = cell->neighbor(0);
                            while (left_neighbor->has_children())
                              {
-                               left_neighbor = left_neighbor->child(1);
-                               left_neighbor->set_neighbor (1, first_child);
+                               left_neighbor = left_neighbor->child(nbnb);
+                               left_neighbor->set_neighbor (nbnb, first_child);
                              }
                          }
 
@@ -4446,14 +4447,15 @@ namespace internal
                                                           // refined same as
                                                           // above
                          {
-                           second_child->set_neighbor (1, cell->neighbor(1)->child(0));
+                           const unsigned int nbnb = cell->neighbor_of_neighbor (1);
+                           second_child->set_neighbor (1, cell->neighbor(1)->child(nbnb));
 
                            typename Triangulation<dim,spacedim>::cell_iterator
                              right_neighbor = cell->neighbor(1);
                            while (right_neighbor->has_children())
                              {
-                               right_neighbor = right_neighbor->child(0);
-                               right_neighbor->set_neighbor (0, second_child);
+                               right_neighbor = right_neighbor->child(nbnb);
+                               right_neighbor->set_neighbor (nbnb, second_child);
                              }
                          }
                    }
index 00b028184c5f3dddd097f350628ac2a2627be6ac..4fd0c88c7ca757f7976f189fc49abea3d634147f 100644 (file)
@@ -1349,7 +1349,6 @@ unsigned int CellAccessor<dim,spacedim>::neighbor_of_neighbor_internal (const un
                                   // cases. look up this relationship
                                   // in the table provided by
                                   // GeometryInfo and try it
-
   const unsigned int this_face_index=face_index(neighbor);
 
   const unsigned int neighbor_guess
diff --git a/tests/codim_one/extract_boundary_mesh_06.cc b/tests/codim_one/extract_boundary_mesh_06.cc
new file mode 100644 (file)
index 0000000..f88f023
--- /dev/null
@@ -0,0 +1,65 @@
+//----------------------------  extract_boundary_mesh_06.cc  ---------------------------
+//    $Id: bem.cc 22693 2010-11-11 20:11:47Z kanschat $
+//    Version: $Name$
+//
+//    Copyright (C) 2010 by the deal.II authors
+//
+//    This file is subject to QPL and may not be  distributed
+//    without copyright and license information. Please refer
+//    to the file deal.II/doc/license.html for the  text  and
+//    further information on this license.
+//
+//----------------------------  extract_boundary_mesh_06.cc  ---------------------------
+
+// another failure that had to do that in the library we assumed that
+// the left neighbor of the right neighbor of a cell is the cell
+// itself. this holds true if dim==spacedim, but not
+// otherwise. falsely making this assumption led to a strange failure
+// in refine_global().
+
+#include "../tests.h"
+
+#include <grid/tria.h>
+#include <grid/grid_generator.h>
+#include <grid/tria_boundary_lib.h>
+#include <grid/grid_out.h>
+#include <grid/grid_tools.h>
+
+using namespace std;
+
+
+void test ()
+{
+  const unsigned int spacedim = 2;
+  const unsigned int dim = spacedim-1;
+
+  Triangulation<dim,spacedim> boundary_mesh;
+  map<Triangulation<dim,spacedim>::cell_iterator,Triangulation<spacedim,spacedim>::face_iterator >
+    surface_to_volume_mapping;
+  Triangulation<spacedim> volume_mesh;
+  GridGenerator::hyper_cube(volume_mesh);
+  volume_mesh.refine_global(1);
+  GridTools::extract_boundary_mesh (volume_mesh, boundary_mesh,
+                                   surface_to_volume_mapping);
+  boundary_mesh.refine_global(1);
+
+  for (Triangulation<dim,spacedim>::active_cell_iterator
+        cell = boundary_mesh.begin_active();
+       cell != boundary_mesh.end(); ++cell)
+    {
+      deallog << "Cell=" << cell << std::endl;
+      deallog << "   neighbors: " << cell->neighbor(0) << ' ' << cell->neighbor(1)
+             << std::endl;
+    }
+}
+
+
+
+int main ()
+{
+  ofstream logfile("extract_boundary_mesh_06/output");
+  deallog.attach(logfile);
+  deallog.depth_console(0);
+
+  test ();
+ }
diff --git a/tests/codim_one/extract_boundary_mesh_06/cmp/generic b/tests/codim_one/extract_boundary_mesh_06/cmp/generic
new file mode 100644 (file)
index 0000000..92242b7
--- /dev/null
@@ -0,0 +1,33 @@
+
+DEAL::Cell=2.0
+DEAL::   neighbors: 2.8 2.1
+DEAL::Cell=2.1
+DEAL::   neighbors: 2.0 2.2
+DEAL::Cell=2.2
+DEAL::   neighbors: 2.1 2.3
+DEAL::Cell=2.3
+DEAL::   neighbors: 2.2 2.12
+DEAL::Cell=2.4
+DEAL::   neighbors: 2.11 2.5
+DEAL::Cell=2.5
+DEAL::   neighbors: 2.4 2.6
+DEAL::Cell=2.6
+DEAL::   neighbors: 2.5 2.7
+DEAL::Cell=2.7
+DEAL::   neighbors: 2.6 2.15
+DEAL::Cell=2.8
+DEAL::   neighbors: 2.0 2.9
+DEAL::Cell=2.9
+DEAL::   neighbors: 2.8 2.10
+DEAL::Cell=2.10
+DEAL::   neighbors: 2.9 2.11
+DEAL::Cell=2.11
+DEAL::   neighbors: 2.10 2.4
+DEAL::Cell=2.12
+DEAL::   neighbors: 2.3 2.13
+DEAL::Cell=2.13
+DEAL::   neighbors: 2.12 2.14
+DEAL::Cell=2.14
+DEAL::   neighbors: 2.13 2.15
+DEAL::Cell=2.15
+DEAL::   neighbors: 2.14 2.7

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.