From 2c91467a1fe811d99aa1b0a5418fbad26df149ce Mon Sep 17 00:00:00 2001 From: Wolfgang Bangerth Date: Tue, 21 May 2024 09:07:30 -0600 Subject: [PATCH] Centralize assertions. --- include/deal.II/fe/fe_system.h | 11 ------ source/fe/fe_system.cc | 70 ++++++---------------------------- 2 files changed, 11 insertions(+), 70 deletions(-) diff --git a/include/deal.II/fe/fe_system.h b/include/deal.II/fe/fe_system.h index 4e3ad8d6ba..68c1c724db 100644 --- a/include/deal.II/fe/fe_system.h +++ b/include/deal.II/fe/fe_system.h @@ -1428,17 +1428,6 @@ FESystem::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 *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 diff --git a/source/fe/fe_system.cc b/source/fe/fe_system.cc index 2162db2865..7fc17ff60d 100644 --- a/source/fe/fe_system.cc +++ b/source/fe/fe_system.cc @@ -333,18 +333,6 @@ FESystem::FESystem(const FiniteElement &fe1, { const std::vector *> fes = {&fe1, &fe2}; const std::vector 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 *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::FESystem(const FiniteElement &fe1, &fe2, &fe3}; const std::vector 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 *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::FESystem(const FiniteElement &fe1, &fe3, &fe4}; const std::vector 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 *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::FESystem(const FiniteElement &fe1, const std::vector *> fes = { &fe1, &fe2, &fe3, &fe4, &fe5}; const std::vector 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 *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::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 *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::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 *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 -- 2.39.5