From b06f3e1eba2beef413d4cc91a3b3f8d05414b872 Mon Sep 17 00:00:00 2001 From: Martin Kronbichler Date: Tue, 31 May 2022 09:20:43 +0200 Subject: [PATCH] MatrixFree: Avoid use of deprecated n_components_filled --- include/deal.II/matrix_free/fe_evaluation.h | 13 +++++++------ include/deal.II/matrix_free/matrix_free.templates.h | 13 +++++++++---- tests/matrix_free/categorize_by_boundary_ids_01.cc | 3 ++- tests/matrix_free/cell_categorization.cc | 9 ++++++--- tests/matrix_free/cell_categorization_02.cc | 7 +++++-- tests/matrix_free/cell_level_and_index.cc | 2 +- tests/matrix_free/dof_info_01.cc | 4 +++- tests/matrix_free/dof_info_02.cc | 4 +++- tests/matrix_free/get_functions_common.h | 3 ++- tests/matrix_free/get_functions_multife.cc | 3 ++- tests/matrix_free/get_functions_multife2.cc | 3 ++- tests/matrix_free/integrate_functions.cc | 3 ++- tests/matrix_free/integrate_functions_hessians.cc | 3 ++- tests/matrix_free/integrate_functions_multife.cc | 3 ++- tests/matrix_free/integrate_functions_multife2.cc | 3 ++- tests/matrix_free/interpolate_functions_common.h | 3 ++- tests/matrix_free/jxw_values.cc | 4 +++- tests/matrix_free/quadrature_points.cc | 4 +++- 18 files changed, 58 insertions(+), 29 deletions(-) diff --git a/include/deal.II/matrix_free/fe_evaluation.h b/include/deal.II/matrix_free/fe_evaluation.h index 76bc437e97..a4db4b46dc 100644 --- a/include/deal.II/matrix_free/fe_evaluation.h +++ b/include/deal.II/matrix_free/fe_evaluation.h @@ -1606,7 +1606,8 @@ protected: * incomplete batch of cells are set to zero, whereas * @p distribute_local_to_global or @p set_dof_values simply ignores the * content in the empty lanes. The number of actually filled SIMD lanes can by - * queried by MatrixFree::n_components_filled(). + * queried by MatrixFree::n_active_entries_per_cell_batch() or + * MatrixFree::n_active_entries_per_face_batch(). * * Obviously, the computations performed on the artificial lanes (without real * data) should never be mixed with valid results. The contract in using this @@ -1615,11 +1616,11 @@ protected: * put together in vectorization. For example, results on an element should * not be added to results on other elements except through the global vector * access methods or by access that is masked by - * MatrixFree::n_components_filled(). No guarantee can be made that results on - * artificial lanes will always be zero that can safely be added to other - * results: The data on JxW or Jacobians is copied from the last valid lane in - * order to avoid division by zero that could trigger floating point - * exceptions or trouble in other situations. + * MatrixFree::n_active_entries_per_cell_batch(). No guarantee can be made + * that results on artificial lanes will always be zero that can safely be + * added to other results: The data on JxW or Jacobians is copied from the + * last valid lane in order to avoid division by zero that could trigger + * floating point exceptions or trouble in other situations. * *

Description of evaluation routines

