From 947a00d8bdd5d3bd00f730c02912d72f5c200891 Mon Sep 17 00:00:00 2001 From: Wolfgang Bangerth Date: Mon, 13 Mar 2023 15:29:58 -0600 Subject: [PATCH] Introduce a concept for MeshType. --- include/deal.II/base/template_constraints.h | 73 +++++++++++++++++++++ 1 file changed, 73 insertions(+) diff --git a/include/deal.II/base/template_constraints.h b/include/deal.II/base/template_constraints.h index 208a99877e..7d635356aa 100644 --- a/include/deal.II/base/template_constraints.h +++ b/include/deal.II/base/template_constraints.h @@ -749,6 +749,7 @@ namespace LinearAlgebra #endif + /** * A namespace that is used to declare concepts used in C++20-style * `requires` clauses. @@ -877,6 +878,78 @@ namespace concepts } // namespace concepts +template +DEAL_II_CXX20_REQUIRES((concepts::is_valid_dim_spacedim)) +class Triangulation; + +template +DEAL_II_CXX20_REQUIRES((concepts::is_valid_dim_spacedim)) +class DoFHandler; + +namespace parallel +{ + namespace distributed + { + template + class Triangulation; + } + namespace shared + { + template + class Triangulation; + } + namespace fullydistributed + { + template + class Triangulation; + } +} // namespace parallel + +namespace concepts +{ + namespace internal + { + template + constexpr bool is_triangulation_or_dof_handler = false; + + template + constexpr bool + is_triangulation_or_dof_handler> = true; + + template + constexpr bool is_triangulation_or_dof_handler< + parallel::distributed::Triangulation> = true; + + template + constexpr bool is_triangulation_or_dof_handler< + parallel::shared::Triangulation> = true; + + template + constexpr bool is_triangulation_or_dof_handler< + parallel::fullydistributed::Triangulation> = true; + + template + constexpr bool is_triangulation_or_dof_handler> = + true; + } // namespace internal + + +#if defined(DEAL_II_HAVE_CXX20) || defined(DOXYGEN) + /** + * A concept that is used to check whether the `MeshType` template + * type used in many functions in namespace GridTools and + * VectorTools is in fact a "mesh" in the sense expected by these + * functions. Specifically, this means that the type is either a + * Triangulation or a DoFHandler type. + */ + template + concept is_triangulation_or_dof_handler = + internal::is_triangulation_or_dof_handler; +#endif +} // namespace concepts + + + DEAL_II_NAMESPACE_CLOSE #endif -- 2.39.5