From fa5bfa27bfb828d68e731ec428f370ae4e43cd4c Mon Sep 17 00:00:00 2001 From: Martin Kronbichler Date: Fri, 10 May 2019 18:52:28 +0200 Subject: [PATCH] Deprecate FEEvaluation::fill_JxW_values --- include/deal.II/matrix_free/fe_evaluation.h | 4 +++- include/deal.II/matrix_free/operators.h | 20 ++++++++------------ tests/matrix_free/jxw_values.cc | 13 ++++--------- tests/matrix_free/jxw_values.output | 4 ++-- 4 files changed, 17 insertions(+), 24 deletions(-) diff --git a/include/deal.II/matrix_free/fe_evaluation.h b/include/deal.II/matrix_free/fe_evaluation.h index 0a8e2c29e2..3018e2f4ad 100644 --- a/include/deal.II/matrix_free/fe_evaluation.h +++ b/include/deal.II/matrix_free/fe_evaluation.h @@ -546,8 +546,10 @@ public: /** * Fills the JxW values currently used into the given array. + * + * @deprecated Use JxW() instead. */ - void + DEAL_II_DEPRECATED void fill_JxW_values(AlignedVector> &JxW_values) const; /** diff --git a/include/deal.II/matrix_free/operators.h b/include/deal.II/matrix_free/operators.h index 3d5e13ef9f..4e2398e1c3 100644 --- a/include/deal.II/matrix_free/operators.h +++ b/include/deal.II/matrix_free/operators.h @@ -946,24 +946,20 @@ namespace MatrixFreeOperators fill_inverse_JxW_values( AlignedVector> &inverse_jxw) const { - constexpr unsigned int dofs_per_cell = Utilities::pow(fe_degree + 1, dim); - Assert(inverse_jxw.size() > 0 && inverse_jxw.size() % dofs_per_cell == 0, + constexpr unsigned int dofs_per_component_on_cell = + Utilities::pow(fe_degree + 1, dim); + Assert(inverse_jxw.size() > 0 && + inverse_jxw.size() % dofs_per_component_on_cell == 0, ExcMessage( "Expected diagonal to be a multiple of scalar dof per cells")); // temporarily reduce size of inverse_jxw to dofs_per_cell to get JxW values // from fe_eval (will not reallocate any memory) - const unsigned int previous_size = inverse_jxw.size(); - inverse_jxw.resize(dofs_per_cell); - fe_eval.fill_JxW_values(inverse_jxw); - - // invert - inverse_jxw.resize_fast(previous_size); - for (unsigned int q = 0; q < dofs_per_cell; ++q) - inverse_jxw[q] = 1. / inverse_jxw[q]; + for (unsigned int q = 0; q < dofs_per_component_on_cell; ++q) + inverse_jxw[q] = 1. / fe_eval.JxW(q); // copy values to rest of vector - for (unsigned int q = dofs_per_cell; q < previous_size;) - for (unsigned int i = 0; i < dofs_per_cell; ++i, ++q) + for (unsigned int q = dofs_per_component_on_cell; q < inverse_jxw.size();) + for (unsigned int i = 0; i < dofs_per_component_on_cell; ++i, ++q) inverse_jxw[q] = inverse_jxw[i]; } diff --git a/tests/matrix_free/jxw_values.cc b/tests/matrix_free/jxw_values.cc index 7ea5a0d5e8..54eda6743a 100644 --- a/tests/matrix_free/jxw_values.cc +++ b/tests/matrix_free/jxw_values.cc @@ -76,14 +76,12 @@ test() double error = 0, error2 = 0, abs = 0; - QGauss quad(2); - FEValues fe_values(fe, quad, update_JxW_values); - FEEvaluation fe_eval(mf_data); - AlignedVector> jxw_values_manual(fe_eval.n_q_points); + QGauss quad(2); + FEValues fe_values(fe, quad, update_JxW_values); + FEEvaluation fe_eval(mf_data); for (unsigned int cell = 0; cell < mf_data.n_macro_cells(); ++cell) { fe_eval.reinit(cell); - fe_eval.fill_JxW_values(jxw_values_manual); for (unsigned int v = 0; v < mf_data.n_components_filled(cell); ++v) { fe_values.reinit(mf_data.get_cell_iterator(cell, v)); @@ -91,14 +89,11 @@ test() { abs += fe_values.JxW(q); error += std::abs(fe_values.JxW(q) - fe_eval.JxW(q)[v]); - error2 += std::abs(fe_values.JxW(q) - jxw_values_manual[q][v]); } } } - deallog << "Norm of difference: " << error / abs << " " << error2 / abs - << std::endl - << std::endl; + deallog << "Norm of difference: " << error / abs << std::endl << std::endl; } diff --git a/tests/matrix_free/jxw_values.output b/tests/matrix_free/jxw_values.output index eb1bf849db..298361bb84 100644 --- a/tests/matrix_free/jxw_values.output +++ b/tests/matrix_free/jxw_values.output @@ -1,5 +1,5 @@ -DEAL::Norm of difference: 0 0 +DEAL::Norm of difference: 6.71e-16 DEAL:: -DEAL::Norm of difference: 0 0 +DEAL::Norm of difference: 4.79e-16 DEAL:: -- 2.39.5