From 85f43a971dc09c0c21a64093270e7b656bf9940f Mon Sep 17 00:00:00 2001 From: Daniel Arndt Date: Mon, 6 Aug 2018 20:11:55 +0200 Subject: [PATCH] Simplify check for boundary ids --- source/grid/grid_generator.cc | 18 +++++++++++++++- source/grid/grid_in.cc | 32 +++++++++++++++++++++------- source/grid/tria.cc | 40 +++++++---------------------------- 3 files changed, 49 insertions(+), 41 deletions(-) diff --git a/source/grid/grid_generator.cc b/source/grid/grid_generator.cc index a8ad44864c..ca0fb5b178 100644 --- a/source/grid/grid_generator.cc +++ b/source/grid/grid_generator.cc @@ -4217,11 +4217,16 @@ namespace GridGenerator if (line->manifold_id() != numbers::flat_manifold_id) { CellData<1> boundary_line; + boundary_line.vertices[0] = line->vertex_index(0) + offset; boundary_line.vertices[1] = line->vertex_index(1) + offset; + boundary_line.manifold_id = line->manifold_id(); + boundary_line.boundary_id = + numbers::internal_face_boundary_id; // default + subcell_data.boundary_lines.push_back( boundary_line); // trivially-copyable } @@ -4260,6 +4265,7 @@ namespace GridGenerator if (face->manifold_id() != numbers::flat_manifold_id) { CellData<2> boundary_quad; + boundary_quad.vertices[0] = face->vertex_index(0) + offset; boundary_quad.vertices[1] = @@ -4270,6 +4276,9 @@ namespace GridGenerator face->vertex_index(3) + offset; boundary_quad.manifold_id = face->manifold_id(); + boundary_quad.boundary_id = + numbers::internal_face_boundary_id; // default + subcell_data.boundary_quads.push_back( boundary_quad); // trivially-copyable } @@ -4279,12 +4288,17 @@ namespace GridGenerator numbers::flat_manifold_id) { CellData<1> boundary_line; + boundary_line.vertices[0] = cell->line(l)->vertex_index(0) + offset; boundary_line.vertices[1] = cell->line(l)->vertex_index(1) + offset; + boundary_line.manifold_id = cell->line(l)->manifold_id(); + boundary_line.boundary_id = + numbers::internal_face_boundary_id; // default + subcell_data.boundary_lines.push_back( boundary_line); // trivially_copyable } @@ -5196,6 +5210,8 @@ namespace GridGenerator (subcell_data.boundary_lines[i].vertices[1] == map_vert_index[face->line(e)->vertex_index(0)]))) { + subcell_data.boundary_lines[i].boundary_id = + numbers::internal_face_boundary_id; edge_found = true; break; } @@ -5208,7 +5224,7 @@ namespace GridGenerator map_vert_index[face->line(e)->vertex_index(0)]; edge.vertices[1] = map_vert_index[face->line(e)->vertex_index(1)]; - edge.boundary_id = numbers::internal_face_boundary_id; + edge.boundary_id = 0; edge.manifold_id = face->line(e)->manifold_id(); subcell_data.boundary_lines.push_back(edge); diff --git a/source/grid/grid_in.cc b/source/grid/grid_in.cc index d6f98790a2..c6f3d5ecfa 100644 --- a/source/grid/grid_in.cc +++ b/source/grid/grid_in.cc @@ -796,11 +796,19 @@ GridIn::read_ucd(std::istream &in, numbers::internal_face_boundary_id)); if (apply_all_indicators_to_manifolds) - subcelldata.boundary_lines.back().manifold_id = - static_cast(material_id); + { + subcelldata.boundary_lines.back().boundary_id = + numbers::internal_face_boundary_id; + subcelldata.boundary_lines.back().manifold_id = + static_cast(material_id); + } else - subcelldata.boundary_lines.back().boundary_id = - static_cast(material_id); + { + subcelldata.boundary_lines.back().boundary_id = + static_cast(material_id); + subcelldata.boundary_lines.back().manifold_id = + numbers::flat_manifold_id; + } // transform from ucd to // consecutive numbering @@ -844,11 +852,19 @@ GridIn::read_ucd(std::istream &in, numbers::internal_face_boundary_id)); if (apply_all_indicators_to_manifolds) - subcelldata.boundary_quads.back().manifold_id = - static_cast(material_id); + { + subcelldata.boundary_quads.back().boundary_id = + numbers::internal_face_boundary_id; + subcelldata.boundary_quads.back().manifold_id = + static_cast(material_id); + } else - subcelldata.boundary_quads.back().boundary_id = - static_cast(material_id); + { + subcelldata.boundary_quads.back().boundary_id = + static_cast(material_id); + subcelldata.boundary_quads.back().manifold_id = + numbers::flat_manifold_id; + } // transform from ucd to // consecutive numbering diff --git a/source/grid/tria.cc b/source/grid/tria.cc index da91e1251f..c4cb44bdd2 100644 --- a/source/grid/tria.cc +++ b/source/grid/tria.cc @@ -2196,40 +2196,16 @@ namespace internal "manifold ids")); line->set_manifold_id(subcell_line.manifold_id); - // Assert that only exterior lines are given a boundary - // indicator; however, it is possible that someone may - // want to give an interior line a manifold id (and thus - // lists this line in the subcell_data structure), and we - // need to allow that + // assert that only exterior lines are given a boundary + // indicator if (subcell_line.boundary_id != numbers::internal_face_boundary_id) { - if (line->boundary_id() == numbers::internal_face_boundary_id) - { - // if we are here, it means that we want to assign a - // boundary indicator different from - // numbers::internal_face_boundary_id to an internal line. - // As said, this would be not allowed, and an exception - // should be immediately thrown. Still, there is the - // possibility that one only wants to specify a manifold_id - // here. If that is the case (manifold_id != - // numbers::flat_manifold_id) the operation is allowed. - // Otherwise, we really tried to specify a boundary_id (and - // not a manifold_id) to an internal face. The exception - // must be thrown. - if (subcell_line.manifold_id == numbers::flat_manifold_id) - { - // If we are here, this assertion will surely fail, for - // the aforementioned reasons - AssertThrow(!(line->boundary_id() == - numbers::internal_face_boundary_id), - ExcInteriorLineCantBeBoundary( - line->vertex_index(0), - line->vertex_index(1), - subcell_line.boundary_id)); - } - } - else - line->set_boundary_id_internal(subcell_line.boundary_id); + AssertThrow( + line->boundary_id() != numbers::internal_face_boundary_id, + ExcInteriorLineCantBeBoundary(line->vertex_index(0), + line->vertex_index(1), + subcell_line.boundary_id)); + line->set_boundary_id_internal(subcell_line.boundary_id); } } -- 2.39.5