From: Marc Fehling Date: Mon, 8 Feb 2021 23:11:58 +0000 (-0700) Subject: Cleanup ::SolutionTransfer. X-Git-Tag: v9.3.0-rc1~440^2~2 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f6fa2f7fbf15bcfbb4f426d043c9f2a43049d57f;p=dealii.git Cleanup ::SolutionTransfer. --- diff --git a/source/numerics/solution_transfer.cc b/source/numerics/solution_transfer.cc index 585c15f3dd..80d4fc4857 100644 --- a/source/numerics/solution_transfer.cc +++ b/source/numerics/solution_transfer.cc @@ -100,12 +100,9 @@ SolutionTransfer::prepare_for_pure_refinement() std::vector>(n_active_cells) .swap(indices_on_cell); - typename DoFHandlerType::active_cell_iterator cell = - dof_handler->begin_active(), - endc = dof_handler->end(); - - for (unsigned int i = 0; cell != endc; ++cell, ++i) + for (const auto &cell : dof_handler->active_cell_iterators()) { + const unsigned int i = cell->active_cell_index(); indices_on_cell[i].resize(cell->get_fe().n_dofs_per_cell()); // on each cell store the indices of the // dofs. after refining we get the values @@ -138,14 +135,11 @@ SolutionTransfer::refine_interpolate( Vector local_values(0); - typename DoFHandlerType::cell_iterator cell = dof_handler->begin(), - endc = dof_handler->end(); - typename std::map, Pointerstruct>::const_iterator pointerstruct, cell_map_end = cell_map.end(); - for (; cell != endc; ++cell) + for (const auto &cell : dof_handler->cell_iterators()) { pointerstruct = cell_map.find(std::make_pair(cell->level(), cell->index())); @@ -265,23 +259,20 @@ SolutionTransfer:: Assert(prepared_for != coarsening_and_refinement, ExcAlreadyPrepForCoarseAndRef()); + clear(); + n_dofs_old = dof_handler->n_dofs(); const unsigned int in_size = all_in.size(); + +#ifdef DEBUG Assert(in_size != 0, ExcMessage("The array of input vectors you pass to this " "function has no elements. This is not useful.")); - - clear(); - - const unsigned int n_active_cells = - dof_handler->get_triangulation().n_active_cells(); - (void)n_active_cells; - n_dofs_old = dof_handler->n_dofs(); - for (unsigned int i = 0; i < in_size; ++i) { Assert(all_in[i].size() == n_dofs_old, ExcDimensionMismatch(all_in[i].size(), n_dofs_old)); } +#endif // first count the number // of cells that will be coarsened @@ -295,13 +286,12 @@ SolutionTransfer:: else ++n_cells_to_stay_or_refine; } - Assert((n_cells_to_coarsen + n_cells_to_stay_or_refine) == n_active_cells, + Assert((n_cells_to_coarsen + n_cells_to_stay_or_refine) == + dof_handler->get_triangulation().n_active_cells(), ExcInternalError()); unsigned int n_coarsen_fathers = 0; - for (typename DoFHandlerType::cell_iterator cell = dof_handler->begin(); - cell != dof_handler->end(); - ++cell) + for (const auto &cell : dof_handler->cell_iterators()) if (!cell->is_active() && cell->child(0)->coarsen_flag_set()) ++n_coarsen_fathers; Assert(n_cells_to_coarsen >= 2 * n_coarsen_fathers, ExcInternalError()); @@ -328,9 +318,7 @@ SolutionTransfer:: // the 'to_stay_or_refine' cells 'n_sr' and // the 'coarsen_fathers' cells 'n_cf', unsigned int n_sr = 0, n_cf = 0; - for (typename DoFHandlerType::cell_iterator cell = dof_handler->begin(); - cell != dof_handler->end(); - ++cell) + for (const auto &cell : dof_handler->cell_iterators()) { // CASE 1: active cell that remains as it is if (cell->is_active() && !cell->coarsen_flag_set()) @@ -424,8 +412,9 @@ SolutionTransfer::interpolate( const std::vector &all_in, std::vector & all_out) const { - Assert(prepared_for == coarsening_and_refinement, ExcNotPrepared()); const unsigned int size = all_in.size(); +#ifdef DEBUG + Assert(prepared_for == coarsening_and_refinement, ExcNotPrepared()); Assert(all_out.size() == size, ExcDimensionMismatch(all_out.size(), size)); for (unsigned int i = 0; i < size; ++i) Assert(all_in[i].size() == n_dofs_old, @@ -438,6 +427,7 @@ SolutionTransfer::interpolate( Assert(&all_in[i] != &all_out[j], ExcMessage("Vectors cannot be used as input and output" " at the same time!")); +#endif Vector local_values; std::vector dofs;