From c27d6f61d2fe49a9e463d9395be25ddf418ed5f5 Mon Sep 17 00:00:00 2001 From: Simon Sticko Date: Thu, 28 Mar 2024 09:29:10 +0100 Subject: [PATCH] Add assert on reinit() being called before get_present_fe_values() If you call hp::FEValues::get_present_fe_values() and forgot to call reinit() first, you presently get a poor error message. Add an assert that present_fe_values_index is not invalid with a better error message. --- include/deal.II/hp/fe_values.h | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/include/deal.II/hp/fe_values.h b/include/deal.II/hp/fe_values.h index a29400d1e4..c7fb10fbe0 100644 --- a/include/deal.II/hp/fe_values.h +++ b/include/deal.II/hp/fe_values.h @@ -693,6 +693,14 @@ namespace hp inline const FEValuesType & FEValuesBase::get_present_fe_values() const { + Assert( + present_fe_values_index != TableIndices<3>(numbers::invalid_unsigned_int, + numbers::invalid_unsigned_int, + numbers::invalid_unsigned_int), + ExcMessage( + "The indices of the present FEValues object are all invalid. The reason" + " is likely that you have forgotten to call the reinit() function.")); + return *fe_values_table(present_fe_values_index); } -- 2.39.5