* diff --git a/include/deal.II/matrix_free/matrix_free.templates.h b/include/deal.II/matrix_free/matrix_free.templates.h index e6adbab2b0..1113e072c1 100644 --- a/include/deal.II/matrix_free/matrix_free.templates.h +++ b/include/deal.II/matrix_free/matrix_free.templates.h @@ -252,7 +252,8 @@ MatrixFree::get_cell_iterator( { AssertIndexRange(dof_handler_index, dof_handlers.size()); AssertIndexRange(cell_batch_index, task_info.cell_partition_data.back()); - AssertIndexRange(lane_index, n_components_filled(cell_batch_index)); + AssertIndexRange(lane_index, + n_active_entries_per_cell_batch(cell_batch_index)); std::pair index = cell_level_index[cell_batch_index * VectorizedArrayType::size() + @@ -273,7 +274,8 @@ MatrixFree::get_cell_level_and_index( const unsigned int lane_index) const { AssertIndexRange(cell_batch_index, task_info.cell_partition_data.back()); - AssertIndexRange(lane_index, n_components_filled(cell_batch_index)); + AssertIndexRange(lane_index, + n_active_entries_per_cell_batch(cell_batch_index)); std::pair level_index_pair = cell_level_index[cell_batch_index * VectorizedArrayType::size() + @@ -329,7 +331,8 @@ MatrixFree::get_hp_cell_iterator( { AssertIndexRange(dof_handler_index, dof_handlers.size()); AssertIndexRange(cell_batch_index, task_info.cell_partition_data.back()); - AssertIndexRange(lane_index, n_components_filled(cell_batch_index)); + AssertIndexRange(lane_index, + n_active_entries_per_cell_batch(cell_batch_index)); std::pair index = cell_level_index[cell_batch_index * VectorizedArrayType::size() + @@ -2056,7 +2059,9 @@ MatrixFree::initialize_indices( for (unsigned int cell = 0; cell < n_cell_batches() + n_ghost_cell_batches(); ++cell) - for (unsigned int v = 0; v < this->n_components_filled(cell); ++v) + for (unsigned int v = 0; + v < this->n_active_entries_per_cell_batch(cell); + ++v) { const unsigned int index = cell * n_lanes + v; diff --git a/tests/matrix_free/categorize_by_boundary_ids_01.cc b/tests/matrix_free/categorize_by_boundary_ids_01.cc index 8abae449e3..cc423e2022 100644 --- a/tests/matrix_free/categorize_by_boundary_ids_01.cc +++ b/tests/matrix_free/categorize_by_boundary_ids_01.cc @@ -85,7 +85,8 @@ test(const unsigned int n_refinements) { bool temp = true; - for (unsigned int v = 1; v < data.n_components_filled(cell); + for (unsigned int v = 1; + v < data.n_active_entries_per_cell_batch(cell); ++v) temp &= (data.get_faces_by_cells_boundary_id(cell, face)[0] == data.get_faces_by_cells_boundary_id(cell, face)[v]); diff --git a/tests/matrix_free/cell_categorization.cc b/tests/matrix_free/cell_categorization.cc index 2145ebba29..69ef873491 100644 --- a/tests/matrix_free/cell_categorization.cc +++ b/tests/matrix_free/cell_categorization.cc @@ -92,7 +92,8 @@ test() deallog << "Number of cell batches: " << mf_data.n_cell_batches() << std::endl; for (unsigned int i = 0; i < mf_data.n_cell_batches(); ++i) - for (unsigned int c = 0; c < mf_data.n_components_filled(i); ++c) + for (unsigned int c = 0; c < mf_data.n_active_entries_per_cell_batch(i); + ++c) deallog << mf_data.get_cell_iterator(i, c)->id() << " with " << mf_data.get_cell_category(i) << std::endl; deallog << std::endl; @@ -102,7 +103,8 @@ test() deallog << "Number of cell batches: " << mf_data.n_cell_batches() << std::endl; for (unsigned int i = 0; i < mf_data.n_cell_batches(); ++i) - for (unsigned int c = 0; c < mf_data.n_components_filled(i); ++c) + for (unsigned int c = 0; c < mf_data.n_active_entries_per_cell_batch(i); + ++c) deallog << mf_data.get_cell_iterator(i, c)->id() << " with " << mf_data.get_cell_category(i) << std::endl; deallog << std::endl; @@ -118,7 +120,8 @@ test() deallog << "Number of cell batches: " << mf_data.n_cell_batches() << std::endl; for (unsigned int i = 0; i < mf_data.n_cell_batches(); ++i) - for (unsigned int c = 0; c < mf_data.n_components_filled(i); ++c) + for (unsigned int c = 0; c < mf_data.n_active_entries_per_cell_batch(i); + ++c) deallog << mf_data.get_cell_iterator(i, c)->id() << " with " << mf_data.get_cell_category(i) << std::endl; deallog << std::endl; diff --git a/tests/matrix_free/cell_categorization_02.cc b/tests/matrix_free/cell_categorization_02.cc index 480e423fb4..7078023974 100644 --- a/tests/matrix_free/cell_categorization_02.cc +++ b/tests/matrix_free/cell_categorization_02.cc @@ -163,7 +163,8 @@ test() for (unsigned int i = 0; i < mf_data.n_cell_batches(); ++i) { const unsigned int m_id = mf_data.get_cell_iterator(i, 0)->material_id(); - for (unsigned int c = 0; c < mf_data.n_components_filled(i); ++c) + for (unsigned int c = 0; c < mf_data.n_active_entries_per_cell_batch(i); + ++c) { const unsigned int c_id = mf_data.get_cell_iterator(i, c)->material_id(); @@ -178,7 +179,9 @@ test() { const unsigned int m_id = level_data->get_cell_iterator(i, 0)->material_id(); - for (unsigned int c = 0; c < level_data->n_components_filled(i); ++c) + for (unsigned int c = 0; + c < level_data->n_active_entries_per_cell_batch(i); + ++c) { const unsigned int c_id = level_data->get_cell_iterator(i, c)->material_id(); diff --git a/tests/matrix_free/cell_level_and_index.cc b/tests/matrix_free/cell_level_and_index.cc index a025b9f476..f49a110395 100644 --- a/tests/matrix_free/cell_level_and_index.cc +++ b/tests/matrix_free/cell_level_and_index.cc @@ -46,7 +46,7 @@ compare_indices(const MatrixFree *mf_data) for (unsigned int batch_no = 0; batch_no < n_batches; ++batch_no) { const unsigned int n_lanes_filled = - mf_data->n_components_filled(batch_no); + mf_data->n_active_entries_per_cell_batch(batch_no); for (unsigned int lane = 0; lane < n_lanes_filled; ++lane) { const auto cell = mf_data->get_cell_iterator(batch_no, lane); diff --git a/tests/matrix_free/dof_info_01.cc b/tests/matrix_free/dof_info_01.cc index b79ff4942a..7d028ae68b 100644 --- a/tests/matrix_free/dof_info_01.cc +++ b/tests/matrix_free/dof_info_01.cc @@ -170,7 +170,9 @@ test(const bool adaptive_ref = true) // output cell blocks: for (unsigned int cell = 0; cell < n_cells; ++cell) - for (unsigned int c = 0; c < mf_data->n_components_filled(cell); ++c) + for (unsigned int c = 0; + c < mf_data->n_active_entries_per_cell_batch(cell); + ++c) { const auto dof_cell = mf_data->get_cell_iterator(cell, c); f << dof_cell->center() << " \"" << cell << "\"\n"; diff --git a/tests/matrix_free/dof_info_02.cc b/tests/matrix_free/dof_info_02.cc index 115d6c66a5..a6e4e13b12 100644 --- a/tests/matrix_free/dof_info_02.cc +++ b/tests/matrix_free/dof_info_02.cc @@ -172,7 +172,9 @@ test(const bool adaptive_ref = true) // output cell blocks: for (unsigned int cell = 0; cell < n_cells; ++cell) - for (unsigned int c = 0; c < mf_data->n_components_filled(cell); ++c) + for (unsigned int c = 0; + c < mf_data->n_active_entries_per_cell_batch(cell); + ++c) { const auto dof_cell = mf_data->get_cell_iterator(cell, c); f << dof_cell->center() << " \"" << cell << "\"\n"; diff --git a/tests/matrix_free/get_functions_common.h b/tests/matrix_free/get_functions_common.h index cb761b986a..6e4927fe33 100644 --- a/tests/matrix_free/get_functions_common.h +++ b/tests/matrix_free/get_functions_common.h @@ -101,7 +101,8 @@ public: // compare values with the ones the FEValues // gives us. Those are seen as reference - for (unsigned int j = 0; j < data.n_components_filled(cell); ++j) + for (unsigned int j = 0; j < data.n_active_entries_per_cell_batch(cell); + ++j) { fe_val.reinit(data.get_cell_iterator(cell, j)); fe_val.get_function_values(src, reference_values); diff --git a/tests/matrix_free/get_functions_multife.cc b/tests/matrix_free/get_functions_multife.cc index bd0fd094a8..e299a94e79 100644 --- a/tests/matrix_free/get_functions_multife.cc +++ b/tests/matrix_free/get_functions_multife.cc @@ -93,7 +93,8 @@ public: // compare values with the ones the FEValues // gives us. Those are seen as reference - for (unsigned int j = 0; j < data.n_components_filled(cell); ++j) + for (unsigned int j = 0; j < data.n_active_entries_per_cell_batch(cell); + ++j) { // FE 0 fe_val0.reinit(data.get_cell_iterator(cell, j, 0)); diff --git a/tests/matrix_free/get_functions_multife2.cc b/tests/matrix_free/get_functions_multife2.cc index a376c99dd5..c0405b448e 100644 --- a/tests/matrix_free/get_functions_multife2.cc +++ b/tests/matrix_free/get_functions_multife2.cc @@ -107,7 +107,8 @@ public: // compare values with the ones the FEValues // gives us. Those are seen as reference - for (unsigned int j = 0; j < data.n_components_filled(cell); ++j) + for (unsigned int j = 0; j < data.n_active_entries_per_cell_batch(cell); + ++j) { // FE 0 fe_val0.reinit(data.get_cell_iterator(cell, j, 0)); diff --git a/tests/matrix_free/integrate_functions.cc b/tests/matrix_free/integrate_functions.cc index 9f6dd5da27..b48c4fa210 100644 --- a/tests/matrix_free/integrate_functions.cc +++ b/tests/matrix_free/integrate_functions.cc @@ -104,7 +104,8 @@ MatrixFreeTest::operator()( fe_eval.reinit(cell); // compare values with the ones the FEValues // gives us. Those are seen as reference - for (unsigned int j = 0; j < data.n_components_filled(cell); ++j) + for (unsigned int j = 0; j < data.n_active_entries_per_cell_batch(cell); + ++j) { // generate random numbers at quadrature // points and test them with basis functions diff --git a/tests/matrix_free/integrate_functions_hessians.cc b/tests/matrix_free/integrate_functions_hessians.cc index 11363a5720..ec4f2132de 100644 --- a/tests/matrix_free/integrate_functions_hessians.cc +++ b/tests/matrix_free/integrate_functions_hessians.cc @@ -106,7 +106,8 @@ MatrixFreeTest::operator()( fe_eval.reinit(cell); // compare values with the ones the FEValues // gives us. Those are seen as reference - for (unsigned int j = 0; j < data.n_components_filled(cell); ++j) + for (unsigned int j = 0; j < data.n_active_entries_per_cell_batch(cell); + ++j) { // generate random numbers at quadrature // points and test them with basis functions diff --git a/tests/matrix_free/integrate_functions_multife.cc b/tests/matrix_free/integrate_functions_multife.cc index cf464018fd..7cf4569ada 100644 --- a/tests/matrix_free/integrate_functions_multife.cc +++ b/tests/matrix_free/integrate_functions_multife.cc @@ -122,7 +122,8 @@ MatrixFreeTest::operator()( // compare values with the ones the FEValues // gives us. Those are seen as reference - for (unsigned int j = 0; j < data.n_components_filled(cell); ++j) + for (unsigned int j = 0; j < data.n_active_entries_per_cell_batch(cell); + ++j) { // FE 0, Quad 0 // generate random numbers at quadrature diff --git a/tests/matrix_free/integrate_functions_multife2.cc b/tests/matrix_free/integrate_functions_multife2.cc index f696e32067..08b97bc456 100644 --- a/tests/matrix_free/integrate_functions_multife2.cc +++ b/tests/matrix_free/integrate_functions_multife2.cc @@ -123,7 +123,8 @@ MatrixFreeTest::operator()( // compare values with the ones the FEValues // gives us. Those are seen as reference - for (unsigned int j = 0; j < data.n_components_filled(cell); ++j) + for (unsigned int j = 0; j < data.n_active_entries_per_cell_batch(cell); + ++j) { // FE 0, Quad 0 // generate random numbers at quadrature diff --git a/tests/matrix_free/interpolate_functions_common.h b/tests/matrix_free/interpolate_functions_common.h index b1be464645..7b0f90b5e4 100644 --- a/tests/matrix_free/interpolate_functions_common.h +++ b/tests/matrix_free/interpolate_functions_common.h @@ -89,7 +89,8 @@ public: fe_eval.evaluate(EvaluationFlags::values | EvaluationFlags::gradients | EvaluationFlags::hessians); - for (unsigned int j = 0; j < data.n_components_filled(cell); ++j) + for (unsigned int j = 0; j < data.n_active_entries_per_cell_batch(cell); + ++j) for (unsigned int q = 0; q < fe_eval.n_q_points; ++q) { ++cell_times; diff --git a/tests/matrix_free/jxw_values.cc b/tests/matrix_free/jxw_values.cc index 7788cfdc75..81c71637c1 100644 --- a/tests/matrix_free/jxw_values.cc +++ b/tests/matrix_free/jxw_values.cc @@ -82,7 +82,9 @@ test() for (unsigned int cell = 0; cell < mf_data.n_cell_batches(); ++cell) { fe_eval.reinit(cell); - for (unsigned int v = 0; v < mf_data.n_components_filled(cell); ++v) + for (unsigned int v = 0; + v < mf_data.n_active_entries_per_cell_batch(cell); + ++v) { fe_values.reinit(mf_data.get_cell_iterator(cell, v)); for (unsigned int q = 0; q < quad.size(); ++q) diff --git a/tests/matrix_free/quadrature_points.cc b/tests/matrix_free/quadrature_points.cc index 4848a2ace7..06047238cd 100644 --- a/tests/matrix_free/quadrature_points.cc +++ b/tests/matrix_free/quadrature_points.cc @@ -94,7 +94,9 @@ test() for (unsigned int cell = 0; cell < n_cells; ++cell) { fe_eval.reinit(cell); - for (unsigned int j = 0; j < mf_data.n_components_filled(cell); ++j) + for (unsigned int j = 0; + j < mf_data.n_active_entries_per_cell_batch(cell); + ++j) { fe_values.reinit(mf_data.get_cell_iterator(cell, j)); for (unsigned int q = 0; q < fe_eval.n_q_points; ++q) -- 2.39.5