From: Wolfgang Bangerth Date: Tue, 21 May 2024 15:07:30 +0000 (-0600) Subject: Centralize assertions. X-Git-Tag: v9.6.0-rc1~245^2 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=refs%2Fpull%2F17051%2Fhead;p=dealii.git Centralize assertions. --- 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