]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Add a couple of static asserts to SolutionTransfer.
authorWolfgang Bangerth <bangerth@colostate.edu>
Mon, 19 Jun 2017 11:58:14 +0000 (05:58 -0600)
committerWolfgang Bangerth <bangerth@colostate.edu>
Mon, 19 Jun 2017 11:58:14 +0000 (05:58 -0600)
This class (in both of its incarnations) takes both a dimension and a DoFHandler
as template argument. The dimension of the DoFHandler better match the explicitly
given dimension. The added static_assert checks that and prevents instantiation
of the class if that is not the case.

include/deal.II/distributed/solution_transfer.h
include/deal.II/numerics/solution_transfer.h

index 6717495d6e4714f73748b8eaa1b30832585cb7e6..2f14a8b4e07b0d0205fc2e26cf2fe509fc2f85f9 100644 (file)
@@ -112,9 +112,15 @@ namespace parallel
      * @ingroup distributed
      * @author Timo Heister, 2009-2011
      */
-    template<int dim, typename VectorType, typename DoFHandlerType=DoFHandler<dim> >
+    template <int dim,
+              typename VectorType,
+              typename DoFHandlerType = DoFHandler<dim> >
     class SolutionTransfer
     {
+      static_assert (dim == DoFHandlerType::dimension,
+                     "The dimension explicitly provided as a template "
+                     "argument, and the dimension of the DoFHandlerType "
+                     "template argument must match.");
     public:
       /**
        * Constructor, takes the current DoFHandler as argument.
index 3ed4f297ac4aa0b94ae25e6474a4d7f78ecd062b..b033ca6203c454c4dc84dfca512eaa0a056a2c00 100644 (file)
@@ -288,10 +288,15 @@ DEAL_II_NAMESPACE_OPEN
  * @author Ralf Hartmann, 1999, Oliver Kayser-Herold and Wolfgang Bangerth,
  * 2006, Wolfgang Bangerth 2014
  */
-template<int dim, typename VectorType=Vector<double>,
-         typename DoFHandlerType=DoFHandler<dim> >
+template<int dim,
+         typename VectorType = Vector<double>,
+         typename DoFHandlerType = DoFHandler<dim> >
 class SolutionTransfer
 {
+  static_assert (dim == DoFHandlerType::dimension,
+                 "The dimension explicitly provided as a template "
+                 "argument, and the dimension of the DoFHandlerType "
+                 "template argument must match.");
 public:
 
   /**

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.