From: hartmann Date: Thu, 16 Jun 2005 10:58:38 +0000 (+0000) Subject: child_cell_on_face, face_to_cell_vertices and face_to_cell_lines now include a new... X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=94c5da6ce07368977c0cca63f113ab9d8e72ca2e;p=dealii-svn.git child_cell_on_face, face_to_cell_vertices and face_to_cell_lines now include a new face_orientation argument. This avoids aweful pieces of code including questioning face_orientation and using child_switch_tables. git-svn-id: https://svn.dealii.org/trunk@10871 0785d39b-7218-0410-832d-ea1e28bc413d --- diff --git a/deal.II/deal.II/include/grid/geometry_info.h b/deal.II/deal.II/include/grid/geometry_info.h index 8fe33f278a..3137454388 100644 --- a/deal.II/deal.II/include/grid/geometry_info.h +++ b/deal.II/deal.II/include/grid/geometry_info.h @@ -353,34 +353,20 @@ struct GeometryInfo * the exact order of the * children is laid down in the * documentation of the - * Triangulation class. - * However, it must be noted that - * this class and function only - * deals with faces in standard - * orientation. In 3d, faces can - * exist in two orientations, - * though, and if a face is in - * the wrong orientation, then - * this function may not give you - * what you want. You can inquire - * about the face orientation - * using the - * cell->face_orientation - * function, and the function to - * ask for a neighbor's cell - * behind a given face and - * subface is - * cell->neighbor_child_on_subface. - * The latter function, in - * contrast to the present one, - * also takes into account the - * actual orientation of the - * faces of a cell and will - * return the correct result in - * all cases. + * Triangulation class. Through + * the face_orientation + * argument this function handles + * faces oriented in both, the + * standard and non-standard + * orientation. + * face_orientation + * defaults to true + * (standard orientation) and has + * no effect in 2d. */ static unsigned int child_cell_on_face (const unsigned int face, - const unsigned int subface); + const unsigned int subface, + const bool face_orientation = true); /** * Map line vertex number to cell @@ -416,6 +402,17 @@ struct GeometryInfo * face face, e.g. * GeometryInfo<2>::face_to_cell_vertices(2,0)=3. * + * Through the + * face_orientation + * argument this function handles + * faces oriented in both, the + * standard or non-standard + * orientation. + * face_orientation + * defaults to true + * (standard orientation) and has + * no effect in 2d. + * * As the children of a cell are * ordered according to the * vertices of the cell, this @@ -427,7 +424,8 @@ struct GeometryInfo * a suggestive name. */ static unsigned int face_to_cell_vertices (const unsigned int face, - const unsigned int vertex); + const unsigned int vertex, + const bool face_orientation = true); /** * Map face line number to cell @@ -437,12 +435,23 @@ struct GeometryInfo * face, e.g. * GeometryInfo<3>::face_to_cell_lines(3,1)=5. * + * Through the + * face_orientation + * argument this function handles + * faces oriented in both, the + * standard and non-standard + * orientation. + * face_orientation + * defaults to true + * (standard orientation). + * * This function is useful and * implemented for * dim=3, only. */ static unsigned int face_to_cell_lines (const unsigned int face, - const unsigned int line); + const unsigned int line, + const bool face_orientation = true); /** * Return the position of the diff --git a/deal.II/deal.II/source/fe/mapping_q.cc b/deal.II/deal.II/source/fe/mapping_q.cc index 569f9a4b21..b8b8205a33 100644 --- a/deal.II/deal.II/source/fe/mapping_q.cc +++ b/deal.II/deal.II/source/fe/mapping_q.cc @@ -954,21 +954,6 @@ add_quad_support_points(const Triangulation<3>::cell_iterator &cell, lines_per_face = GeometryInfo<3>::lines_per_face, vertices_per_cell = GeometryInfo<3>::vertices_per_cell; - // mapping of faces to vertex - // indices for properly oriented - // faces is given by - // GeometryInfo<3>::face_to_cell_vertices - // - // same if the face is in opposite - // orientation - static const unsigned int face_to_cell_vertices2 - [faces_per_cell][vertices_per_face]={{0,3,2,1}, - {4,7,6,5}, - {0,4,5,1}, - {1,2,6,5}, - {3,7,6,2}, - {0,3,7,4}}; - static const StraightBoundary<3> straight_boundary; // used if face quad at boundary or // entirely in the interior of the @@ -991,29 +976,17 @@ add_quad_support_points(const Triangulation<3>::cell_iterator &cell, // some sanity checks up front for (unsigned int i=0; ivertex_index(i)== - cell->vertex_index(face_orientation ? - GeometryInfo<3>::face_to_cell_vertices(face_no, i) : - face_to_cell_vertices2[face_no][i]), - ExcInternalError()); - + Assert(face->vertex_index(i)==cell->vertex_index( + GeometryInfo<3>::face_to_cell_vertices(face_no, i, face_orientation)), + ExcInternalError()); // indices of the lines that - // bound a properly oriented - // face are given by - // GeometryInfo<3>:: - // face_to_cell_lines(face_no, line_no) - // - // same for faces in wrong - // orientation is given by + // bound a face are given by // GeometryInfo<3>:: - // face_to_cell_lines(face_no, 3-line_no) + // face_to_cell_lines for (unsigned int i=0; iline(i)== - cell->line(face_orientation ? - GeometryInfo<3>::face_to_cell_lines(face_no, i) : - GeometryInfo<3>::face_to_cell_lines(face_no, 3-i)), - ExcInternalError()); + Assert(face->line(i)==cell->line(GeometryInfo<3>::face_to_cell_lines( + face_no, i, face_orientation)), ExcInternalError()); // if face at boundary, then // ask boundary object to @@ -1064,17 +1037,13 @@ add_quad_support_points(const Triangulation<3>::cell_iterator &cell, // sort the points into b for (unsigned int i=0; i::face_to_cell_vertices(face_no, i) : - face_to_cell_vertices2[face_no][i]]; + b[i]=a[GeometryInfo<3>::face_to_cell_vertices(face_no, i, face_orientation)]; for (unsigned int i=0; i::face_to_cell_lines(face_no, i) : - GeometryInfo<3>::face_to_cell_lines(face_no, 3-i))*(degree-1)+j]; + a[vertices_per_cell + GeometryInfo<3>::face_to_cell_lines( + face_no, i, face_orientation)*(degree-1)+j]; // Now b includes the // right order of diff --git a/deal.II/deal.II/source/grid/geometry_info.cc b/deal.II/deal.II/source/grid/geometry_info.cc index cd6681556e..dc0bb0f12b 100644 --- a/deal.II/deal.II/source/grid/geometry_info.cc +++ b/deal.II/deal.II/source/grid/geometry_info.cc @@ -109,7 +109,8 @@ GeometryInfo<3>::unit_normal_orientation[GeometryInfo<3>::faces_per_cell] template <> unsigned int GeometryInfo<1>::child_cell_on_face (const unsigned int face, - const unsigned int subface) + const unsigned int subface, + const bool) { Assert (face::child_cell_on_face (const unsigned int face, template <> unsigned int GeometryInfo<2>::child_cell_on_face (const unsigned int face, - const unsigned int subface) + const unsigned int subface, + const bool) { Assert (face::child_cell_on_face (const unsigned int face, template <> unsigned int GeometryInfo<3>::child_cell_on_face (const unsigned int face, - const unsigned int subface) + const unsigned int subface, + const bool face_orientation) { Assert (face::subfaces_per_face] = { 0, 3, 2, 1 }; static const unsigned subcells[faces_per_cell][subfaces_per_face] = {{0, 1, 2, 3}, {4, 5, 6, 7}, @@ -152,7 +156,7 @@ GeometryInfo<3>::child_cell_on_face (const unsigned int face, {1, 5, 6, 2}, {3, 2, 6, 7}, {0, 4, 7, 3}}; - return subcells[face][subface]; + return face_orientation ? subcells[face][subface] : subcells[face][flip[subface]]; } @@ -208,7 +212,8 @@ GeometryInfo<3>::line_to_cell_vertices (const unsigned int line, template <> unsigned int GeometryInfo<3>::face_to_cell_lines (const unsigned int face, - const unsigned int line) + const unsigned int line, + const bool face_orientation) { Assert (face::face_to_cell_lines (const unsigned int face, {2,10, 6,11}, {8, 7,11, 3}}; - return lines[face][line]; + return face_orientation ? lines[face][line] : lines[face][3-line]; } @@ -230,9 +235,10 @@ template inline unsigned int GeometryInfo::face_to_cell_vertices (const unsigned int face, - const unsigned int vertex) + const unsigned int vertex, + const bool face_orientation) { - return child_cell_on_face(face, vertex); + return child_cell_on_face(face, vertex, face_orientation); } diff --git a/deal.II/deal.II/source/grid/tria.cc b/deal.II/deal.II/source/grid/tria.cc index 9d44f1e4ac..fa11197603 100644 --- a/deal.II/deal.II/source/grid/tria.cc +++ b/deal.II/deal.II/source/grid/tria.cc @@ -6280,6 +6280,16 @@ Triangulation<3>::execute_refinement () new_hexes[GeometryInfo::child_cell_on_face(f,s)] ->set_face_orientation(f, hex->face_orientation(f)); +#ifdef DEBUG + // check consistency + // against + // GeometryInfo<3>::child_cell_on_face + for (unsigned int f=0; f::faces_per_cell; ++f) + for (unsigned int s=0; s::subfaces_per_face; ++s) + Assert(hex->face(f)->child(s)==hex->child( + GeometryInfo::child_cell_on_face( + f, s, hex->face_orientation(f)))->face(f), ExcInternalError()); +#endif ///////////////////////////////// // now the only thing still @@ -6431,19 +6441,12 @@ Triangulation<3>::execute_refinement () && hex->face_orientation(face)); - static const unsigned int - child_switch_table[GeometryInfo::subfaces_per_face] - = { 0, 3, 2, 1 }; - for (unsigned int c=0; c::subfaces_per_face; ++c) { neighbor_cells[face][c] = neighbor->child(GeometryInfo:: - child_cell_on_face(nb_nb, - orient ? - c : - child_switch_table[c])); + child_cell_on_face(nb_nb, c, orient)); Assert (neighbor_cells[face][c].state() == IteratorState::valid, diff --git a/deal.II/deal.II/source/grid/tria_accessor.cc b/deal.II/deal.II/source/grid/tria_accessor.cc index 99f21db643..40bf7421e7 100644 --- a/deal.II/deal.II/source/grid/tria_accessor.cc +++ b/deal.II/deal.II/source/grid/tria_accessor.cc @@ -2195,11 +2195,8 @@ neighbor_child_on_subface (const unsigned int face, = (this->neighbor(face)->face_orientation(neighbor_neighbor) == this->face_orientation(face)); const unsigned int neighbor_child_index - = (GeometryInfo<3>:: - child_cell_on_face(neighbor_neighbor, - (face_orientations_match ? - subface : - subface_translation[subface]))); + = GeometryInfo<3>::child_cell_on_face(neighbor_neighbor, subface, + face_orientations_match); const TriaIterator<3,CellAccessor<3> > neighbor_child= this->neighbor(face)->child(neighbor_child_index);