From 0810b2c58bd911fabc24c9ae88f46770483985b2 Mon Sep 17 00:00:00 2001 From: Peter Munch Date: Wed, 9 Mar 2022 15:20:11 +0100 Subject: [PATCH] Remove specialization in MGTwoLevelTransfer::interpolate() --- .../mg_transfer_global_coarsening.templates.h | 57 ++++++++++--------- 1 file changed, 29 insertions(+), 28 deletions(-) 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 -- 2.39.5