]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Add NumberType to CurlType.
authorLuca Heltai <luca.heltai@sissa.it>
Tue, 8 Aug 2017 21:26:55 +0000 (15:26 -0600)
committerLuca Heltai <luca.heltai@sissa.it>
Tue, 8 Aug 2017 21:26:55 +0000 (15:26 -0600)
include/deal.II/fe/fe_values.h
tests/fe/fe_values_view_number_01.cc [new file with mode: 0644]
tests/fe/fe_values_view_number_01.output [new file with mode: 0644]

index 73cbefd5d21da539c74fc5d6f1e1c6d737bfddfc..d49cf35727b70835da5a4af1125a503c1a60d694 100644 (file)
@@ -56,7 +56,7 @@ namespace internal
    * A class whose specialization is used to define what type the curl of a
    * vector valued function corresponds to.
    */
-  template <int dim>
+  template <int dim, class NumberType=double>
   struct CurlType;
 
   /**
@@ -65,10 +65,10 @@ namespace internal
    *
    * In 1d, the curl is a scalar.
    */
-  template <>
-  struct CurlType<1>
+  template <class NumberType>
+  struct CurlType<1, NumberType>
   {
-    typedef Tensor<1,1>     type;
+    typedef Tensor<1,1,NumberType>     type;
   };
 
   /**
@@ -77,10 +77,10 @@ namespace internal
    *
    * In 2d, the curl is a scalar.
    */
-  template <>
-  struct CurlType<2>
+  template <class NumberType>
+  struct CurlType<2,NumberType>
   {
-    typedef Tensor<1,1>     type;
+    typedef Tensor<1,1,NumberType>     type;
   };
 
   /**
@@ -89,10 +89,10 @@ namespace internal
    *
    * In 3d, the curl is a vector.
    */
-  template <>
-  struct CurlType<3>
+  template <class NumberType>
+  struct CurlType<3,NumberType>
   {
-    typedef Tensor<1,3>     type;
+    typedef Tensor<1,3,NumberType>     type;
   };
 }
 
diff --git a/tests/fe/fe_values_view_number_01.cc b/tests/fe/fe_values_view_number_01.cc
new file mode 100644 (file)
index 0000000..4d33b42
--- /dev/null
@@ -0,0 +1,43 @@
+// ---------------------------------------------------------------------
+//
+// Copyright (C) 2007 - 2016 by the deal.II authors
+//
+// This file is part of the deal.II library.
+//
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
+// Check that we get the right type of CurlType with Custom number type.
+
+#include "../tests.h"
+#include <deal.II/fe/fe_values.h>
+
+#include <fstream>
+
+
+
+template <typename Number>
+void test ()
+{
+  if (typeid(typename internal::CurlType<1, Number>::type) != typeid(Tensor<1,1,Number>) )
+    deallog << "NOT OK!" << std::endl;
+  if (typeid(typename internal::CurlType<2, Number>::type) != typeid(Tensor<1,1,Number>) )
+    deallog << "NOT OK!" << std::endl;
+  if (typeid(typename internal::CurlType<3, Number>::type) != typeid(Tensor<1,3,Number>) )
+    deallog << "NOT OK!" << std::endl;
+  deallog << "OK" << std::endl;
+}
+
+
+int main()
+{
+  initlog();
+  test<double>();
+  test<float>();
+}
diff --git a/tests/fe/fe_values_view_number_01.output b/tests/fe/fe_values_view_number_01.output
new file mode 100644 (file)
index 0000000..8b3b075
--- /dev/null
@@ -0,0 +1,3 @@
+
+DEAL::OK
+DEAL::OK

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.