]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Introduce a concept for MeshType.
authorWolfgang Bangerth <bangerth@colostate.edu>
Mon, 13 Mar 2023 21:29:58 +0000 (15:29 -0600)
committerWolfgang Bangerth <bangerth@colostate.edu>
Mon, 20 Mar 2023 23:46:18 +0000 (17:46 -0600)
include/deal.II/base/template_constraints.h

index 208a99877ec0ddfddf37a9511834c9d62e313a34..7d635356aa98df016291c6fe2a82bcde805d96d1 100644 (file)
@@ -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 <int dim, int spacedim>
+DEAL_II_CXX20_REQUIRES((concepts::is_valid_dim_spacedim<dim, spacedim>))
+class Triangulation;
+
+template <int dim, int spacedim>
+DEAL_II_CXX20_REQUIRES((concepts::is_valid_dim_spacedim<dim, spacedim>))
+class DoFHandler;
+
+namespace parallel
+{
+  namespace distributed
+  {
+    template <int dim, int spacedim>
+    class Triangulation;
+  }
+  namespace shared
+  {
+    template <int dim, int spacedim>
+    class Triangulation;
+  }
+  namespace fullydistributed
+  {
+    template <int dim, int spacedim>
+    class Triangulation;
+  }
+} // namespace parallel
+
+namespace concepts
+{
+  namespace internal
+  {
+    template <typename T>
+    constexpr bool is_triangulation_or_dof_handler = false;
+
+    template <int dim, int spacedim>
+    constexpr bool
+      is_triangulation_or_dof_handler<Triangulation<dim, spacedim>> = true;
+
+    template <int dim, int spacedim>
+    constexpr bool is_triangulation_or_dof_handler<
+      parallel::distributed::Triangulation<dim, spacedim>> = true;
+
+    template <int dim, int spacedim>
+    constexpr bool is_triangulation_or_dof_handler<
+      parallel::shared::Triangulation<dim, spacedim>> = true;
+
+    template <int dim, int spacedim>
+    constexpr bool is_triangulation_or_dof_handler<
+      parallel::fullydistributed::Triangulation<dim, spacedim>> = true;
+
+    template <int dim, int spacedim>
+    constexpr bool is_triangulation_or_dof_handler<DoFHandler<dim, spacedim>> =
+      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 <typename MeshType>
+  concept is_triangulation_or_dof_handler =
+    internal::is_triangulation_or_dof_handler<MeshType>;
+#endif
+} // namespace concepts
+
+
+
 DEAL_II_NAMESPACE_CLOSE
 
 #endif

In the beginning the Universe was created. This has made a lot of people very angry and has been widely regarded as a bad move.

Douglas Adams


Typeset in Trocchi and Trocchi Bold Sans Serif.