return 0;
size_type m = 0;
- for (size_type i = 0; i < lines.size(); ++i)
+ for (const auto &line : lines)
{
- m = std::max(m, static_cast<size_type>(lines[i].entries.size()));
+ m = std::max(m, static_cast<size_type>(line.entries.size()));
}
return m;
{
out << '[' << (rowset.size() == 0 ? row : rowset.nth_index_in_set(row));
- for (std::vector<size_type>::const_iterator j =
- lines[row].entries.begin();
- j != lines[row].entries.end();
- ++j)
- out << ',' << *j;
+ for (const auto entry : lines[row].entries)
+ out << ',' << entry;
out << ']' << std::endl;
}
const size_type rowindex =
rowset.size() == 0 ? row : rowset.nth_index_in_set(row);
- for (std::vector<size_type>::const_iterator j =
- lines[row].entries.begin();
- j != lines[row].entries.end();
- ++j)
+ for (const auto entry : lines[row].entries)
// while matrix entries are usually
// written (i,j), with i vertical and
// j horizontal, gnuplot output is
// x-y, that is we have to exchange
// the order of output
- out << *j << " " << -static_cast<signed int>(rowindex) << std::endl;
+ out << entry << " " << -static_cast<signed int>(rowindex) << std::endl;
}
const size_type rowindex =
rowset.size() == 0 ? row : rowset.nth_index_in_set(row);
- for (std::vector<size_type>::const_iterator j =
- lines[row].entries.begin();
- j != lines[row].entries.end();
- ++j)
- if (static_cast<size_type>(std::abs(static_cast<int>(rowindex - *j))) >
- b)
- b = std::abs(static_cast<signed int>(rowindex - *j));
+ for (const auto entry : lines[row].entries)
+ if (static_cast<size_type>(
+ std::abs(static_cast<int>(rowindex - entry))) > b)
+ b = std::abs(static_cast<signed int>(rowindex - entry));
}
return b;
return 0;
size_type n = 0;
- for (size_type i = 0; i < lines.size(); ++i)
+ for (const auto &line : lines)
{
- n += lines[i].entries.size();
+ n += line.entries.size();
}
return n;
MemoryConsumption::memory_consumption(rowset) -
sizeof(rowset);
- for (size_type i = 0; i < lines.size(); ++i)
- mem += MemoryConsumption::memory_consumption(lines[i]);
+ for (const auto &line : lines)
+ mem += MemoryConsumption::memory_consumption(line);
return mem;
}
sparsity.row_index_set().size() == sparsity.n_rows(),
ExcMessage(
"Only valid for sparsity patterns which store all rows."));
- for (SparsityPattern::size_type i = 0; i < starting_indices.size(); ++i)
- Assert(starting_indices[i] < sparsity.n_rows(),
- ExcMessage("Invalid starting index: All starting indices need "
- "to be between zero and the number of rows in the "
- "sparsity pattern."));
+ for (const auto starting_index : starting_indices)
+ {
+ (void)starting_index;
+ Assert(starting_index < sparsity.n_rows(),
+ ExcMessage("Invalid starting index: All starting indices need "
+ "to be between zero and the number of rows in the "
+ "sparsity pattern."));
+ }
// store the indices of the dofs renumbered in the last round. Default to
// starting points
std::vector<DynamicSparsityPattern::size_type> next_round_dofs;
// find all neighbors of the dofs numbered in the last round
- for (DynamicSparsityPattern::size_type i = 0;
- i < last_round_dofs.size();
- ++i)
- for (DynamicSparsityPattern::iterator j =
- sparsity.begin(last_round_dofs[i]);
- j < sparsity.end(last_round_dofs[i]);
+ for (const auto dof : last_round_dofs)
+ for (DynamicSparsityPattern::iterator j = sparsity.begin(dof);
+ j < sparsity.end(dof);
++j)
next_round_dofs.push_back(j->column());
dofs_by_coordination;
// find coordination number for each of these dofs
- for (std::vector<DynamicSparsityPattern::size_type>::iterator s =
- next_round_dofs.begin();
- s != next_round_dofs.end();
- ++s)
+ for (const types::global_dof_index next_round_dof : next_round_dofs)
{
const DynamicSparsityPattern::size_type coordination =
- sparsity.row_length(*s);
+ sparsity.row_length(next_round_dof);
// insert this dof at its coordination number
const std::pair<const DynamicSparsityPattern::size_type, int>
- new_entry(coordination, *s);
+ new_entry(coordination, next_round_dof);
dofs_by_coordination.insert(new_entry);
}
// next set of possible neighbors
min_neighbors = std::make_pair(numbers::invalid_dof_index,
numbers::invalid_dof_index);
- for (std::set<types::global_dof_index>::iterator it =
- current_neighbors.begin();
- it != current_neighbors.end();
- ++it)
+ for (const auto current_neighbor : current_neighbors)
{
- Assert(touched_nodes[*it] == numbers::invalid_dof_index,
+ Assert(touched_nodes[current_neighbor] ==
+ numbers::invalid_dof_index,
ExcInternalError());
- if (n_remaining_neighbors[*it] < min_neighbors.second)
+ if (n_remaining_neighbors[current_neighbor] <
+ min_neighbors.second)
min_neighbors =
- std::make_pair(*it, n_remaining_neighbors[*it]);
+ std::make_pair(current_neighbor,
+ n_remaining_neighbors[current_neighbor]);
}
// Among the set of nodes with the minimal number of neighbors,
// i.e., the one with the largest row length
const types::global_dof_index best_row_length =
min_neighbors.second;
- for (std::set<types::global_dof_index>::iterator it =
- current_neighbors.begin();
- it != current_neighbors.end();
- ++it)
- if (n_remaining_neighbors[*it] == best_row_length)
- if (row_lengths[*it] > min_neighbors.second)
- min_neighbors = std::make_pair(*it, row_lengths[*it]);
+ for (const auto current_neighbor : current_neighbors)
+ if (n_remaining_neighbors[current_neighbor] == best_row_length)
+ if (row_lengths[current_neighbor] > min_neighbors.second)
+ min_neighbors =
+ std::make_pair(current_neighbor,
+ row_lengths[current_neighbor]);
// Add the pivot and all direct neighbors of the pivot node not
// yet touched to the list of new entries.
// valid neighbor (here we assume symmetry of the
// connectivity). Delete the entries of the current list from
// the set of possible next pivots.
- for (unsigned int i = 0; i < next_group.size(); ++i)
+ for (const auto index : next_group)
{
for (DynamicSparsityPattern::iterator it =
- connectivity.begin(next_group[i]);
- it != connectivity.end(next_group[i]);
+ connectivity.begin(index);
+ it != connectivity.end(index);
++it)
{
if (touched_nodes[it->column()] ==
current_neighbors.insert(it->column());
n_remaining_neighbors[it->column()]--;
}
- current_neighbors.erase(next_group[i]);
+ current_neighbors.erase(index);
}
}
}
{
std::vector<unsigned int> send_to;
send_to.reserve(send_data.size());
- for (map_vec_t::iterator it = send_data.begin(); it != send_data.end();
- ++it)
- send_to.push_back(it->first);
+ for (const auto &sparsity_line : send_data)
+ send_to.push_back(sparsity_line.first);
num_receive =
Utilities::MPI::compute_n_point_to_point_communications(mpi_comm,
// send data
{
unsigned int idx = 0;
- for (map_vec_t::iterator it = send_data.begin(); it != send_data.end();
- ++it, ++idx)
+ for (const auto &sparsity_line : send_data)
{
- const int ierr = MPI_Isend(&(it->second[0]),
- it->second.size(),
+ const int ierr = MPI_Isend(&(sparsity_line.second[0]),
+ sparsity_line.second.size(),
DEAL_II_DOF_INDEX_MPI_TYPE,
- it->first,
+ sparsity_line.first,
124,
mpi_comm,
- &requests[idx]);
+ &requests[idx++]);
AssertThrowMPI(ierr);
}
}
{
std::vector<unsigned int> send_to;
send_to.reserve(send_data.size());
- for (map_vec_t::iterator it = send_data.begin(); it != send_data.end();
- ++it)
- send_to.push_back(it->first);
+ for (const auto &sparsity_line : send_data)
+ send_to.push_back(sparsity_line.first);
num_receive =
Utilities::MPI::compute_n_point_to_point_communications(mpi_comm,
// send data
{
unsigned int idx = 0;
- for (map_vec_t::iterator it = send_data.begin(); it != send_data.end();
- ++it, ++idx)
+ for (const auto &sparsity_line : send_data)
{
- const int ierr = MPI_Isend(&(it->second[0]),
- it->second.size(),
+ const int ierr = MPI_Isend(&(sparsity_line.second[0]),
+ sparsity_line.second.size(),
DEAL_II_DOF_INDEX_MPI_TYPE,
- it->first,
+ sparsity_line.first,
124,
mpi_comm,
- &requests[idx]);
+ &requests[idx++]);
AssertThrowMPI(ierr);
}
}