From ca5865993401cb01bb1ecfd057f3c88ac1cb6124 Mon Sep 17 00:00:00 2001 From: bangerth Date: Tue, 7 Dec 2010 19:16:55 +0000 Subject: [PATCH] Fix another failure caused by assuming that the left neighbor of the right neighbor is the current cell. git-svn-id: https://svn.dealii.org/trunk@22938 0785d39b-7218-0410-832d-ea1e28bc413d --- deal.II/include/deal.II/grid/tria_accessor.h | 9 +-- .../deal.II/grid/tria_accessor.templates.h | 3 +- deal.II/source/grid/tria.cc | 14 ++-- deal.II/source/grid/tria_accessor.cc | 1 - tests/codim_one/extract_boundary_mesh_06.cc | 65 +++++++++++++++++++ .../extract_boundary_mesh_06/cmp/generic | 33 ++++++++++ 6 files changed, 112 insertions(+), 13 deletions(-) create mode 100644 tests/codim_one/extract_boundary_mesh_06.cc create mode 100644 tests/codim_one/extract_boundary_mesh_06/cmp/generic diff --git a/deal.II/include/deal.II/grid/tria_accessor.h b/deal.II/include/deal.II/grid/tria_accessor.h index b47a171b48..b1cce904c9 100644 --- a/deal.II/include/deal.II/grid/tria_accessor.h +++ b/deal.II/include/deal.II/grid/tria_accessor.h @@ -2161,10 +2161,11 @@ class CellAccessor : public TriaAccessor * 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; diff --git a/deal.II/include/deal.II/grid/tria_accessor.templates.h b/deal.II/include/deal.II/grid/tria_accessor.templates.h index 6b95623667..b979367bea 100644 --- a/deal.II/include/deal.II/grid/tria_accessor.templates.h +++ b/deal.II/include/deal.II/grid/tria_accessor.templates.h @@ -2445,8 +2445,7 @@ CellAccessor::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: diff --git a/deal.II/source/grid/tria.cc b/deal.II/source/grid/tria.cc index 21ac85c0fc..8cf4b63d0b 100644 --- a/deal.II/source/grid/tria.cc +++ b/deal.II/source/grid/tria.cc @@ -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::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); } } } diff --git a/deal.II/source/grid/tria_accessor.cc b/deal.II/source/grid/tria_accessor.cc index 00b028184c..4fd0c88c7c 100644 --- a/deal.II/source/grid/tria_accessor.cc +++ b/deal.II/source/grid/tria_accessor.cc @@ -1349,7 +1349,6 @@ unsigned int CellAccessor::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 index 0000000000..f88f023b44 --- /dev/null +++ b/tests/codim_one/extract_boundary_mesh_06.cc @@ -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 +#include +#include +#include +#include + +using namespace std; + + +void test () +{ + const unsigned int spacedim = 2; + const unsigned int dim = spacedim-1; + + Triangulation boundary_mesh; + map::cell_iterator,Triangulation::face_iterator > + surface_to_volume_mapping; + Triangulation 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::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 index 0000000000..92242b7633 --- /dev/null +++ b/tests/codim_one/extract_boundary_mesh_06/cmp/generic @@ -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 -- 2.39.5