From e9edc12df5c2e3c8b05dcc7f9755c0911bc90d1c Mon Sep 17 00:00:00 2001 From: Ralf Hartmann Date: Sat, 12 Mar 2005 19:22:39 +0000 Subject: [PATCH] Replace ugliest code sequence of 12 assertions of hard-coded geometry information by a single (almost) geometry independent assertion. git-svn-id: https://svn.dealii.org/trunk@10115 0785d39b-7218-0410-832d-ea1e28bc413d --- deal.II/deal.II/source/grid/tria.cc | 94 ++++++++++++++++------------- 1 file changed, 52 insertions(+), 42 deletions(-) diff --git a/deal.II/deal.II/source/grid/tria.cc b/deal.II/deal.II/source/grid/tria.cc index 4ed613b386..af33c7d9d6 100644 --- a/deal.II/deal.II/source/grid/tria.cc +++ b/deal.II/deal.II/source/grid/tria.cc @@ -1093,53 +1093,63 @@ Triangulation<3>::create_triangulation (const std::vector > &v, for (unsigned int quad=0; quad::faces_per_cell; ++quad) adjacent_cells[face_iterator[quad]->index()].push_back (cell); - +#ifdef DEBUG // make some checks on the // lines and their // ordering; if the lines // are right, so are the // vertices - // TODO: simplify this - Assert (face_iterator[0]->line(face_orientation[0] ? 0 : 3) == - face_iterator[2]->line(face_orientation[2] ? 0 : 3), - ExcInternalErrorOnCell(c)); - Assert (face_iterator[0]->line(face_orientation[0] ? 1 : 2) == - face_iterator[3]->line(face_orientation[3] ? 3 : 0), - ExcInternalErrorOnCell(c)); - Assert (face_iterator[0]->line(face_orientation[0] ? 2 : 1) == - face_iterator[4]->line(face_orientation[4] ? 0 : 3), - ExcInternalErrorOnCell(c)); - Assert (face_iterator[0]->line(face_orientation[0] ? 3 : 0) == - face_iterator[5]->line(face_orientation[5] ? 3 : 0), - ExcInternalErrorOnCell(c)); - - Assert (face_iterator[1]->line(face_orientation[1] ? 0 : 3) == - face_iterator[2]->line(face_orientation[2] ? 2 : 1), - ExcInternalErrorOnCell(c)); - Assert (face_iterator[1]->line(face_orientation[1] ? 1 : 2) == - face_iterator[3]->line(face_orientation[3] ? 1 : 2), - ExcInternalErrorOnCell(c)); - Assert (face_iterator[1]->line(face_orientation[1] ? 2 : 1) == - face_iterator[4]->line(face_orientation[4] ? 2 : 1), - ExcInternalErrorOnCell(c)); - Assert (face_iterator[1]->line(face_orientation[1] ? 3 : 0) == - face_iterator[5]->line(face_orientation[5] ? 1 : 2), - ExcInternalErrorOnCell(c)); - - Assert (face_iterator[2]->line(face_orientation[2] ? 1 : 2) == - face_iterator[3]->line(face_orientation[3] ? 0 : 3), - ExcInternalErrorOnCell(c)); - Assert (face_iterator[3]->line(face_orientation[3] ? 2 : 1) == - face_iterator[4]->line(face_orientation[4] ? 1 : 2), - ExcInternalErrorOnCell(c)); - Assert (face_iterator[4]->line(face_orientation[4] ? 3 : 0) == - face_iterator[5]->line(face_orientation[5] ? 2 : 1), - ExcInternalErrorOnCell(c)); - Assert (face_iterator[5]->line(face_orientation[5] ? 0 : 3) == - face_iterator[2]->line(face_orientation[2] ? 3 : 0), - ExcInternalErrorOnCell(c)); - }; - }; + + // first map all cell lines + // to the two face lines + // which should + // coincide. all face lines + // are included with a cell + // line number (0-11) + // key. At the end all keys + // will be included twice + // (for each of the two + // coinciding lines once) + std::multimap > + cell_to_face_lines; + for (unsigned int face=0; face::faces_per_cell; ++face) + for (unsigned int line=0; line::lines_per_face; ++line) + cell_to_face_lines.insert( + std::pair > ( + GeometryInfo::face_to_cell_lines(face,line), + std::pair (face,line))); + std::multimap >::const_iterator + map_iter=cell_to_face_lines.begin(); + + for (; map_iter!=cell_to_face_lines.end(); ++map_iter) + { + const unsigned int cell_line=map_iter->first; + const unsigned int face1=map_iter->second.first; + const unsigned int line1=map_iter->second.second; + ++map_iter; + Assert(map_iter!=cell_to_face_lines.end(), ExcInternalErrorOnCell(c)); + Assert(map_iter->first==cell_line, ExcInternalErrorOnCell(c)); + const unsigned int face2=map_iter->second.first; + const unsigned int line2=map_iter->second.second; + + // check that the pair + // of lines really + // coincide. Take care + // about the face + // orientation; note, + // that line_no in + // standard face + // orientation is + // 3-line_no in + // non-standard face + // orientation + Assert (face_iterator[face1]->line(face_orientation[face1] ? line1 : 3-line1) == + face_iterator[face2]->line(face_orientation[face2] ? line2 : 3-line2), + ExcInternalErrorOnCell(c)); + } +#endif + } + } ///////////////////////////////////////// -- 2.39.5