From d356ab85a2cef1836cb11b076b6c2172a5787ea9 Mon Sep 17 00:00:00 2001 From: Wolfgang Bangerth Date: Thu, 3 May 2018 15:07:12 -0600 Subject: [PATCH] Implement FE_Nothing::operator==(). --- include/deal.II/fe/fe_nothing.h | 10 ++++++++++ source/fe/fe_nothing.cc | 23 +++++++++++++++++++++++ 2 files changed, 33 insertions(+) diff --git a/include/deal.II/fe/fe_nothing.h b/include/deal.II/fe/fe_nothing.h index 0f42477868..c58aa5793a 100644 --- a/include/deal.II/fe/fe_nothing.h +++ b/include/deal.II/fe/fe_nothing.h @@ -254,6 +254,16 @@ public: */ bool is_dominating() const; + /** + * Comparison operator. In addition to the fields already checked by + * FiniteElement::operator==(), this operator also checks for equality + * of the arguments passed to the constructors of the current object + * as well as the object against which the comparison is done (which + * for this purpose obviously also needs to be of type FE_Nothing). + */ + virtual + bool operator == (const FiniteElement &fe) const override; + private: /** diff --git a/source/fe/fe_nothing.cc b/source/fe/fe_nothing.cc index db131e195c..40f9991413 100644 --- a/source/fe/fe_nothing.cc +++ b/source/fe/fe_nothing.cc @@ -179,6 +179,29 @@ FE_Nothing::is_dominating() const } + +template +bool +FE_Nothing::operator == (const FiniteElement &f) const +{ + // Compare fields stored in the base class + if (! (this->FiniteElement::operator== (f))) + return false; + + // Then make sure the other object is really of type FE_Nothing, + // and compare the data that has been passed to both objects' + // constructors. + if (const FE_Nothing *f_nothing + = dynamic_cast *>(&f)) + return ((dominate == f_nothing->dominate) + && + (this->components == f_nothing->components)); + else + return false; +} + + + template FiniteElementDomination::Domination FE_Nothing :: -- 2.39.5