]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Move check about FECollection size to DoFHandler. 14920/head
authorMarc Fehling <mafehling.git@gmail.com>
Mon, 20 Mar 2023 11:59:11 +0000 (12:59 +0100)
committerMarc Fehling <mafehling.git@gmail.com>
Tue, 21 Mar 2023 09:58:19 +0000 (10:58 +0100)
source/dofs/dof_handler.cc
source/hp/fe_collection.cc

index 62fc1523eaeec2ee63e01767a0f4b817e102a3e0..a296b3cb48e53a1ca633bcd4072a7db4fd49ce0b 100644 (file)
@@ -2149,14 +2149,19 @@ DEAL_II_CXX20_REQUIRES((concepts::is_valid_dim_spacedim<dim, spacedim>))
 void DoFHandler<dim, spacedim>::distribute_dofs(
   const hp::FECollection<dim, spacedim> &ff)
 {
-  Assert(
-    this->tria != nullptr,
-    ExcMessage(
-      "You need to set the Triangulation in the DoFHandler using reinit() or "
-      "in the constructor before you can distribute DoFs."));
+  Assert(this->tria != nullptr,
+         ExcMessage(
+           "You need to set the Triangulation in the DoFHandler using reinit() "
+           "or in the constructor before you can distribute DoFs."));
   Assert(this->tria->n_levels() > 0,
          ExcMessage("The Triangulation you are using is empty!"));
+
+  // verify size of provided FE collection
   Assert(ff.size() > 0, ExcMessage("The given hp::FECollection is empty!"));
+  Assert((ff.size() <= std::numeric_limits<types::fe_index>::max()) &&
+           (ff.size() != numbers::invalid_fe_index),
+         ExcMessage("The given hp::FECollection contains more finite elements "
+                    "than the DoFHandler can cover with active FE indices."));
 
   //
   // register the new finite element collection
index 2ac945c033dfb9d6ba19b5f3f24e33b12e5439a6..5a45fdd2348b58563aa2407d7c2e84d66356d448 100644 (file)
@@ -73,11 +73,6 @@ namespace hp
            ExcMessage("All elements inside a collection need to have the "
                       "same number of vector components!"));
 
-    Assert(this->size() <= std::numeric_limits<types::fe_index>::max() &&
-             this->size() != numbers::invalid_fe_index,
-           ExcMessage(
-             "You reached the maximum possible number of finite elements."));
-
     Collection<FiniteElement<dim, spacedim>>::push_back(new_fe.clone());
   }
 

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.