From: Peter Munch Date: Wed, 9 Mar 2022 14:20:11 +0000 (+0100) Subject: Remove specialization in MGTwoLevelTransfer::interpolate() X-Git-Tag: v9.4.0-rc1~391^2 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=0810b2c58bd911fabc24c9ae88f46770483985b2;p=dealii.git Remove specialization in MGTwoLevelTransfer::interpolate() --- diff --git a/include/deal.II/multigrid/mg_transfer_global_coarsening.templates.h b/include/deal.II/multigrid/mg_transfer_global_coarsening.templates.h index 88fc24d426..3298de8946 100644 --- a/include/deal.II/multigrid/mg_transfer_global_coarsening.templates.h +++ b/include/deal.II/multigrid/mg_transfer_global_coarsening.templates.h @@ -3184,25 +3184,23 @@ MGTwoLevelTransfer>:: for (const auto &scheme : schemes) { - // identity -> take short cut and work directly on global vectors - if (scheme.restriction_matrix.size() == 0 && - scheme.restriction_matrix_1d.size() == 0) - { - for (unsigned int cell = 0; cell < scheme.n_coarse_cells; ++cell) - { - if ((scheme.n_dofs_per_cell_fine != 0) && - (scheme.n_dofs_per_cell_coarse != 0)) - for (unsigned int i = 0; i < scheme.n_dofs_per_cell_fine; ++i) - vec_coarse_ptr->local_element(indices_coarse_plain[i]) = - vec_fine_ptr->local_element(indices_fine[i]); + if (scheme.n_coarse_cells == 0) + continue; - indices_fine += scheme.n_dofs_per_cell_fine; - indices_coarse_plain += scheme.n_dofs_per_cell_coarse; - } + if (scheme.n_dofs_per_cell_fine == 0 || + scheme.n_dofs_per_cell_coarse == 0) + { + indices_fine += scheme.n_coarse_cells * scheme.n_dofs_per_cell_fine; + indices_coarse_plain += + scheme.n_coarse_cells * scheme.n_dofs_per_cell_coarse; continue; } + const bool needs_interpolation = + (scheme.prolongation_matrix.size() == 0 && + scheme.prolongation_matrix_1d.size() == 0) == false; + // general case -> local restriction is needed evaluation_data_fine.resize(scheme.n_dofs_per_cell_fine); evaluation_data_coarse.resize(scheme.n_dofs_per_cell_fine); @@ -3233,20 +3231,23 @@ MGTwoLevelTransfer>:: } // ------------------------------ fine ------------------------------- - for (int c = n_components - 1; c >= 0; --c) - { - CellRestrictor cell_restrictor( - scheme.restriction_matrix, - scheme.restriction_matrix_1d, - evaluation_data_fine.begin() + c * n_scalar_dofs_fine, - evaluation_data_coarse.begin() + c * n_scalar_dofs_coarse); - - if (scheme.restriction_matrix_1d.size() > 0) - cell_transfer.run(cell_restrictor); - else - cell_restrictor.run_full(n_scalar_dofs_fine, - n_scalar_dofs_coarse); - } + if (needs_interpolation) + for (int c = n_components - 1; c >= 0; --c) + { + CellRestrictor cell_restrictor( + scheme.restriction_matrix, + scheme.restriction_matrix_1d, + evaluation_data_fine.begin() + c * n_scalar_dofs_fine, + evaluation_data_coarse.begin() + c * n_scalar_dofs_coarse); + + if (scheme.restriction_matrix_1d.size() > 0) + cell_transfer.run(cell_restrictor); + else + cell_restrictor.run_full(n_scalar_dofs_fine, + n_scalar_dofs_coarse); + } + else + evaluation_data_coarse = evaluation_data_fine; // TODO // ----------------------------- coarse ------------------------------ // write into dst vector