// initialize the child indices to invalid values
// (the only allowed values are between zero and
// GeometryInfo<dim>::max_children_per_cell)
- for (unsigned int i = 0; i < child_indices.size(); ++i)
- child_indices[i] = std::numeric_limits<char>::max();
+ std::fill(child_indices.begin(),
+ child_indices.end(),
+ std::numeric_limits<char>::max());
}
static constexpr double tol =
std::numeric_limits<double>::epsilon() * 10000;
if (colorize)
- for (auto &cell : tria.active_cell_iterators())
+ for (const auto &cell : tria.active_cell_iterators())
for (unsigned int face_n = 0; face_n < GeometryInfo<2>::faces_per_cell;
++face_n)
{
// The bulk cells are not quite squares, so we need to move the left
// and right sides of cylinder_tria inwards so that it fits in
// bulk_tria:
- for (auto &cell : cylinder_tria.active_cell_iterators())
+ for (const auto &cell : cylinder_tria.active_cell_iterators())
for (unsigned int vertex_n = 0;
vertex_n < GeometryInfo<2>::vertices_per_cell;
++vertex_n)
}
// Assign interior manifold ids to be the TFI id.
- for (auto &cell : cylinder_tria.active_cell_iterators())
+ for (const auto &cell : cylinder_tria.active_cell_iterators())
{
cell->set_manifold_id(tfi_manifold_id);
for (unsigned int face_n = 0; face_n < GeometryInfo<2>::faces_per_cell;
// Ensure that all manifold ids on a polar cell really are set to the
// polar manifold id:
- for (auto &cell : tria.active_cell_iterators())
+ for (const auto &cell : tria.active_cell_iterators())
if (cell->manifold_id() == polar_manifold_id)
cell->set_all_manifold_ids(polar_manifold_id);
tria.set_manifold(tfi_manifold_id, inner_manifold);
if (colorize)
- for (auto &face : tria.active_face_iterators())
+ for (const auto &face : tria.active_face_iterators())
if (face->at_boundary())
{
const Point<2> center = face->center();
// 3, the bottom boundary id is 4 and the top is 5: both are walls, so set
// them to 3
if (colorize)
- for (auto &face : tria.active_face_iterators())
+ for (const auto &face : tria.active_face_iterators())
if (face->boundary_id() == 4 || face->boundary_id() == 5)
face->set_boundary_id(3);
}
coords[3] = right + thickness;
unsigned int k = 0;
- for (unsigned int i0 = 0; i0 < 4; ++i0)
- for (unsigned int i1 = 0; i1 < 4; ++i1)
- vertices[k++] = Point<2>(coords[i1], coords[i0]);
+ for (const double y : coords)
+ for (const double x : coords)
+ vertices[k++] = Point<2>(x, y);
const types::material_id materials[9] = {5, 4, 6, 1, 0, 2, 9, 8, 10};
coords[3] = right + thickness;
unsigned int k = 0;
- for (unsigned int z = 0; z < 4; ++z)
- for (unsigned int y = 0; y < 4; ++y)
- for (unsigned int x = 0; x < 4; ++x)
- vertices[k++] = Point<3>(coords[x], coords[y], coords[z]);
+ for (const double z : coords)
+ for (const double y : coords)
+ for (const double x : coords)
+ vertices[k++] = Point<3>(x, y, z);
const types::material_id materials[27] = {21, 20, 22, 17, 16, 18, 25,
24, 26, 5, 4, 6, 1, 0,
// Set boundary ids at -half_length to 1 and at half_length to 2. Set the
// manifold id on hull faces (i.e., faces not on either end) to 0.
- for (auto face : triangulation.active_face_iterators())
+ for (const auto &face : triangulation.active_face_iterators())
if (face->at_boundary())
{
if (std::abs(face->center()[0] - -half_length) < 1e-8 * half_length)
Point<3>(d, half_length, d),
};
// Turn cylinder such that y->x
- for (unsigned int i = 0; i < 24; ++i)
+ for (auto &vertex : vertices)
{
- const double h = vertices[i](1);
- vertices[i](1) = -vertices[i](0);
- vertices[i](0) = h;
+ const double h = vertex(1);
+ vertex(1) = -vertex(0);
+ vertex(0) = h;
}
int cell_vertices[10][8] = {{0, 1, 8, 9, 2, 3, 10, 11},
quads.push_back(quad);
quad.boundary_id = top_boundary_id;
- for (unsigned int vertex_n = 0;
- vertex_n < GeometryInfo<3>::vertices_per_face;
- ++vertex_n)
- quad.vertices[vertex_n] += (n_slices - 1) * input.n_vertices();
+ for (unsigned int &vertex : quad.vertices)
+ vertex += (n_slices - 1) * input.n_vertices();
if (copy_manifold_ids)
quad.manifold_id = cell->manifold_id();
quads.push_back(quad);
for (auto manifold_id_it = priorities.rbegin();
manifold_id_it != priorities.rend();
++manifold_id_it)
- for (auto &face : result.active_face_iterators())
+ for (const auto &face : result.active_face_iterators())
if (face->manifold_id() == *manifold_id_it)
for (unsigned int line_n = 0;
line_n < GeometryInfo<3>::lines_per_face;
// orientation. if so, skip it.
{
bool edge_found = false;
- for (unsigned int i = 0;
- i < subcell_data.boundary_lines.size();
- ++i)
- if (((subcell_data.boundary_lines[i].vertices[0] ==
+ for (auto &boundary_line : subcell_data.boundary_lines)
+ if (((boundary_line.vertices[0] ==
map_vert_index[face->line(e)->vertex_index(0)]) &&
- (subcell_data.boundary_lines[i].vertices[1] ==
+ (boundary_line.vertices[1] ==
map_vert_index[face->line(e)->vertex_index(
1)])) ||
- ((subcell_data.boundary_lines[i].vertices[0] ==
+ ((boundary_line.vertices[0] ==
map_vert_index[face->line(e)->vertex_index(1)]) &&
- (subcell_data.boundary_lines[i].vertices[1] ==
+ (boundary_line.vertices[1] ==
map_vert_index[face->line(e)->vertex_index(0)])))
{
- subcell_data.boundary_lines[i].boundary_id =
+ boundary_line.boundary_id =
numbers::internal_face_boundary_id;
edge_found = true;
break;
if (dim == 3)
{
- for (unsigned int i = 0;
- i < subcelldata.boundary_quads.size();
- i++)
+ for (auto &boundary_quad : subcelldata.boundary_quads)
{
double id;
in >> id;
if (set == "MaterialID")
- subcelldata.boundary_quads[i].material_id =
+ boundary_quad.material_id =
static_cast<types::material_id>(id);
else if (set == "ManifoldID")
- subcelldata.boundary_quads[i].manifold_id =
+ boundary_quad.manifold_id =
static_cast<types::manifold_id>(id);
else
Assert(false, ExcInternalError());
}
- for (unsigned int i = 0;
- i < subcelldata.boundary_lines.size();
- i++)
+ for (auto &boundary_line : subcelldata.boundary_lines)
{
double id;
in >> id;
if (set == "MaterialID")
- subcelldata.boundary_lines[i].material_id =
+ boundary_line.material_id =
static_cast<types::material_id>(id);
else if (set == "ManifoldID")
- subcelldata.boundary_lines[i].manifold_id =
+ boundary_line.manifold_id =
static_cast<types::manifold_id>(id);
else
Assert(false, ExcInternalError());
}
else if (dim == 2)
{
- for (unsigned int i = 0;
- i < subcelldata.boundary_lines.size();
- i++)
+ for (auto &boundary_line : subcelldata.boundary_lines)
{
double id;
in >> id;
if (set == "MaterialID")
- subcelldata.boundary_lines[i].material_id =
+ boundary_line.material_id =
static_cast<types::material_id>(id);
else if (set == "ManifoldID")
- subcelldata.boundary_lines[i].manifold_id =
+ boundary_line.manifold_id =
static_cast<types::manifold_id>(id);
else
Assert(false, ExcInternalError());
subcelldata.boundary_lines.emplace_back();
AssertThrow(in, ExcIO());
- for (unsigned int v = 0; v < 2; v++)
- in >> subcelldata.boundary_lines.back().vertices[v];
+ for (unsigned int &vertex :
+ subcelldata.boundary_lines.back().vertices)
+ in >> vertex;
subcelldata.boundary_lines.back().material_id = 0;
- for (unsigned int v = 0; v < 2; v++)
- subcelldata.boundary_lines.back().vertices[v] =
- vertex_indices[subcelldata.boundary_lines.back().vertices[v]];
+ for (unsigned int &vertex :
+ subcelldata.boundary_lines.back().vertices)
+ vertex = vertex_indices[vertex];
line_indices[no] = no_line;
subcelldata.boundary_quads.emplace_back();
AssertThrow(in, ExcIO());
- for (unsigned int v = 0; v < 4; v++)
- in >> subcelldata.boundary_quads.back().vertices[v];
+ for (unsigned int &vertex :
+ subcelldata.boundary_quads.back().vertices)
+ in >> vertex;
subcelldata.boundary_quads.back().material_id = 0;
- for (unsigned int v = 0; v < 4; v++)
- subcelldata.boundary_quads.back().vertices[v] =
- vertex_indices[subcelldata.boundary_quads.back().vertices[v]];
+ for (unsigned int &vertex :
+ subcelldata.boundary_quads.back().vertices)
+ vertex = vertex_indices[vertex];
quad_indices[no] = no_quad;
// transform from ucd to
// consecutive numbering
- for (unsigned int i = 0; i < 2; ++i)
- if (vertex_indices.find(
- subcelldata.boundary_lines.back().vertices[i]) !=
- vertex_indices.end())
+ for (unsigned int &vertex :
+ subcelldata.boundary_lines.back().vertices)
+ if (vertex_indices.find(vertex) != vertex_indices.end())
// vertex with this index exists
- subcelldata.boundary_lines.back().vertices[i] =
- vertex_indices[subcelldata.boundary_lines.back().vertices[i]];
+ vertex = vertex_indices[vertex];
else
{
// no such vertex index
- AssertThrow(false,
- ExcInvalidVertexIndex(
- cell,
- subcelldata.boundary_lines.back().vertices[i]));
- subcelldata.boundary_lines.back().vertices[i] =
- numbers::invalid_unsigned_int;
+ AssertThrow(false, ExcInvalidVertexIndex(cell, vertex));
+ vertex = numbers::invalid_unsigned_int;
};
}
else if ((cell_type == "quad") && (dim == 3))
// transform from ucd to
// consecutive numbering
- for (unsigned int i = 0; i < 4; ++i)
- if (vertex_indices.find(
- subcelldata.boundary_quads.back().vertices[i]) !=
- vertex_indices.end())
+ for (unsigned int &vertex :
+ subcelldata.boundary_quads.back().vertices)
+ if (vertex_indices.find(vertex) != vertex_indices.end())
// vertex with this index exists
- subcelldata.boundary_quads.back().vertices[i] =
- vertex_indices[subcelldata.boundary_quads.back().vertices[i]];
+ vertex = vertex_indices[vertex];
else
{
// no such vertex index
- Assert(false,
- ExcInvalidVertexIndex(
- cell, subcelldata.boundary_quads.back().vertices[i]));
- subcelldata.boundary_quads.back().vertices[i] =
- numbers::invalid_unsigned_int;
+ Assert(false, ExcInvalidVertexIndex(cell, vertex));
+ vertex = numbers::invalid_unsigned_int;
};
}
else
AssertThrow(in, ExcIO());
Assert(GeometryInfo<2>::vertices_per_cell == 4, ExcInternalError());
- for (unsigned int i = 0; i < 4; ++i)
- in >> cells[cell].vertices[i];
+ for (unsigned int &vertex : cells[cell].vertices)
+ in >> vertex;
};
unsigned int xda_ordered_nodes[8];
- for (unsigned int i = 0; i < 8; ++i)
- in >> xda_ordered_nodes[i];
+ for (unsigned int &xda_ordered_node : xda_ordered_nodes)
+ in >> xda_ordered_node;
for (unsigned int i = 0; i < 8; i++)
cells[cell].vertices[i] = xda_ordered_nodes[xda_to_dealII_map[i]];
// transform from ucd to
// consecutive numbering
- for (unsigned int i = 0; i < 2; ++i)
- if (vertex_indices.find(
- subcelldata.boundary_lines.back().vertices[i]) !=
- vertex_indices.end())
+ for (unsigned int &vertex :
+ subcelldata.boundary_lines.back().vertices)
+ if (vertex_indices.find(vertex) != vertex_indices.end())
// vertex with this index exists
- subcelldata.boundary_lines.back().vertices[i] =
- vertex_indices[subcelldata.boundary_lines.back()
- .vertices[i]];
+ vertex = vertex_indices[vertex];
else
{
// no such vertex index
- AssertThrow(
- false,
- ExcInvalidVertexIndex(
- cell_per_entity,
- subcelldata.boundary_lines.back().vertices[i]));
- subcelldata.boundary_lines.back().vertices[i] =
- numbers::invalid_unsigned_int;
+ AssertThrow(false,
+ ExcInvalidVertexIndex(cell_per_entity,
+ vertex));
+ vertex = numbers::invalid_unsigned_int;
};
}
else if ((cell_type == 3) && (dim == 3))
// transform from gmsh to
// consecutive numbering
- for (unsigned int i = 0; i < 4; ++i)
- if (vertex_indices.find(
- subcelldata.boundary_quads.back().vertices[i]) !=
- vertex_indices.end())
+ for (unsigned int &vertex :
+ subcelldata.boundary_quads.back().vertices)
+ if (vertex_indices.find(vertex) != vertex_indices.end())
// vertex with this index exists
- subcelldata.boundary_quads.back().vertices[i] =
- vertex_indices[subcelldata.boundary_quads.back()
- .vertices[i]];
+ vertex = vertex_indices[vertex];
else
{
// no such vertex index
Assert(false,
- ExcInvalidVertexIndex(
- cell_per_entity,
- subcelldata.boundary_quads.back().vertices[i]));
- subcelldata.boundary_quads.back().vertices[i] =
- numbers::invalid_unsigned_int;
+ ExcInvalidVertexIndex(cell_per_entity, vertex));
+ vertex = numbers::invalid_unsigned_int;
}
}
else if (cell_type == 15)
// get the connectivity from the
// input file. the vertices are
// ordered like in the ucd format
- for (unsigned int j = 0; j < GeometryInfo<dim>::vertices_per_cell;
- ++j)
- in >> cells[i].vertices[j];
+ for (unsigned int &vertex : cells[i].vertices)
+ in >> vertex;
}
// do some clean-up on vertices
GridTools::delete_unused_vertices(vertices, cells, subcelldata);
for (unsigned int i = 0; i < cells.size(); ++i)
{
- for (unsigned int v = 0; v < 4; ++v)
+ for (const auto vertex : cells[i].vertices)
{
- const Point<2> &p = vertices[cells[i].vertices[v]];
+ const Point<2> &p = vertices[vertex];
if (p(0) < min_x)
min_x = p(0);
out << "# cell " << i << std::endl;
Point<2> center;
- for (unsigned int f = 0; f < 4; ++f)
- center += vertices[cells[i].vertices[f]];
+ for (const auto vertex : cells[i].vertices)
+ center += vertices[vertex];
center /= 4;
out << "set label \"" << i << "\" at " << center(0) << ',' << center(1)
const std::vector<Point<3>> & vertices,
std::ostream & out)
{
- for (unsigned int cell = 0; cell < cells.size(); ++cell)
+ for (const auto &cell : cells)
{
// line 0
- out << vertices[cells[cell].vertices[0]] << std::endl
- << vertices[cells[cell].vertices[1]] << std::endl
+ out << vertices[cell.vertices[0]] << std::endl
+ << vertices[cell.vertices[1]] << std::endl
<< std::endl
<< std::endl;
// line 1
- out << vertices[cells[cell].vertices[1]] << std::endl
- << vertices[cells[cell].vertices[2]] << std::endl
+ out << vertices[cell.vertices[1]] << std::endl
+ << vertices[cell.vertices[2]] << std::endl
<< std::endl
<< std::endl;
// line 2
- out << vertices[cells[cell].vertices[3]] << std::endl
- << vertices[cells[cell].vertices[2]] << std::endl
+ out << vertices[cell.vertices[3]] << std::endl
+ << vertices[cell.vertices[2]] << std::endl
<< std::endl
<< std::endl;
// line 3
- out << vertices[cells[cell].vertices[0]] << std::endl
- << vertices[cells[cell].vertices[3]] << std::endl
+ out << vertices[cell.vertices[0]] << std::endl
+ << vertices[cell.vertices[3]] << std::endl
<< std::endl
<< std::endl;
// line 4
- out << vertices[cells[cell].vertices[4]] << std::endl
- << vertices[cells[cell].vertices[5]] << std::endl
+ out << vertices[cell.vertices[4]] << std::endl
+ << vertices[cell.vertices[5]] << std::endl
<< std::endl
<< std::endl;
// line 5
- out << vertices[cells[cell].vertices[5]] << std::endl
- << vertices[cells[cell].vertices[6]] << std::endl
+ out << vertices[cell.vertices[5]] << std::endl
+ << vertices[cell.vertices[6]] << std::endl
<< std::endl
<< std::endl;
// line 6
- out << vertices[cells[cell].vertices[7]] << std::endl
- << vertices[cells[cell].vertices[6]] << std::endl
+ out << vertices[cell.vertices[7]] << std::endl
+ << vertices[cell.vertices[6]] << std::endl
<< std::endl
<< std::endl;
// line 7
- out << vertices[cells[cell].vertices[4]] << std::endl
- << vertices[cells[cell].vertices[7]] << std::endl
+ out << vertices[cell.vertices[4]] << std::endl
+ << vertices[cell.vertices[7]] << std::endl
<< std::endl
<< std::endl;
// line 8
- out << vertices[cells[cell].vertices[0]] << std::endl
- << vertices[cells[cell].vertices[4]] << std::endl
+ out << vertices[cell.vertices[0]] << std::endl
+ << vertices[cell.vertices[4]] << std::endl
<< std::endl
<< std::endl;
// line 9
- out << vertices[cells[cell].vertices[1]] << std::endl
- << vertices[cells[cell].vertices[5]] << std::endl
+ out << vertices[cell.vertices[1]] << std::endl
+ << vertices[cell.vertices[5]] << std::endl
<< std::endl
<< std::endl;
// line 10
- out << vertices[cells[cell].vertices[2]] << std::endl
- << vertices[cells[cell].vertices[6]] << std::endl
+ out << vertices[cell.vertices[2]] << std::endl
+ << vertices[cell.vertices[6]] << std::endl
<< std::endl
<< std::endl;
// line 11
- out << vertices[cells[cell].vertices[3]] << std::endl
- << vertices[cells[cell].vertices[7]] << std::endl
+ out << vertices[cell.vertices[3]] << std::endl
+ << vertices[cell.vertices[7]] << std::endl
<< std::endl
<< std::endl;
};
extract_int(const std::string &s)
{
std::string tmp;
- for (unsigned int i = 0; i < s.size(); ++i)
+ for (const char c : s)
{
- if (isdigit(s[i]))
+ if (isdigit(c))
{
- tmp += s[i];
+ tmp += c;
}
}
iss >> stmp >> temp >> face_number;
const std::vector<int> cells = elsets_list[elset_name];
- for (unsigned int i = 0; i < cells.size(); ++i)
+ for (const int cell : cells)
{
- el_idx = cells[i];
+ el_idx = cell;
quad_node_list =
get_global_node_numbers(el_idx, face_number);
quad_node_list.insert(quad_node_list.begin(),
// Assign material id to cells
const std::vector<int> &elset_cells = elsets_list[elset_name];
- for (unsigned int i = 0; i < elset_cells.size(); ++i)
+ for (const int elset_cell : elset_cells)
{
- const int cell_id = elset_cells[i] - 1;
+ const int cell_id = elset_cell - 1;
cell_list[cell_id][0] = material_id;
}
}
const int dim = 2;
const int spacedim = 2;
- const unsigned int nv = GeometryInfo<dim>::vertices_per_cell;
- const unsigned int nf = GeometryInfo<dim>::faces_per_cell;
- const unsigned int nvf = GeometryInfo<dim>::vertices_per_face;
+ const unsigned int nv = GeometryInfo<dim>::vertices_per_cell;
// The following text was copied
// from an existing XFig file.
// Now write boundary edges
static const unsigned int face_reorder[4] = {2, 1, 3, 0};
if (xfig_flags.draw_boundary)
- for (unsigned int f = 0; f < nf; ++f)
+ for (const unsigned int f : face_reorder)
{
- Triangulation<dim, spacedim>::face_iterator face =
- cell->face(face_reorder[f]);
+ Triangulation<dim, spacedim>::face_iterator face = cell->face(f);
const types::boundary_id bi = face->boundary_id();
if (bi != numbers::internal_face_boundary_id)
{
// some style parameters
<< " 0 0 -1 0 0 "
// number of points
- << nvf << std::endl;
+ << GeometryInfo<dim>::vertices_per_face << std::endl;
// For each point, write scaled
// and shifted coordinates
// multiplied by 1200
// (dots/inch)
- for (unsigned int k = 0; k < nvf; ++k)
+ for (unsigned int k = 0;
+ k < GeometryInfo<dim>::vertices_per_face;
+ ++k)
{
const Point<dim> &p = face->vertex(k % nv);
for (unsigned int d = 0; d < static_cast<unsigned int>(dim);
void
GridOut::write_svg(const Triangulation<2, 2> &tria, std::ostream &out) const
{
- unsigned int n_materials = 0;
- unsigned int n_levels = 0;
- unsigned int n_subdomains = 0;
- unsigned int n_level_subdomains = 0;
-
unsigned int n = 0;
unsigned int min_level, max_level;
min_level = max_level = tria.begin()->level();
// auxiliary array for the materials being used (material ids 255 max.)
- unsigned int materials[256];
- for (unsigned int material_index = 0; material_index < 256; material_index++)
- materials[material_index] = 0;
+ std::array<unsigned int, 256> materials{};
// auxiliary array for the levels being used (level number 255 max.)
- unsigned int levels[256];
- for (unsigned int level_index = 0; level_index < 256; level_index++)
- levels[level_index] = 0;
+ std::array<unsigned int, 256> levels{};
// auxiliary array for the subdomains being used (subdomain id 255 max.)
- unsigned int subdomains[256];
- for (unsigned int subdomain_index = 0; subdomain_index < 256;
- subdomain_index++)
- subdomains[subdomain_index] = 0;
+ std::array<unsigned int, 256> subdomains{};
// auxiliary array for the level subdomains being used
- int level_subdomains[256];
- for (int level_subdomain_index = 0; level_subdomain_index < 256;
- level_subdomain_index++)
- level_subdomains[level_subdomain_index] = 0;
+ std::array<int, 256> level_subdomains{};
// We use an active cell iterator to determine the
// bounding box of the given triangulation and check
y_dimension = y_max - y_min;
// count the materials being used
- for (unsigned int material_index = 0; material_index < 256; material_index++)
- {
- if (materials[material_index])
- n_materials++;
- }
+ const unsigned int n_materials =
+ std::count_if(materials.begin(),
+ materials.end(),
+ [](const unsigned int material) { return material != 0; });
// count the levels being used
- for (unsigned int level_index = 0; level_index < 256; level_index++)
- {
- if (levels[level_index])
- n_levels++;
- }
+ const unsigned int n_levels =
+ std::count_if(levels.begin(), levels.end(), [](const unsigned int level) {
+ return level != 0;
+ });
// count the subdomains being used
- for (unsigned int subdomain_index = 0; subdomain_index < 256;
- subdomain_index++)
- {
- if (subdomains[subdomain_index])
- n_subdomains++;
- }
+ const unsigned int n_subdomains =
+ std::count_if(subdomains.begin(),
+ subdomains.end(),
+ [](const unsigned int subdomain) { return subdomain != 0; });
// count the level subdomains being used
- for (int level_subdomain_index = 0; level_subdomain_index < 256;
- level_subdomain_index++)
- {
- if (level_subdomains[level_subdomain_index])
- n_level_subdomains++;
- }
+ const unsigned int n_level_subdomains =
+ std::count_if(level_subdomains.begin(),
+ level_subdomains.end(),
+ [](const int level_subdomain) {
+ return level_subdomain != 0;
+ });
switch (svg_flags.coloring)
{
<< "POINTS " << n_vertices << " double\n";
// actually write the vertices.
- for (auto v : vertices)
+ for (const auto &v : vertices)
{
out << v;
for (unsigned int d = spacedim + 1; d <= 3; ++d)
const int co_face_type = (dim == 1 ? -1 : dim == 2 ? -1 : 3);
// write cells.
- for (auto cell : tria.active_cell_iterators())
+ for (const auto &cell : tria.active_cell_iterators())
{
out << GeometryInfo<dim>::vertices_per_cell;
for (unsigned int i = 0; i < GeometryInfo<dim>::vertices_per_cell; ++i)
}
out << '\n';
}
- for (auto face : faces)
+ for (const auto &face : faces)
{
out << GeometryInfo<dim>::vertices_per_face;
for (unsigned int i = 0; i < GeometryInfo<dim>::vertices_per_face; ++i)
}
out << '\n';
}
- for (auto co_face : co_faces)
+ for (const auto &co_face : co_faces)
{
out << 2;
for (unsigned int i = 0; i < 2; ++i)
<< "LOOKUP_TABLE default\n";
// Now material id and boundary id
- for (auto cell : tria.active_cell_iterators())
+ for (const auto &cell : tria.active_cell_iterators())
{
out << static_cast<std::make_signed<types::material_id>::type>(
cell->material_id())
<< ' ';
}
out << '\n';
- for (auto face : faces)
+ for (const auto &face : faces)
{
out << static_cast<std::make_signed<types::boundary_id>::type>(
face->boundary_id())
<< ' ';
}
out << '\n';
- for (auto co_face : co_faces)
+ for (const auto &co_face : co_faces)
{
out << static_cast<std::make_signed<types::boundary_id>::type>(
co_face->boundary_id())
<< "LOOKUP_TABLE default\n";
// Now material id and boundary id
- for (auto cell : tria.active_cell_iterators())
+ for (const auto &cell : tria.active_cell_iterators())
{
out << static_cast<std::make_signed<types::boundary_id>::type>(
cell->manifold_id())
<< ' ';
}
out << '\n';
- for (auto face : faces)
+ for (const auto &face : faces)
{
out << static_cast<std::make_signed<types::boundary_id>::type>(
face->manifold_id())
<< ' ';
}
out << '\n';
- for (auto co_face : co_faces)
+ for (const auto &co_face : co_faces)
{
out << static_cast<std::make_signed<types::boundary_id>::type>(
co_face->manifold_id())
void reorder_new_to_old_style(std::vector<CellData<2>> &cells)
{
- for (unsigned int cell = 0; cell < cells.size(); ++cell)
- std::swap(cells[cell].vertices[2], cells[cell].vertices[3]);
+ for (auto &cell : cells)
+ std::swap(cell.vertices[2], cell.vertices[3]);
}
void reorder_new_to_old_style(std::vector<CellData<3>> &cells)
{
unsigned int tmp[GeometryInfo<3>::vertices_per_cell];
- for (unsigned int cell = 0; cell < cells.size(); ++cell)
+ for (auto &cell : cells)
{
for (unsigned int i = 0; i < GeometryInfo<3>::vertices_per_cell; ++i)
- tmp[i] = cells[cell].vertices[i];
+ tmp[i] = cell.vertices[i];
for (unsigned int i = 0; i < GeometryInfo<3>::vertices_per_cell; ++i)
- cells[cell].vertices[i] = tmp[GeometryInfo<3>::ucd_to_deal[i]];
+ cell.vertices[i] = tmp[GeometryInfo<3>::ucd_to_deal[i]];
}
}
{
// undo the ordering above
unsigned int tmp[GeometryInfo<3>::vertices_per_cell];
- for (unsigned int cell = 0; cell < cells.size(); ++cell)
+ for (auto &cell : cells)
{
for (unsigned int i = 0; i < GeometryInfo<3>::vertices_per_cell; ++i)
- tmp[i] = cells[cell].vertices[i];
+ tmp[i] = cell.vertices[i];
for (unsigned int i = 0; i < GeometryInfo<3>::vertices_per_cell; ++i)
- cells[cell].vertices[GeometryInfo<3>::ucd_to_deal[i]] = tmp[i];
+ cell.vertices[GeometryInfo<3>::ucd_to_deal[i]] = tmp[i];
}
}
} // namespace
{
unsigned int vertices_lex[GeometryInfo<2>::vertices_per_cell];
unsigned int n_negative_cells = 0;
- for (unsigned int cell_no = 0; cell_no < cells.size(); ++cell_no)
+ for (auto &cell : cells)
{
// GridTools::cell_measure
// requires the vertices to be
// in lexicographic ordering
for (unsigned int i = 0; i < GeometryInfo<2>::vertices_per_cell; ++i)
- vertices_lex[GeometryInfo<2>::ucd_to_deal[i]] =
- cells[cell_no].vertices[i];
+ vertices_lex[GeometryInfo<2>::ucd_to_deal[i]] = cell.vertices[i];
if (GridTools::cell_measure<2>(all_vertices, vertices_lex) < 0)
{
++n_negative_cells;
- std::swap(cells[cell_no].vertices[1], cells[cell_no].vertices[3]);
+ std::swap(cell.vertices[1], cell.vertices[3]);
// check whether the
// resulting cell is now ok.
// should be sticked into the
// bin
for (unsigned int i = 0; i < GeometryInfo<2>::vertices_per_cell; ++i)
- vertices_lex[GeometryInfo<2>::ucd_to_deal[i]] =
- cells[cell_no].vertices[i];
+ vertices_lex[GeometryInfo<2>::ucd_to_deal[i]] = cell.vertices[i];
AssertThrow(GridTools::cell_measure<2>(all_vertices, vertices_lex) >
0,
ExcInternalError());
{
unsigned int vertices_lex[GeometryInfo<3>::vertices_per_cell];
unsigned int n_negative_cells = 0;
- for (unsigned int cell_no = 0; cell_no < cells.size(); ++cell_no)
+ for (auto &cell : cells)
{
// GridTools::cell_measure
// requires the vertices to be
// in lexicographic ordering
for (unsigned int i = 0; i < GeometryInfo<3>::vertices_per_cell; ++i)
- vertices_lex[GeometryInfo<3>::ucd_to_deal[i]] =
- cells[cell_no].vertices[i];
+ vertices_lex[GeometryInfo<3>::ucd_to_deal[i]] = cell.vertices[i];
if (GridTools::cell_measure<3>(all_vertices, vertices_lex) < 0)
{
++n_negative_cells;
// reorder vertices: swap front and back face
for (unsigned int i = 0; i < 4; ++i)
- std::swap(cells[cell_no].vertices[i],
- cells[cell_no].vertices[i + 4]);
+ std::swap(cell.vertices[i], cell.vertices[i + 4]);
// check whether the
// resulting cell is now ok.
// should be sticked into the
// bin
for (unsigned int i = 0; i < GeometryInfo<3>::vertices_per_cell; ++i)
- vertices_lex[GeometryInfo<3>::ucd_to_deal[i]] =
- cells[cell_no].vertices[i];
+ vertices_lex[GeometryInfo<3>::ucd_to_deal[i]] = cell.vertices[i];
AssertThrow(GridTools::cell_measure<3>(all_vertices, vertices_lex) >
0,
ExcInternalError());
cells[c].vertices[v] = new_vertex_numbers[cells[c].vertices[v]];
// same for boundary data
- for (unsigned int c = 0; c < subcelldata.boundary_lines.size(); ++c)
+ for (unsigned int c = 0; c < subcelldata.boundary_lines.size(); // NOLINT
+ ++c)
for (unsigned int v = 0; v < GeometryInfo<1>::vertices_per_cell; ++v)
{
Assert(subcelldata.boundary_lines[c].vertices[v] <
new_vertex_numbers[subcelldata.boundary_lines[c].vertices[v]];
}
- for (unsigned int c = 0; c < subcelldata.boundary_quads.size(); ++c)
+ for (unsigned int c = 0; c < subcelldata.boundary_quads.size(); // NOLINT
+ ++c)
for (unsigned int v = 0; v < GeometryInfo<2>::vertices_per_cell; ++v)
{
Assert(subcelldata.boundary_quads[c].vertices[v] <
const auto src_boundary_ids = tria.get_boundary_ids();
std::vector<types::manifold_id> dst_manifold_ids(src_boundary_ids.size());
auto m_it = dst_manifold_ids.begin();
- for (auto b : src_boundary_ids)
+ for (const auto b : src_boundary_ids)
{
*m_it = static_cast<types::manifold_id>(b);
++m_it;
{
has_cells_with_more_than_dim_faces_on_boundary = false;
- for (auto cell : tria.active_cell_iterators())
+ for (const auto &cell : tria.active_cell_iterators())
{
unsigned int boundary_face_counter = 0;
for (unsigned int f = 0; f < GeometryInfo<dim>::faces_per_cell; ++f)
{
while (refinement_cycles > 0)
{
- for (auto cell : tria.active_cell_iterators())
+ for (const auto &cell : tria.active_cell_iterators())
cell->set_coarsen_flag();
tria.execute_coarsening_and_refinement();
refinement_cycles--;
const unsigned int v0 = 0, v1 = 1, v2 = (dim > 1 ? 2 : 0),
v3 = (dim > 1 ? 3 : 0);
- for (auto cell : tria.active_cell_iterators())
+ for (const auto &cell : tria.active_cell_iterators())
{
double angle_fraction = 0;
unsigned int vertex_at_corner = numbers::invalid_unsigned_int;
{
while (refinement_cycles > 0)
{
- for (auto cell : tria.active_cell_iterators())
+ for (const auto &cell : tria.active_cell_iterators())
cell->set_coarsen_flag();
tria.execute_coarsening_and_refinement();
refinement_cycles--;
}
// add the cells that were not marked as skipped
- for (auto cell : tria.active_cell_iterators())
+ for (const auto &cell : tria.active_cell_iterators())
{
if (cells_to_remove[cell->active_cell_index()] == false)
{
std::map<types::manifold_id, std::unique_ptr<Manifold<dim, spacedim>>>
manifolds;
// Set manifolds in new Triangulation
- for (auto manifold_id : manifold_ids)
+ for (const auto manifold_id : manifold_ids)
if (manifold_id != numbers::flat_manifold_id)
manifolds[manifold_id] = tria.get_manifold(manifold_id).clone();
tria.create_triangulation(vertices, cells_to_add, subcelldata_to_add);
// Restore manifolds
- for (auto manifold_id : manifold_ids)
+ for (const auto manifold_id : manifold_ids)
if (manifold_id != numbers::flat_manifold_id)
tria.set_manifold(manifold_id, *manifolds[manifold_id]);
}
// Alayzing the output discarding artificial cell
// and storing in the proper container locally owned and ghost cells
- for (auto const &cell_tuples : cpt_loc_pts)
+ for (const auto &cell_tuples : cpt_loc_pts)
{
auto &cell_loc = cell_tuples.first;
auto &q_loc = std::get<0>(cell_tuples.second);
// rank and points is a pair: first rank, then a pair of vectors
// (points, indices)
- for (auto const &rank_and_points : map_pts)
+ for (const auto &rank_and_points : map_pts)
{
// Rewriting the contents of the map in human readable format
const auto &received_process = rank_and_points.first;
point_idx))
// The point wasn't found in ghost or locally owned cells: adding it
// to the map
- for (unsigned int i = 0; i < probable_owners_rks.size(); ++i)
- if (probable_owners_rks[i] != my_rank)
+ for (const unsigned int probable_owners_rk : probable_owners_rks)
+ if (probable_owners_rk != my_rank)
{
// add to the data for process probable_owners_rks[i]
- auto ¤t_pts = other_check_pts[probable_owners_rks[i]];
+ auto ¤t_pts = other_check_pts[probable_owners_rk];
// The point local_points[point_idx]
current_pts.first.emplace_back(local_points[point_idx]);
// and its index in the current process
typename Triangulation<dim, spacedim>::active_cell_iterator>>
boxes(tria->n_active_cells());
unsigned int i = 0;
- for (auto cell : tria->active_cell_iterators())
+ for (const auto &cell : tria->active_cell_iterators())
boxes[i++] = std::make_pair(cell->bounding_box(), cell);
cell_bounding_boxes_rtree = pack_rtree(boxes);
}
const double original_distance_to_unit_cell =
GeometryInfo<dim>::distance_to_unit_cell(unit_point);
- for (auto cell : cells_to_add)
+ for (const auto &cell : cells_to_add)
{
if (cell != my_cell)
try
// identify the weights for the lines to be accumulated (vertex
// weights are set outside and coincide with the flat manifold case)
- double weights_lines[GeometryInfo<3>::lines_per_cell];
- for (unsigned int line = 0; line < GeometryInfo<3>::lines_per_cell;
- ++line)
- weights_lines[line] = 0;
+ std::array<double, GeometryInfo<3>::lines_per_cell> weights_lines{};
// start with the contributions of the faces
std::array<double, GeometryInfo<2>::vertices_per_cell> weights;
void reorder_compatibility(std::vector<CellData<2>> &cells,
const SubCellData &)
{
- for (unsigned int cell = 0; cell < cells.size(); ++cell)
- std::swap(cells[cell].vertices[2], cells[cell].vertices[3]);
+ for (auto &cell : cells)
+ std::swap(cell.vertices[2], cell.vertices[3]);
}
SubCellData & subcelldata)
{
unsigned int tmp[GeometryInfo<3>::vertices_per_cell];
- for (unsigned int cell = 0; cell < cells.size(); ++cell)
+ for (auto &cell : cells)
{
for (unsigned int i = 0; i < GeometryInfo<3>::vertices_per_cell; ++i)
- tmp[i] = cells[cell].vertices[i];
+ tmp[i] = cell.vertices[i];
for (unsigned int i = 0; i < GeometryInfo<3>::vertices_per_cell; ++i)
- cells[cell].vertices[GeometryInfo<3>::ucd_to_deal[i]] = tmp[i];
+ cell.vertices[GeometryInfo<3>::ucd_to_deal[i]] = tmp[i];
}
// now points in boundary quads
// some security tests
{
unsigned int boundary_nodes = 0;
- for (unsigned int i = 0; i < lines_at_vertex.size(); ++i)
- switch (lines_at_vertex[i].size())
+ for (const auto &line : lines_at_vertex)
+ switch (line.size())
{
case 1:
// this vertex has only
needed_lines;
for (unsigned int cell = 0; cell < cells.size(); ++cell)
{
- for (unsigned int vertex = 0; vertex < 4; ++vertex)
- AssertThrow(cells[cell].vertices[vertex] <
- triangulation.vertices.size(),
+ for (const auto vertex : cells[cell].vertices)
+ AssertThrow(vertex < triangulation.vertices.size(),
ExcInvalidVertexIndex(cell,
- cells[cell].vertices[vertex],
+ vertex,
triangulation.vertices.size()));
for (unsigned int line = 0;
// note that this cell is
// adjacent to the four
// lines
- for (unsigned int line = 0;
- line < GeometryInfo<dim>::lines_per_cell;
- ++line)
- adjacent_cells[lines[line]->index()].push_back(cell);
+ for (const auto &line : lines)
+ adjacent_cells[line->index()].push_back(cell);
}
}
{
// check whether vertex indices
// are valid ones
- for (unsigned int vertex = 0;
- vertex < GeometryInfo<dim>::vertices_per_cell;
- ++vertex)
- AssertThrow(cells[cell].vertices[vertex] <
- triangulation.vertices.size(),
+ for (const auto vertex : cells[cell].vertices)
+ AssertThrow(vertex < triangulation.vertices.size(),
ExcInvalidVertexIndex(cell,
- cells[cell].vertices[vertex],
+ vertex,
triangulation.vertices.size()));
for (unsigned int line = 0;
std::array<bool, GeometryInfo<dim>::lines_per_face>>,
QuadComparator>
needed_quads;
- for (unsigned int cell = 0; cell < cells.size(); ++cell)
+ for (const auto &cell : cells)
{
// the faces are quads which
// consist of four numbers
++line)
{
line_list[line] = std::pair<int, int>(
- cells[cell].vertices[GeometryInfo<dim>::line_to_cell_vertices(
- line, 0)],
- cells[cell].vertices[GeometryInfo<dim>::line_to_cell_vertices(
- line, 1)]);
+ cell.vertices[GeometryInfo<dim>::line_to_cell_vertices(line,
+ 0)],
+ cell.vertices[GeometryInfo<dim>::line_to_cell_vertices(line,
+ 1)]);
inverse_line_list[line] = std::pair<int, int>(
- cells[cell].vertices[GeometryInfo<dim>::line_to_cell_vertices(
- line, 1)],
- cells[cell].vertices[GeometryInfo<dim>::line_to_cell_vertices(
- line, 0)]);
+ cell.vertices[GeometryInfo<dim>::line_to_cell_vertices(line,
+ 1)],
+ cell.vertices[GeometryInfo<dim>::line_to_cell_vertices(line,
+ 0)]);
}
for (unsigned int face = 0;
// note that this cell is
// adjacent to the six
// quads
- for (unsigned int quad = 0;
- quad < GeometryInfo<dim>::faces_per_cell;
- ++quad)
- adjacent_cells[face_iterator[quad]->index()].push_back(cell);
+ for (const auto &quad : face_iterator)
+ adjacent_cells[quad->index()].push_back(cell);
#ifdef DEBUG
// make some checks on the
quad->line_index(3)));
}
- for (unsigned int i = 0; i < 2; ++i)
+ for (const auto &new_quad : new_quads)
{
- new_quads[i]->set_used_flag();
- new_quads[i]->clear_user_flag();
- new_quads[i]->clear_user_data();
- new_quads[i]->clear_children();
- new_quads[i]->set_boundary_id_internal(
- quad->boundary_id());
- new_quads[i]->set_manifold_id(quad->manifold_id());
+ new_quad->set_used_flag();
+ new_quad->clear_user_flag();
+ new_quad->clear_user_data();
+ new_quad->clear_children();
+ new_quad->set_boundary_id_internal(quad->boundary_id());
+ new_quad->set_manifold_id(quad->manifold_id());
// set all line orientations to true, change
// this after the loop, as we have to consider
// different lines for each child
for (unsigned int j = 0;
j < GeometryInfo<dim>::lines_per_face;
++j)
- new_quads[i]->set_line_orientation(j, true);
+ new_quad->set_line_orientation(j, true);
}
// now set the line orientation of children of
// outer lines correctly, the lines in the
internal::TriangulationImplementation::TriaObject<1>(
vertex_indices[4], vertex_indices[1]));
- for (unsigned int i = 0; i < 4; ++i)
+ for (const auto &new_line : new_lines)
{
- new_lines[i]->set_used_flag();
- new_lines[i]->clear_user_flag();
- new_lines[i]->clear_user_data();
- new_lines[i]->clear_children();
- new_lines[i]->set_boundary_id_internal(
- quad->boundary_id());
- new_lines[i]->set_manifold_id(quad->manifold_id());
+ new_line->set_used_flag();
+ new_line->clear_user_flag();
+ new_line->clear_user_data();
+ new_line->clear_children();
+ new_line->set_boundary_id_internal(quad->boundary_id());
+ new_line->set_manifold_id(quad->manifold_id());
}
// now for the quads. again, first collect some
line_indices[3],
line_indices[11],
line_indices[7]));
- for (unsigned int i = 0; i < 4; ++i)
+ for (const auto &new_quad : new_quads)
{
- new_quads[i]->set_used_flag();
- new_quads[i]->clear_user_flag();
- new_quads[i]->clear_user_data();
- new_quads[i]->clear_children();
- new_quads[i]->set_boundary_id_internal(
- quad->boundary_id());
- new_quads[i]->set_manifold_id(quad->manifold_id());
+ new_quad->set_used_flag();
+ new_quad->clear_user_flag();
+ new_quad->clear_user_data();
+ new_quad->clear_children();
+ new_quad->set_boundary_id_internal(quad->boundary_id());
+ new_quad->set_manifold_id(quad->manifold_id());
// set all line orientations to true, change
// this after the loop, as we have to consider
// different lines for each child
for (unsigned int j = 0;
j < GeometryInfo<dim>::lines_per_face;
++j)
- new_quads[i]->set_line_orientation(j, true);
+ new_quad->set_line_orientation(j, true);
}
// now set the line orientation of children of
// outer lines correctly, the lines in the
// and fill it with the respective values
bool line_orientation[4];
- // the middle vertice marked as m0 above is the
+ // the middle vertex marked as m0 above is the
// start vertex for lines 0 and 2 in standard
// orientation, whereas m1 is the end vertex of
// lines 1 and 3 in standard orientation
// and fill it with the respective values
bool line_orientation[4];
- // the middle vertice marked as m0 above is the
+ // the middle vertex marked as m0 above is the
// start vertex for lines 0 and 2 in standard
// orientation, whereas m1 is the end vertex of
// lines 1 and 3 in standard orientation
&levels,
internal::TriangulationImplementation::TriaFaces<1> *)
{
- for (unsigned int level = 0; level < levels.size(); ++level)
- levels[level]->cells.clear_user_flags();
+ for (const auto &level : levels)
+ level->cells.clear_user_flags();
}
template <int dim>
&levels,
internal::TriangulationImplementation::TriaFaces<2> *)
{
- for (unsigned int level = 0; level < levels.size(); ++level)
- levels[level]->cells.clear_user_flags();
+ for (const auto &level : levels)
+ level->cells.clear_user_flags();
}
template <int dim>
&levels,
internal::TriangulationImplementation::TriaFaces<3> *)
{
- for (unsigned int level = 0; level < levels.size(); ++level)
- levels[level]->cells.clear_user_flags();
+ for (const auto &level : levels)
+ level->cells.clear_user_flags();
}
} // namespace