From: Peter Munch Date: Tue, 30 Jun 2020 19:23:12 +0000 (+0200) Subject: Introduce ReferenceCell::Type X-Git-Tag: v9.3.0-rc1~1283^2 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=864ba8d8f0cd61997cf80242011f633ad8b4f5cd;p=dealii.git Introduce ReferenceCell::Type --- diff --git a/include/deal.II/fe/fe_base.h b/include/deal.II/fe/fe_base.h index 653dc07b47..ee51ceb64e 100644 --- a/include/deal.II/fe/fe_base.h +++ b/include/deal.II/fe/fe_base.h @@ -20,6 +20,8 @@ #include +#include + #include #include @@ -351,6 +353,17 @@ public: const Conformity conformity = unknown, const BlockIndices &block_indices = BlockIndices()); + /** + * The same as above but with the difference that also the type of the + * underlying geometric entity can be specified. + */ + FiniteElementData(const std::vector &dofs_per_object, + const ReferenceCell::Type cell_type, + const unsigned int n_components, + const unsigned int degree, + const Conformity conformity = unknown, + const BlockIndices &block_indices = BlockIndices()); + /** * Number of dofs per vertex. */ diff --git a/include/deal.II/grid/reference_cell.h b/include/deal.II/grid/reference_cell.h index 49e2033ccd..7c2a57ce7b 100644 --- a/include/deal.II/grid/reference_cell.h +++ b/include/deal.II/grid/reference_cell.h @@ -229,6 +229,18 @@ namespace ReferenceCell return true; } + + /** + * Return reference-cell type of face @p face_no. + */ + virtual ReferenceCell::Type + face_reference_cell_type(const unsigned int face_no) const + { + Assert(false, ExcNotImplemented()); + (void)face_no; + + return ReferenceCell::Type::Invalid; + } }; @@ -263,7 +275,14 @@ namespace ReferenceCell * Vertex. */ struct Vertex : public TensorProductBase<0> - {}; + { + ReferenceCell::Type + face_reference_cell_type(const unsigned int face_no) const override + { + (void)face_no; + return ReferenceCell::Type::Invalid; + } + }; @@ -271,7 +290,14 @@ namespace ReferenceCell * Line. */ struct Line : public TensorProductBase<1> - {}; + { + ReferenceCell::Type + face_reference_cell_type(const unsigned int face_no) const override + { + (void)face_no; + return ReferenceCell::Type::Vertex; + } + }; @@ -299,6 +325,13 @@ namespace ReferenceCell return GeometryInfo<2>::standard_to_real_line_vertex( vertex, line_orientation); } + + ReferenceCell::Type + face_reference_cell_type(const unsigned int face_no) const override + { + (void)face_no; + return ReferenceCell::Type::Line; + } }; @@ -381,8 +414,53 @@ namespace ReferenceCell get_bit(face_orientation, 2), get_bit(face_orientation, 1)); } + + ReferenceCell::Type + face_reference_cell_type(const unsigned int face_no) const override + { + (void)face_no; + return ReferenceCell::Type::Quad; + } }; + /** + * Return for a given reference-cell type @p the right Info. + */ + inline const ReferenceCell::internal::Info::Base & + get_cell(const ReferenceCell::Type &type) + { + static ReferenceCell::internal::Info::Base gei_invalid; + static ReferenceCell::internal::Info::Vertex gei_vertex; + static ReferenceCell::internal::Info::Line gei_line; + static ReferenceCell::internal::Info::Quad gei_quad; + static ReferenceCell::internal::Info::Hex gei_hex; + + switch (type) + { + case ReferenceCell::Type::Vertex: + return gei_vertex; + case ReferenceCell::Type::Line: + return gei_line; + case ReferenceCell::Type::Quad: + return gei_quad; + case ReferenceCell::Type::Hex: + return gei_hex; + default: + Assert(false, StandardExceptions::ExcNotImplemented()); + return gei_invalid; + } + } + + /** + * Return for a given reference-cell type @p and face number @p face_no the + * right Info of the @p face_no-th face. + */ + inline const ReferenceCell::internal::Info::Base & + get_face(const ReferenceCell::Type &type, const unsigned int face_no) + { + return get_cell(get_cell(type).face_reference_cell_type(face_no)); + } + } // namespace Info } // namespace internal } // namespace ReferenceCell diff --git a/source/fe/fe_data.cc b/source/fe/fe_data.cc index 4ae2482afd..ad587ad12d 100644 --- a/source/fe/fe_data.cc +++ b/source/fe/fe_data.cc @@ -26,28 +26,74 @@ FiniteElementData::FiniteElementData( const unsigned int degree, const Conformity conformity, const BlockIndices & block_indices) + : FiniteElementData(dofs_per_object, + dim == 0 ? + ReferenceCell::Type::Vertex : + (dim == 1 ? ReferenceCell::Type::Line : + (dim == 2 ? ReferenceCell::Type::Quad : + ReferenceCell::Type::Hex)), + n_components, + degree, + conformity, + block_indices) +{} + +template +FiniteElementData::FiniteElementData( + const std::vector &dofs_per_object, + const ReferenceCell::Type cell_type, + const unsigned int n_components, + const unsigned int degree, + const Conformity conformity, + const BlockIndices & block_indices) : 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_hex(dim > 2 ? dofs_per_object[3] : 0) - , first_line_index(GeometryInfo::vertices_per_cell * dofs_per_vertex) - , first_quad_index(first_line_index + - GeometryInfo::lines_per_cell * dofs_per_line) - , first_hex_index(first_quad_index + - GeometryInfo::quads_per_cell * dofs_per_quad) - , first_face_line_index(GeometryInfo::vertices_per_cell * - dofs_per_vertex) + , first_line_index( + ReferenceCell::internal::Info::get_cell(cell_type).n_vertices() * + dofs_per_vertex) + , first_quad_index( + first_line_index + + ReferenceCell::internal::Info::get_cell(cell_type).n_lines() * + dofs_per_line) + , first_hex_index( + first_quad_index + + (dim == 2 ? + 1 : + (dim == 3 ? + ReferenceCell::internal::Info::get_cell(cell_type).n_faces() : + 0)) * + dofs_per_quad) + , first_face_line_index( + ReferenceCell::internal::Info::get_face(cell_type, 0).n_vertices() * + dofs_per_vertex) , first_face_quad_index( - (dim == 3 ? GeometryInfo::vertices_per_cell * dofs_per_vertex : - GeometryInfo::vertices_per_cell * dofs_per_vertex) + - GeometryInfo::lines_per_cell * dofs_per_line) - , dofs_per_face(GeometryInfo::vertices_per_face * dofs_per_vertex + - GeometryInfo::lines_per_face * dofs_per_line + - GeometryInfo::quads_per_face * dofs_per_quad) - , dofs_per_cell(GeometryInfo::vertices_per_cell * dofs_per_vertex + - GeometryInfo::lines_per_cell * dofs_per_line + - GeometryInfo::quads_per_cell * dofs_per_quad + - GeometryInfo::hexes_per_cell * dofs_per_hex) + (dim == 3 ? + ReferenceCell::internal::Info::get_face(cell_type, 0).n_vertices() * + dofs_per_vertex : + ReferenceCell::internal::Info::get_cell(cell_type).n_vertices() * + dofs_per_vertex) + + ReferenceCell::internal::Info::get_face(cell_type, 0).n_lines() * + dofs_per_line) + , dofs_per_face( + ReferenceCell::internal::Info::get_face(cell_type, 0).n_vertices() * + dofs_per_vertex + + ReferenceCell::internal::Info::get_face(cell_type, 0).n_lines() * + dofs_per_line + + (dim == 3 ? 1 : 0) * dofs_per_quad) + , dofs_per_cell( + ReferenceCell::internal::Info::get_cell(cell_type).n_vertices() * + dofs_per_vertex + + ReferenceCell::internal::Info::get_cell(cell_type).n_lines() * + dofs_per_line + + (dim == 2 ? + 1 : + (dim == 3 ? + ReferenceCell::internal::Info::get_cell(cell_type).n_faces() : + 0)) * + dofs_per_quad + + (dim == 3 ? 1 : 0) * dofs_per_hex) , components(n_components) , degree(degree) , conforming_space(conformity)