if (!active_only && dof.has_level_dofs())
{
std::vector<std::vector<types::global_dof_index>> sizes(
- dof.get_triangulation().n_levels());
-
- for (unsigned int i = 0; i < sizes.size(); ++i)
- sizes[i].resize(dof.get_fe().n_blocks());
+ dof.get_triangulation().n_levels(),
+ std::vector<types::global_dof_index>(dof.get_fe().n_blocks()));
MGTools::count_dofs_per_block(dof, sizes);
levels.resize(sizes.size());
Assert(*p == i, ExcNewNumbersNotConsecutive(i));
}
else
- for (types::global_dof_index i = 0; i < new_numbers.size(); ++i)
- Assert(new_numbers[i] < n_dofs(),
+ for (const auto new_number : new_numbers)
+ Assert(new_number < n_dofs(),
ExcMessage(
"New DoF index is not less than the total number of dofs."));
#endif
Assert(*p == i, ExcNewNumbersNotConsecutive(i));
}
else
- for (types::global_dof_index i = 0; i < new_numbers.size(); ++i)
- Assert(new_numbers[i] < n_dofs(level),
+ for (const auto new_number : new_numbers)
+ Assert(new_number < n_dofs(level),
ExcMessage(
"New DoF index is not less than the total number of dofs."));
#endif
DoFIdentities &identities =
*vertex_dof_identities[most_dominating_fe_index]
[other_fe_index];
- for (unsigned int i = 0; i < identities.size(); ++i)
+ for (const auto &identity : identities)
{
const types::global_dof_index master_dof_index =
dealii::internal::DoFAccessorImplementation::
dof_handler,
vertex_index,
most_dominating_fe_index,
- identities[i].first);
+ identity.first);
const types::global_dof_index slave_dof_index =
dealii::internal::DoFAccessorImplementation::
Implementation::get_vertex_dof_index(
dof_handler,
vertex_index,
other_fe_index,
- identities[i].second);
+ identity.second);
// on subdomain boundaries, we will
// encounter invalid DoFs on ghost cells,
DoFIdentities &identities =
*line_dof_identities[most_dominating_fe_index]
[other_fe_index];
- for (unsigned int i = 0; i < identities.size();
- ++i)
+ for (const auto &identity : identities)
{
const types::global_dof_index
master_dof_index = line->dof_index(
- identities[i].first,
+ identity.first,
most_dominating_fe_index);
const types::global_dof_index
slave_dof_index =
- line->dof_index(identities[i].second,
+ line->dof_index(identity.second,
other_fe_index);
// on subdomain boundaries, we will
DoFIdentities &identities =
*quad_dof_identities[most_dominating_fe_index]
[other_fe_index];
- for (unsigned int i = 0; i < identities.size(); ++i)
+ for (const auto &identity : identities)
{
const types::global_dof_index master_dof_index =
- quad->dof_index(identities[i].first,
+ quad->dof_index(identity.first,
most_dominating_fe_index);
const types::global_dof_index slave_dof_index =
- quad->dof_index(identities[i].second,
+ quad->dof_index(identity.second,
other_fe_index);
// we only store an identity if we are about to
new_dof_indices[p.first] = new_dof_indices[p.second];
}
- for (unsigned int i = 0; i < new_dof_indices.size(); ++i)
+ for (const types::global_dof_index new_dof_index : new_dof_indices)
{
- Assert(new_dof_indices[i] != enumeration_dof_index,
+ (void)new_dof_index;
+ Assert(new_dof_index != enumeration_dof_index,
ExcInternalError());
- Assert(new_dof_indices[i] < next_free_dof ||
- new_dof_indices[i] == numbers::invalid_dof_index,
+ Assert(new_dof_index < next_free_dof ||
+ new_dof_index == numbers::invalid_dof_index,
ExcInternalError());
}
DoFIdentities &identities =
*vertex_dof_identities[most_dominating_fe_index]
[other_fe_index];
- for (unsigned int i = 0; i < identities.size();
- ++i)
+ for (const auto &identity : identities)
{
const types::global_dof_index
master_dof_index = dealii::internal::
dof_handler,
vertex_index,
most_dominating_fe_index,
- identities[i].first);
+ identity.first);
const types::global_dof_index
slave_dof_index = dealii::internal::
DoFAccessorImplementation::
dof_handler,
vertex_index,
other_fe_index,
- identities[i].second);
+ identity.second);
// check if we are on an interface between
// a locally owned and a ghost cell on which
dof_handler,
vertex_index,
other_fe_index,
- identities[i].second,
+ identity.second,
master_dof_index);
}
}
DoFIdentities &identities =
*line_dof_identities[most_dominating_fe_index]
[other_fe_index];
- for (unsigned int i = 0; i < identities.size();
- ++i)
+ for (const auto &identity : identities)
{
const types::global_dof_index
master_dof_index = line->dof_index(
- identities[i].first,
+ identity.first,
most_dominating_fe_index);
const types::global_dof_index
slave_dof_index =
- line->dof_index(identities[i].second,
+ line->dof_index(identity.second,
other_fe_index);
// check if we are on an interface between
numbers::invalid_dof_index) &&
(master_dof_index !=
numbers::invalid_dof_index))
- line->set_dof_index(identities[i].second,
+ line->set_dof_index(identity.second,
master_dof_index,
other_fe_index);
}
DoFIdentities &identities =
*quad_dof_identities[most_dominating_fe_index]
[other_fe_index];
- for (unsigned int i = 0; i < identities.size(); ++i)
+ for (const auto &identity : identities)
{
const types::global_dof_index master_dof_index =
- quad->dof_index(identities[i].first,
+ quad->dof_index(identity.first,
most_dominating_fe_index);
const types::global_dof_index slave_dof_index =
- quad->dof_index(identities[i].second,
+ quad->dof_index(identity.second,
other_fe_index);
// check if we are on an interface between
numbers::invalid_dof_index) &&
(master_dof_index !=
numbers::invalid_dof_index))
- quad->set_dof_index(identities[i].second,
+ quad->set_dof_index(identity.second,
master_dof_index,
other_fe_index);
}
{
std::vector<types::global_dof_index> local_dof_indices;
- for (auto cell : dof_handler.active_cell_iterators())
+ for (const auto &cell : dof_handler.active_cell_iterators())
if (cell->is_ghost() && (cell->subdomain_id() < subdomain_id))
{
// we found a neighboring ghost cell whose subdomain
// the interface)
local_dof_indices.resize(cell->get_fe().dofs_per_cell);
cell->get_dof_indices(local_dof_indices);
- for (auto &local_dof_index : local_dof_indices)
+ for (const auto &local_dof_index : local_dof_indices)
if (local_dof_index != numbers::invalid_dof_index)
renumbering[local_dof_index] = numbers::invalid_dof_index;
}
using cellmap_t =
std::map<dealii::types::subdomain_id, CellDataTransferBuffer<dim>>;
cellmap_t neighbor_cell_list;
- for (std::set<dealii::types::subdomain_id>::iterator it =
- level_ghost_owners.begin();
- it != level_ghost_owners.end();
- ++it)
+ for (const auto level_ghost_owner : level_ghost_owners)
neighbor_cell_list.insert(
- std::make_pair(*it, CellDataTransferBuffer<dim>()));
+ std::make_pair(level_ghost_owner, CellDataTransferBuffer<dim>()));
for (typename DoFHandlerType::level_cell_iterator cell =
dof_handler.begin(0);
// mark all cells that either have to send data (locally
// owned cells that are adjacent to ghost neighbors in some
// way) or receive data (all ghost cells) via the user flags
- for (auto cell : dof_handler->active_cell_iterators())
+ for (const auto &cell : dof_handler->active_cell_iterators())
if (cell->is_locally_owned())
{
for (unsigned int v = 0;
// at this point, we must have taken care of the data transfer
// on all cells we had previously marked. verify this
# ifdef DEBUG
- for (auto cell : dof_handler->active_cell_iterators())
+ for (const auto &cell : dof_handler->active_cell_iterators())
Assert(cell->user_flag_set() == false, ExcInternalError());
# endif
{
std::vector<dealii::types::global_dof_index> local_dof_indices;
- for (auto cell : dof_handler->active_cell_iterators())
+ for (const auto &cell : dof_handler->active_cell_iterators())
if (!cell->is_artificial())
{
local_dof_indices.resize(cell->get_fe().dofs_per_cell);
// TODO: make this code simpler with the new constructors of
// NumberCache make indices consecutive
level_number_cache.n_locally_owned_dofs = 0;
- for (std::vector<dealii::types::global_dof_index>::iterator it =
- renumbering.begin();
- it != renumbering.end();
- ++it)
- if (*it != numbers::invalid_dof_index)
- *it = level_number_cache.n_locally_owned_dofs++;
+ for (types::global_dof_index &index : renumbering)
+ if (index != numbers::invalid_dof_index)
+ index = level_number_cache.n_locally_owned_dofs++;
//* 3. communicate local dofcount and shift ids to make
// them unique
level_number_cache.n_locally_owned_dofs_per_processor.begin() +
triangulation->locally_owned_subdomain(),
static_cast<dealii::types::global_dof_index>(0));
- for (std::vector<dealii::types::global_dof_index>::iterator it =
- renumbering.begin();
- it != renumbering.end();
- ++it)
- if (*it != numbers::invalid_dof_index)
- (*it) += shift;
+ for (types::global_dof_index &index : renumbering)
+ if (index != numbers::invalid_dof_index)
+ index += shift;
// now re-enumerate all dofs to this shifted and condensed
// numbering form. we renumber some dofs as invalid, so
triangulation->clear_user_flags();
// mark all own cells for transfer
- for (auto cell : dof_handler->active_cell_iterators())
+ for (const auto &cell : dof_handler->active_cell_iterators())
if (!cell->is_artificial())
cell->set_user_flag();
DoFTools::extract_locally_active_dofs(dof_handler, locally_active_dofs);
bool needs_locally_active = false;
- for (unsigned int i = 0; i < starting_indices.size(); ++i)
+ for (const auto starting_index : starting_indices)
{
if ((needs_locally_active ==
/* previously already set to */ true) ||
- (locally_owned_dofs.is_element(starting_indices[i]) == false))
+ (locally_owned_dofs.is_element(starting_index) == false))
{
Assert(
- locally_active_dofs.is_element(starting_indices[i]),
+ locally_active_dofs.is_element(starting_index),
ExcMessage(
"You specified global degree of freedom " +
- Utilities::to_string(starting_indices[i]) +
+ Utilities::to_string(starting_index) +
" as a starting index, but this index is not among the "
"locally active ones on this processor, as required "
"for this function."));
// above, we ended up with new_indices only containing the local
// indices of the locally-owned DoFs. so that's where we get the
// indices
- for (std::size_t i = 0; i < new_indices.size(); ++i)
- new_indices[i] = locally_owned_dofs.nth_index_in_set(new_indices[i]);
+ for (types::global_dof_index &new_index : new_indices)
+ new_index = locally_owned_dofs.nth_index_in_set(new_index);
}
}
ExcDimensionMismatch(component_order.size(),
fe_collection.n_components()));
- for (unsigned int i = 0; i < component_order.size(); ++i)
- Assert(component_order[i] < fe_collection.n_components(),
- ExcIndexRange(component_order[i],
- 0,
- fe_collection.n_components()));
+ for (const unsigned int component : component_order)
+ {
+ (void)component;
+ AssertIndexRange(component, fe_collection.n_components());
+ }
// vector to hold the dof indices on
// the cell we visit at a time
// achieve this by extending halo_dofs with DoFs to which
// halo_dofs are constrained.
std::set<types::global_dof_index> extra_halo;
- for (std::set<types::global_dof_index>::iterator it =
- dofs_with_support_on_halo_cells.begin();
- it != dofs_with_support_on_halo_cells.end();
- ++it)
+ for (const auto dof : dofs_with_support_on_halo_cells)
// if halo DoF is constrained, add all DoFs to which it's constrained
// because after resolving constraints, the support of the DoFs that
// constrain the current DoF will extend to the halo cells.
- if (const auto *line_ptr = cm.get_constraint_entries(*it))
+ if (const auto *line_ptr = cm.get_constraint_entries(dof))
{
const unsigned int line_size = line_ptr->size();
for (unsigned int j = 0; j < line_size; ++j)
// this function is similar to the make_sparsity_pattern function,
// see there for more information
- for (auto cell : dof_handler.active_cell_iterators())
+ for (const auto &cell : dof_handler.active_cell_iterators())
if (!cell->is_artificial())
{
for (unsigned int face = 0;
const FiniteElement<dim, spacedim> &fe = dof_handler.get_fe();
- for (auto cell : dof_handler.active_cell_iterators())
+ for (const auto &cell : dof_handler.active_cell_iterators())
if (!cell->is_artificial())
for (unsigned int f = 0; f < GeometryInfo<dim>::faces_per_cell; ++f)
{
dof_indices.resize(cell->get_fe().dofs_per_cell);
cell->get_dof_indices(dof_indices);
- for (std::vector<types::global_dof_index>::iterator it =
- dof_indices.begin();
- it != dof_indices.end();
- ++it)
- if (!dof_set.is_element(*it))
- global_dof_indices.insert(*it);
+ for (const types::global_dof_index dof_index : dof_indices)
+ if (!dof_set.is_element(dof_index))
+ global_dof_indices.insert(dof_index);
}
dof_set.add_indices(global_dof_indices.begin(), global_dof_indices.end());
{
dof_indices.resize(cell->get_fe().dofs_per_cell);
cell->get_dof_indices(dof_indices);
- for (unsigned int i = 0; i < dof_indices.size(); ++i)
- if (!dof_set.is_element(dof_indices[i]))
- dofs_on_ghosts.push_back(dof_indices[i]);
+ for (const auto dof_index : dof_indices)
+ if (!dof_set.is_element(dof_index))
+ dofs_on_ghosts.push_back(dof_index);
}
// sort, compress out duplicates, fill into index set
dof_indices.resize(cell->get_fe().dofs_per_cell);
cell->get_mg_dof_indices(dof_indices);
- for (unsigned int i = 0; i < dof_indices.size(); ++i)
- if (!dof_set.is_element(dof_indices[i]))
- dofs_on_ghosts.push_back(dof_indices[i]);
+ for (const auto dof_index : dof_indices)
+ if (!dof_set.is_element(dof_index))
+ dofs_on_ghosts.push_back(dof_index);
}
// sort, compress out duplicates, fill into index set
std::vector<bool>(n_selected_dofs, false));
// Loop over all owned cells and ask the element for the constant modes
-
- typename DoFHandlerType::active_cell_iterator cell =
- dof_handler.begin_active(),
- endc = dof_handler.end();
std::vector<types::global_dof_index> dof_indices;
- for (; cell != endc; ++cell)
+ for (const auto &cell : dof_handler.active_cell_iterators())
if (cell->is_locally_owned())
{
dof_indices.resize(cell->get_fe().dofs_per_cell);
locally_owned_dofs.index_within_set(dof_indices[i]);
const unsigned int comp = dofs_by_component[loc_index];
if (component_mask[comp])
- for (unsigned int j = 0;
- j < constant_mode_to_component_translation[comp].size();
- ++j)
- constant_modes
- [constant_mode_to_component_translation[comp][j].first]
- [component_numbering[loc_index]] =
- element_constant_modes[cell->active_fe_index()](
- constant_mode_to_component_translation[comp][j]
- .second,
- i);
+ for (auto &indices :
+ constant_mode_to_component_translation[comp])
+ constant_modes[indices
+ .first][component_numbering[loc_index]] =
+ element_constant_modes[cell->active_fe_index()](
+ indices.second, i);
}
}
}
local_dof_indices.resize(cell->get_fe().dofs_per_cell);
cell->get_dof_indices(local_dof_indices);
- for (std::vector<types::global_dof_index>::iterator it =
- local_dof_indices.begin();
- it != local_dof_indices.end();
- ++it)
- subdomain_halo_global_dof_indices.insert(*it);
+ for (const types::global_dof_index local_dof_index :
+ local_dof_indices)
+ subdomain_halo_global_dof_indices.insert(local_dof_index);
}
dof_set[subdomain_id].add_indices(
}
else
{
- for (types::global_dof_index j = 0; j < indices.size(); ++j)
- block_list.add(0, indices[j]);
+ for (const auto index : indices)
+ block_list.add(0, index);
}
}
}
}
else
{
- for (unsigned int j = 0; j < indices.size(); ++j)
- block_list.add(block, indices[j]);
+ for (const auto index : indices)
+ block_list.add(block, index);
}
}
}
subface->get_dof_indices(slave_dofs,
subface_fe_index);
- for (unsigned int i = 0; i < slave_dofs.size(); ++i)
- Assert(slave_dofs[i] !=
- numbers::invalid_dof_index,
- ExcInternalError());
+ for (const types::global_dof_index slave_dof :
+ slave_dofs)
+ {
+ (void)slave_dof;
+ Assert(slave_dof != numbers::invalid_dof_index,
+ ExcInternalError());
+ }
// Now create the element constraint for this
// subface.
// enter those dofs into the list that match the component
// signature.
- for (unsigned int i = 0; i < face_dofs.size(); ++i)
+ for (const types::global_dof_index face_dof : face_dofs)
{
// Find out if a dof has a contribution in this component,
// and if so, add it to the list
const std::vector<types::global_dof_index>::iterator
it_index_on_cell = std::find(cell_dofs.begin(),
cell_dofs.end(),
- face_dofs[i]);
+ face_dof);
Assert(it_index_on_cell != cell_dofs.end(),
ExcInvalidIterator());
const unsigned int index_on_cell =
}
if (nonzero)
- zero_boundary_constraints.add_line(face_dofs[i]);
+ zero_boundary_constraints.add_line(face_dof);
}
}
}
if (sparsity.n_rows() != 0)
{
types::global_dof_index max_element = 0;
- for (std::vector<types::global_dof_index>::const_iterator i =
- dof_to_boundary_mapping.begin();
- i != dof_to_boundary_mapping.end();
- ++i)
- if ((*i != numbers::invalid_dof_index) && (*i > max_element))
- max_element = *i;
+ for (const types::global_dof_index index : dof_to_boundary_mapping)
+ if ((index != numbers::invalid_dof_index) && (index > max_element))
+ max_element = index;
AssertDimension(max_element, sparsity.n_rows() - 1);
};
#endif
if (sparsity.n_rows() != 0)
{
types::global_dof_index max_element = 0;
- for (std::vector<types::global_dof_index>::const_iterator i =
- dof_to_boundary_mapping.begin();
- i != dof_to_boundary_mapping.end();
- ++i)
- if ((*i != numbers::invalid_dof_index) && (*i > max_element))
- max_element = *i;
+ for (const types::global_dof_index index : dof_to_boundary_mapping)
+ if ((index != numbers::invalid_dof_index) && (index > max_element))
+ max_element = index;
AssertDimension(max_element, sparsity.n_rows() - 1);
};
#endif