]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Centralize assertions. 17051/head
authorWolfgang Bangerth <bangerth@colostate.edu>
Tue, 21 May 2024 15:07:30 +0000 (09:07 -0600)
committerWolfgang Bangerth <bangerth@colostate.edu>
Tue, 21 May 2024 15:07:30 +0000 (09:07 -0600)
include/deal.II/fe/fe_system.h
source/fe/fe_system.cc

index 4e3ad8d6bafe448cd9b367bdd25c1be6a1af5d45..68c1c724db0a7acae82d0ff71d8698cf64760395 100644 (file)
@@ -1428,17 +1428,6 @@ FESystem<dim, spacedim>::FESystem(
   for (const auto &p : fe_systems)
     extract(p);
 
-  const ReferenceCell reference_cell = fes.front()->reference_cell();
-  (void)reference_cell;
-  Assert(std::all_of(fes.begin(),
-                     fes.end(),
-                     [reference_cell](const FiniteElement<dim, spacedim> *fe) {
-                       return fe->reference_cell() == reference_cell;
-                     }),
-         ExcMessage("You cannot combine finite elements defined on "
-                    "different reference cells into a combined element "
-                    "such as an FESystem or FE_Enriched object."));
-
   initialize(fes, multiplicities);
 }
 #  endif
index 2162db2865fcc9702c5761c5d6396db325dda8d5..7fc17ff60d7dcce5e816e6ff7cf63a52cf000bce 100644 (file)
@@ -333,18 +333,6 @@ FESystem<dim, spacedim>::FESystem(const FiniteElement<dim, spacedim> &fe1,
 {
   const std::vector<const FiniteElement<dim, spacedim> *> fes = {&fe1, &fe2};
   const std::vector<unsigned int> multiplicities              = {n1, n2};
-
-  const ReferenceCell reference_cell = fes.front()->reference_cell();
-  (void)reference_cell;
-  Assert(std::all_of(fes.begin(),
-                     fes.end(),
-                     [reference_cell](const FiniteElement<dim, spacedim> *fe) {
-                       return fe->reference_cell() == reference_cell;
-                     }),
-         ExcMessage("You cannot combine finite elements defined on "
-                    "different reference cells into a combined element "
-                    "such as an FESystem or FE_Enriched object."));
-
   initialize(fes, multiplicities);
 }
 
@@ -375,18 +363,6 @@ FESystem<dim, spacedim>::FESystem(const FiniteElement<dim, spacedim> &fe1,
                                                                  &fe2,
                                                                  &fe3};
   const std::vector<unsigned int> multiplicities              = {n1, n2, n3};
-
-  const ReferenceCell reference_cell = fes.front()->reference_cell();
-  (void)reference_cell;
-  Assert(std::all_of(fes.begin(),
-                     fes.end(),
-                     [reference_cell](const FiniteElement<dim, spacedim> *fe) {
-                       return fe->reference_cell() == reference_cell;
-                     }),
-         ExcMessage("You cannot combine finite elements defined on "
-                    "different reference cells into a combined element "
-                    "such as an FESystem or FE_Enriched object."));
-
   initialize(fes, multiplicities);
 }
 
@@ -420,18 +396,6 @@ FESystem<dim, spacedim>::FESystem(const FiniteElement<dim, spacedim> &fe1,
                                                                  &fe3,
                                                                  &fe4};
   const std::vector<unsigned int> multiplicities = {n1, n2, n3, n4};
-
-  const ReferenceCell reference_cell = fes.front()->reference_cell();
-  (void)reference_cell;
-  Assert(std::all_of(fes.begin(),
-                     fes.end(),
-                     [reference_cell](const FiniteElement<dim, spacedim> *fe) {
-                       return fe->reference_cell() == reference_cell;
-                     }),
-         ExcMessage("You cannot combine finite elements defined on "
-                    "different reference cells into a combined element "
-                    "such as an FESystem or FE_Enriched object."));
-
   initialize(fes, multiplicities);
 }
 
@@ -466,18 +430,6 @@ FESystem<dim, spacedim>::FESystem(const FiniteElement<dim, spacedim> &fe1,
   const std::vector<const FiniteElement<dim, spacedim> *> fes = {
     &fe1, &fe2, &fe3, &fe4, &fe5};
   const std::vector<unsigned int> multiplicities = {n1, n2, n3, n4, n5};
-
-  const ReferenceCell reference_cell = fes.front()->reference_cell();
-  (void)reference_cell;
-  Assert(std::all_of(fes.begin(),
-                     fes.end(),
-                     [reference_cell](const FiniteElement<dim, spacedim> *fe) {
-                       return fe->reference_cell() == reference_cell;
-                     }),
-         ExcMessage("You cannot combine finite elements defined on "
-                    "different reference cells into a combined element "
-                    "such as an FESystem or FE_Enriched object."));
-
   initialize(fes, multiplicities);
 }
 
@@ -495,17 +447,6 @@ FESystem<dim, spacedim>::FESystem(
       FETools::Compositing::compute_nonzero_components(fes, multiplicities))
   , base_elements(count_nonzeros(multiplicities))
 {
-  const ReferenceCell reference_cell = fes.front()->reference_cell();
-  (void)reference_cell;
-  Assert(std::all_of(fes.begin(),
-                     fes.end(),
-                     [reference_cell](const FiniteElement<dim, spacedim> *fe) {
-                       return fe->reference_cell() == reference_cell;
-                     }),
-         ExcMessage("You cannot combine finite elements defined on "
-                    "different reference cells into a combined element "
-                    "such as an FESystem or FE_Enriched object."));
-
   initialize(fes, multiplicities);
 }
 
@@ -1761,6 +1702,17 @@ FESystem<dim, spacedim>::initialize(
   Assert(count_nonzeros(multiplicities) > 0,
          ExcMessage("You only passed FiniteElements with multiplicity 0."));
 
+  const ReferenceCell reference_cell = fes.front()->reference_cell();
+  (void)reference_cell;
+  Assert(std::all_of(fes.begin(),
+                     fes.end(),
+                     [reference_cell](const FiniteElement<dim, spacedim> *fe) {
+                       return fe->reference_cell() == reference_cell;
+                     }),
+         ExcMessage("You cannot combine finite elements defined on "
+                    "different reference cells into a combined element "
+                    "such as an FESystem or FE_Enriched object."));
+
   // Note that we need to skip every FE with multiplicity 0 in the following
   // block of code
 

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.