]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Add assert on reinit() being called before get_present_fe_values() 16805/head
authorSimon Sticko <simon@sticko.se>
Thu, 28 Mar 2024 08:29:10 +0000 (09:29 +0100)
committerSimon Sticko <simon@sticko.se>
Thu, 28 Mar 2024 19:01:15 +0000 (20:01 +0100)
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

index a29400d1e4b744c97a9bec12c766c31bb7a8263d..c7fb10fbe04efa0d5a9ee50ed79e7b272eb06b78 100644 (file)
@@ -693,6 +693,14 @@ namespace hp
   inline const FEValuesType &
   FEValuesBase<dim, q_dim, FEValuesType>::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);
   }
 

In the beginning the Universe was created. This has made a lot of people very angry and has been widely regarded as a bad move.

Douglas Adams


Typeset in Trocchi and Trocchi Bold Sans Serif.