From: David Wells Date: Sat, 3 Jul 2021 15:17:22 +0000 (-0400) Subject: Make FE_SimplexP_Bubbles inherit from FE_SimplexPoly. X-Git-Tag: v9.4.0-rc1~1160^2 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=672f53e5adfe52e74b0e2ae76b80894bf0487429;p=dealii.git Make FE_SimplexP_Bubbles inherit from FE_SimplexPoly. This makes the code simpler and should make this element work automatically with the current matrix-free simplex implementation. --- diff --git a/include/deal.II/fe/fe_simplex_p_bubbles.h b/include/deal.II/fe/fe_simplex_p_bubbles.h index 074411c44e..556fa53e8a 100644 --- a/include/deal.II/fe/fe_simplex_p_bubbles.h +++ b/include/deal.II/fe/fe_simplex_p_bubbles.h @@ -20,7 +20,7 @@ #include -#include +#include DEAL_II_NAMESPACE_OPEN @@ -68,7 +68,7 @@ DEAL_II_NAMESPACE_OPEN * are not yet implemented in this class. */ template -class FE_SimplexP_Bubbles : public dealii::FE_Poly +class FE_SimplexP_Bubbles : public FE_SimplexPoly { public: /** @@ -77,7 +77,8 @@ public: * space for this element: see the general documentation of this class for * more information. * - * @note For degree == 1 this element is equivalent to FE_P(1). + * @note For degree == 1 this element is equivalent to + * FE_SimplexP(1). */ FE_SimplexP_Bubbles(const unsigned int degree); @@ -96,14 +97,6 @@ public: virtual std::string get_name() const override; - /** - * @copydoc dealii::FiniteElement::convert_generalized_support_point_values_to_dof_values() - */ - virtual void - convert_generalized_support_point_values_to_dof_values( - const std::vector> &support_point_values, - std::vector & nodal_values) const override; - protected: /** * Degree of the approximation (i.e., the constructor argument). diff --git a/source/fe/fe_simplex_p_bubbles.cc b/source/fe/fe_simplex_p_bubbles.cc index 044ce1643a..914aa2919e 100644 --- a/source/fe/fe_simplex_p_bubbles.cc +++ b/source/fe/fe_simplex_p_bubbles.cc @@ -26,91 +26,6 @@ DEAL_II_NAMESPACE_OPEN -namespace -{ - /** - * Set up a vector that contains the unit (reference) cell support points - * for FE_Poly and sufficiently similar elements. - */ - template - std::vector> - unit_support_points_fe_poly_bubbles(const unsigned int degree) - { - std::vector> unit_points; - - // Piecewise constants are a special case: use a support point at the - // centroid and only the centroid - if (degree == 0) - { - Point centroid; - std::fill(centroid.begin_raw(), - centroid.end_raw(), - 1.0 / double(dim + 1)); - unit_points.emplace_back(centroid); - return unit_points; - } - - if (dim == 1) - { - // We don't really have dim = 1 support for simplex elements yet, but - // its convenient for populating the face array - Assert(degree <= 2, ExcNotImplemented()); - if (degree >= 1) - { - unit_points.emplace_back(0.0); - unit_points.emplace_back(1.0); - - if (degree == 2) - unit_points.emplace_back(0.5); - } - } - else if (dim == 2) - { - Assert(degree <= 2, ExcNotImplemented()); - if (degree >= 1) - { - unit_points.emplace_back(0.0, 0.0); - unit_points.emplace_back(1.0, 0.0); - unit_points.emplace_back(0.0, 1.0); - - if (degree == 2) - { - unit_points.emplace_back(0.5, 0.0); - unit_points.emplace_back(0.5, 0.5); - unit_points.emplace_back(0.0, 0.5); - } - } - } - else if (dim == 3) - { - Assert(degree <= 2, ExcNotImplemented()); - if (degree >= 1) - { - unit_points.emplace_back(0.0, 0.0, 0.0); - unit_points.emplace_back(1.0, 0.0, 0.0); - unit_points.emplace_back(0.0, 1.0, 0.0); - unit_points.emplace_back(0.0, 0.0, 1.0); - - if (degree == 2) - { - unit_points.emplace_back(0.5, 0.0, 0.0); - unit_points.emplace_back(0.5, 0.5, 0.0); - unit_points.emplace_back(0.0, 0.5, 0.0); - unit_points.emplace_back(0.0, 0.0, 0.5); - unit_points.emplace_back(0.5, 0.0, 0.5); - unit_points.emplace_back(0.0, 0.5, 0.5); - } - } - } - else - { - Assert(false, ExcNotImplemented()); - } - - return unit_points; - } -} // namespace - namespace FE_P_BubblesImplementation { template @@ -148,8 +63,9 @@ namespace FE_P_BubblesImplementation unit_support_points(const unsigned int degree) { Assert(degree < 3, ExcNotImplemented()); - std::vector> points = - unit_support_points_fe_poly_bubbles(degree); + // Start with the points used by FE_SimplexP, and then add bubbles. + FE_SimplexP fe_p(degree); + std::vector> points = fe_p.get_unit_support_points(); Point centroid; std::fill(centroid.begin_raw(), centroid.end_raw(), 1.0 / double(dim + 1)); @@ -186,6 +102,17 @@ namespace FE_P_BubblesImplementation + template <> + std::vector> + unit_support_points<0>(const unsigned int /*degree*/) + { + std::vector> points; + points.emplace_back(); + return points; + } + + + template BarycentricPolynomials get_basis(const unsigned int degree) @@ -314,24 +241,15 @@ namespace FE_P_BubblesImplementation template FE_SimplexP_Bubbles::FE_SimplexP_Bubbles( const unsigned int degree) - : dealii::FE_Poly( + : FE_SimplexPoly( FE_P_BubblesImplementation::get_basis(degree), FE_P_BubblesImplementation::get_fe_data(degree), - std::vector( - FE_P_BubblesImplementation::get_fe_data(degree).dofs_per_cell, - true), - std::vector( - FE_P_BubblesImplementation::get_fe_data(degree).dofs_per_cell, - std::vector(1, true))) + FE_P_BubblesImplementation::unit_support_points(degree), + {FE_P_BubblesImplementation::unit_support_points(degree)}, + // Interface contraints are not yet implemented + FullMatrix()) , approximation_degree(degree) -{ - this->unit_support_points = - FE_P_BubblesImplementation::unit_support_points(degree); - - // TODO - // this->unit_face_support_points = - // unit_face_support_points_fe_poly(degree); -} +{} @@ -345,28 +263,6 @@ FE_SimplexP_Bubbles::get_name() const -template -void -FE_SimplexP_Bubbles:: - convert_generalized_support_point_values_to_dof_values( - const std::vector> &support_point_values, - std::vector & nodal_values) const -{ - AssertDimension(support_point_values.size(), - this->get_unit_support_points().size()); - AssertDimension(support_point_values.size(), nodal_values.size()); - AssertDimension(this->dofs_per_cell, nodal_values.size()); - - for (unsigned int i = 0; i < this->dofs_per_cell; ++i) - { - AssertDimension(support_point_values[i].size(), 1); - - nodal_values[i] = support_point_values[i](0); - } -} - - - template std::unique_ptr> FE_SimplexP_Bubbles::clone() const