From: David Schneider Date: Tue, 7 Nov 2023 17:10:21 +0000 (+0100) Subject: Fix MF::get_cell_active_fe_index() to recognise cell categorization X-Git-Tag: relicensing~286^2~6 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f4e69ca2a6a8d673e18959e421e7aedbbc4b64da;p=dealii.git Fix MF::get_cell_active_fe_index() to recognise cell categorization --- diff --git a/include/deal.II/matrix_free/fe_evaluation.h b/include/deal.II/matrix_free/fe_evaluation.h index 92a43ad4a8..81eef32ef6 100644 --- a/include/deal.II/matrix_free/fe_evaluation.h +++ b/include/deal.II/matrix_free/fe_evaluation.h @@ -7121,7 +7121,7 @@ inline FEEvaluation range) const; + const std::pair range, unsigned int dof_index) const; /** * In the hp-adaptive case, return the active FE index of a face range. @@ -2689,11 +2689,12 @@ MatrixFree::n_active_fe_indices() const template unsigned int MatrixFree::get_cell_active_fe_index( - const std::pair range) const + const std::pair range, unsigned int dof_handler_index) const { const auto &fe_indices = dof_info[0].cell_active_fe_index; - if (fe_indices.empty() == true) + if (fe_indices.empty() == true || + dof_handlers[dof_handler_index]->get_fe_collection().size() == 1) return 0; const auto index = fe_indices[range.first]; diff --git a/tests/matrix_free/compute_diagonal_01.cc b/tests/matrix_free/compute_diagonal_01.cc index 685838d8a7..f9e2915f3c 100644 --- a/tests/matrix_free/compute_diagonal_01.cc +++ b/tests/matrix_free/compute_diagonal_01.cc @@ -25,7 +25,7 @@ template > void -test() +test(bool use_categorization = false) { parallel::distributed::Triangulation tria(MPI_COMM_WORLD); @@ -38,6 +38,15 @@ test() cell->set_refine_flag(); tria.execute_coarsening_and_refinement(); + if (use_categorization) + { + for (auto &cell : tria.active_cell_iterators()) + if (cell->is_active() && cell->is_locally_owned() && + cell->center()[0] < 0.0) + cell->set_material_id(42); + else + cell->set_material_id(0); + } const FE_Q fe_q(fe_degree); const FESystem fe(fe_q, n_components); @@ -60,6 +69,18 @@ test() additional_data; additional_data.mapping_update_flags = update_values | update_gradients; + if (use_categorization) + { + additional_data.cell_vectorization_category.resize(tria.n_active_cells()); + for (const auto &cell : tria.active_cell_iterators()) + if (cell->is_locally_owned()) + additional_data + .cell_vectorization_category[cell->active_cell_index()] = + cell->material_id(); + + additional_data.cell_vectorization_categories_strict = true; + } + MappingQ mapping(1); QGauss<1> quad(fe_degree + 1); @@ -96,4 +117,9 @@ main(int argc, char **argv) test<2, 1, 2, 1, float>(); // scalar test<2, 1, 2, 2, float>(); // vector + + // Same as above, but testing additional categorization of vectorized cell + // batches + test<2, 1, 2, 1, float>(true); // scalar + test<2, 1, 2, 2, float>(true); // vector }