From 213d38bae79012ef4820cab5987c916c7b52d8b5 Mon Sep 17 00:00:00 2001 From: Peter Munch Date: Fri, 31 Jul 2020 21:02:18 +0200 Subject: [PATCH] Introduce FiniteElementData::max_dofs_per_quad() and FiniteElementData::max_dofs_per_face() --- include/deal.II/fe/fe_base.h | 46 ++++++++++++++++++++++++++++++ include/deal.II/hp/fe_collection.h | 18 ++++-------- source/dofs/dof_handler_policy.cc | 2 +- source/fe/fe_data.cc | 2 ++ 4 files changed, 55 insertions(+), 13 deletions(-) diff --git a/include/deal.II/fe/fe_base.h b/include/deal.II/fe/fe_base.h index 3b69a65a82..c8db30f119 100644 --- a/include/deal.II/fe/fe_base.h +++ b/include/deal.II/fe/fe_base.h @@ -243,6 +243,13 @@ public: */ const unsigned int dofs_per_quad; +private: + /** + * Maximum number of degrees of freedom on any quad. + */ + const unsigned int dofs_per_quad_max; + +public: /** * Number of degrees of freedom in a hexahedron; not including the degrees * of freedom on the quadrilaterals, lines and vertices of the hexahedron. @@ -281,6 +288,13 @@ public: */ const unsigned int dofs_per_face; +private: + /** + * Maximum number of degrees of freedom on any face. + */ + const unsigned int dofs_per_face_max; + +public: /** * Total number of degrees of freedom on a cell. This is the accumulated * number of degrees of freedom on all the objects of dimension up to @@ -395,6 +409,13 @@ public: unsigned int n_dofs_per_quad() const; + /** + * Maximum number of dofs per quad. Not including dofs on lower dimensional + * objects. + */ + unsigned int + max_dofs_per_quad() const; + /** * Number of dofs per hex. Not including dofs on lower dimensional objects. */ @@ -408,6 +429,13 @@ public: unsigned int n_dofs_per_face() const; + /** + * Maximum number of dofs per face, accumulating degrees of freedom of all + * lower dimensional objects. + */ + unsigned int + max_dofs_per_face() const; + /** * Number of dofs per cell, accumulating degrees of freedom of all lower * dimensional objects. @@ -594,6 +622,15 @@ FiniteElementData::n_dofs_per_quad() const +template +inline unsigned int +FiniteElementData::max_dofs_per_quad() const +{ + return dofs_per_quad_max; +} + + + template inline unsigned int FiniteElementData::n_dofs_per_hex() const @@ -612,6 +649,15 @@ FiniteElementData::n_dofs_per_face() const +template +inline unsigned int +FiniteElementData::max_dofs_per_face() const +{ + return dofs_per_face_max; +} + + + template inline unsigned int FiniteElementData::n_dofs_per_cell() const diff --git a/include/deal.II/hp/fe_collection.h b/include/deal.II/hp/fe_collection.h index 2dfe8194f1..c6e6f87956 100644 --- a/include/deal.II/hp/fe_collection.h +++ b/include/deal.II/hp/fe_collection.h @@ -884,8 +884,7 @@ namespace hp unsigned int max = 0; for (unsigned int i = 0; i < finite_elements.size(); ++i) - if (finite_elements[i]->n_dofs_per_vertex() > max) - max = finite_elements[i]->n_dofs_per_vertex(); + max = std::max(max, finite_elements[i]->n_dofs_per_vertex()); return max; } @@ -900,8 +899,7 @@ namespace hp unsigned int max = 0; for (unsigned int i = 0; i < finite_elements.size(); ++i) - if (finite_elements[i]->n_dofs_per_line() > max) - max = finite_elements[i]->n_dofs_per_line(); + max = std::max(max, finite_elements[i]->n_dofs_per_line()); return max; } @@ -916,8 +914,7 @@ namespace hp unsigned int max = 0; for (unsigned int i = 0; i < finite_elements.size(); ++i) - if (finite_elements[i]->n_dofs_per_quad() > max) - max = finite_elements[i]->n_dofs_per_quad(); + max = std::max(max, finite_elements[i]->max_dofs_per_quad()); return max; } @@ -932,8 +929,7 @@ namespace hp unsigned int max = 0; for (unsigned int i = 0; i < finite_elements.size(); ++i) - if (finite_elements[i]->n_dofs_per_hex() > max) - max = finite_elements[i]->n_dofs_per_hex(); + max = std::max(max, finite_elements[i]->n_dofs_per_hex()); return max; } @@ -948,8 +944,7 @@ namespace hp unsigned int max = 0; for (unsigned int i = 0; i < finite_elements.size(); ++i) - if (finite_elements[i]->n_dofs_per_face() > max) - max = finite_elements[i]->n_dofs_per_face(); + max = std::max(max, finite_elements[i]->max_dofs_per_face()); return max; } @@ -964,8 +959,7 @@ namespace hp unsigned int max = 0; for (unsigned int i = 0; i < finite_elements.size(); ++i) - if (finite_elements[i]->n_dofs_per_cell() > max) - max = finite_elements[i]->n_dofs_per_cell(); + max = std::max(max, finite_elements[i]->n_dofs_per_cell()); return max; } diff --git a/source/dofs/dof_handler_policy.cc b/source/dofs/dof_handler_policy.cc index f5195216c3..c36f9866b5 100644 --- a/source/dofs/dof_handler_policy.cc +++ b/source/dofs/dof_handler_policy.cc @@ -2619,7 +2619,7 @@ namespace internal const bool check_validity) { if (dof_handler.get_fe().n_dofs_per_line() > 0 || - dof_handler.get_fe().n_dofs_per_quad() > 0) + dof_handler.get_fe().max_dofs_per_quad() > 0) { // save user flags as they will be modified std::vector user_flags; diff --git a/source/fe/fe_data.cc b/source/fe/fe_data.cc index f9fff482ff..21e16f708a 100644 --- a/source/fe/fe_data.cc +++ b/source/fe/fe_data.cc @@ -50,6 +50,7 @@ FiniteElementData::FiniteElementData( , dofs_per_vertex(dofs_per_object[0]) , dofs_per_line(dofs_per_object[1]) , dofs_per_quad(dim > 1 ? dofs_per_object[2] : 0) + , dofs_per_quad_max(dofs_per_quad) , dofs_per_hex(dim > 2 ? dofs_per_object[3] : 0) , first_line_index( ReferenceCell::internal::Info::get_cell(cell_type).n_vertices() * @@ -83,6 +84,7 @@ FiniteElementData::FiniteElementData( ReferenceCell::internal::Info::get_face(cell_type, 0).n_lines() * dofs_per_line + (dim == 3 ? 1 : 0) * dofs_per_quad) + , dofs_per_face_max(dofs_per_face) , dofs_per_cell( ReferenceCell::internal::Info::get_cell(cell_type).n_vertices() * dofs_per_vertex + -- 2.39.5