From 2228fa2e5414d6b86a206281bffbfc890b6f4215 Mon Sep 17 00:00:00 2001 From: Peter Munch Date: Fri, 19 Jun 2020 14:33:14 +0200 Subject: [PATCH] Small generialization in tria_description.cc --- source/grid/tria_description.cc | 32 +++++++++++++++++--------------- 1 file changed, 17 insertions(+), 15 deletions(-) diff --git a/source/grid/tria_description.cc b/source/grid/tria_description.cc index b59c2e0b1f..5096a3b4dd 100644 --- a/source/grid/tria_description.cc +++ b/source/grid/tria_description.cc @@ -41,7 +41,10 @@ template bool CellData::operator==(const CellData &other) const { - for (const unsigned int i : GeometryInfo::vertex_indices()) + if (vertices.size() != other.vertices.size()) + return false; + + for (unsigned int i = 0; i < vertices.size(); ++i) if (vertices[i] != other.vertices[i]) return false; @@ -209,7 +212,7 @@ namespace TriangulationDescription TriaIterator> &cell, std::vector &vertices_owned_by_locally_owned_cells) { // add local vertices - for (const unsigned int v : GeometryInfo::vertex_indices()) + for (const auto v : GeometryInfo::vertex_indices()) { vertices_owned_by_locally_owned_cells[cell->vertex_index(v)] = true; @@ -273,7 +276,7 @@ namespace TriangulationDescription // owned cell) auto is_locally_relevant_on_level = [&](TriaIterator> &cell) { - for (const unsigned int v : GeometryInfo::vertex_indices()) + for (const auto v : GeometryInfo::vertex_indices()) if (vertices_owned_by_locally_owned_cells_on_level [cell->vertex_index(v)]) return true; @@ -297,15 +300,16 @@ namespace TriangulationDescription continue; // extract cell definition (with old numbering of vertices) - dealii::CellData cell_data; + dealii::CellData cell_data( + GeometryInfo::vertices_per_cell); cell_data.material_id = cell->material_id(); cell_data.manifold_id = cell->manifold_id(); - for (const unsigned int v : GeometryInfo::vertex_indices()) + for (const auto v : GeometryInfo::vertex_indices()) cell_data.vertices[v] = cell->vertex_index(v); construction_data.coarse_cells.push_back(cell_data); // save indices of each vertex of this cell - for (const unsigned int v : GeometryInfo::vertex_indices()) + for (const auto v : GeometryInfo::vertex_indices()) vertices_locally_relevant[cell->vertex_index(v)] = numbers::invalid_unsigned_int; @@ -325,7 +329,7 @@ namespace TriangulationDescription // c) correct vertices of cells (make them local) for (auto &cell : construction_data.coarse_cells) - for (const unsigned int v : GeometryInfo::vertex_indices()) + for (const auto v : GeometryInfo::vertex_indices()) cell.vertices[v] = vertices_locally_relevant[cell.vertices[v]]; } @@ -347,7 +351,7 @@ namespace TriangulationDescription auto is_locally_relevant_on_active_level = [&](TriaIterator> &cell) { if (cell->active()) - for (const unsigned int v : GeometryInfo::vertex_indices()) + for (const auto v : GeometryInfo::vertex_indices()) if (vertices_owned_by_locally_owned_active_cells [cell->vertex_index(v)]) return true; @@ -372,7 +376,7 @@ namespace TriangulationDescription // on level auto is_locally_relevant_on_level = [&](TriaIterator> &cell) { - for (const unsigned int v : GeometryInfo::vertex_indices()) + for (const auto v : GeometryInfo::vertex_indices()) if (vertices_owned_by_locally_owned_cells_on_level [cell->vertex_index(v)]) return true; @@ -392,7 +396,7 @@ namespace TriangulationDescription cell_info.id = cell->id().template to_binary(); // save boundary_ids of each face of this cell - for (const unsigned int f : GeometryInfo::face_indices()) + for (const auto f : GeometryInfo::face_indices()) { types::boundary_id boundary_ind = cell->face(f)->boundary_id(); @@ -415,11 +419,9 @@ namespace TriangulationDescription // ... of quads if (dim == 3) - for (unsigned int quad = 0; - quad < GeometryInfo::quads_per_cell; - ++quad) - cell_info.manifold_quad_ids[quad] = - cell->quad(quad)->manifold_id(); + for (const auto f : GeometryInfo::face_indices()) + cell_info.manifold_quad_ids[f] = + cell->quad(f)->manifold_id(); } // subdomain and level subdomain id -- 2.39.5