]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Add testcases.
authorWolfgang Bangerth <bangerth@math.tamu.edu>
Wed, 11 Feb 2015 23:02:09 +0000 (17:02 -0600)
committerWolfgang Bangerth <bangerth@math.tamu.edu>
Thu, 12 Feb 2015 13:31:44 +0000 (07:31 -0600)
tests/base/product_type_02.cc [new file with mode: 0644]
tests/base/product_type_02.output [new file with mode: 0644]
tests/base/product_type_03.cc [new file with mode: 0644]
tests/base/product_type_03.output [new file with mode: 0644]

diff --git a/tests/base/product_type_02.cc b/tests/base/product_type_02.cc
new file mode 100644 (file)
index 0000000..c75d9a7
--- /dev/null
@@ -0,0 +1,69 @@
+// ---------------------------------------------------------------------
+//
+// Copyright (C) 2015 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.
+//
+// ---------------------------------------------------------------------
+
+
+// test that the product between a tensor of rank 1 and a scalar
+// results a result type as expected
+
+#include "../tests.h"
+#include <iomanip>
+#include <iomanip>
+#include <fstream>
+#include <cmath>
+#include <typeinfo>
+#include <complex>
+
+#include <deal.II/base/template_constraints.h>
+#include <deal.II/base/tensor.h>
+
+
+template <typename T, typename U, typename CompareType>
+void check()
+{
+  Assert (typeid(T() * U()) == typeid(CompareType),
+         ExcInternalError());
+  Assert (typeid(T() * U()) == typeid(CompareType),
+         ExcInternalError());
+}
+
+
+int main()
+{
+  std::ofstream logfile("output");
+  deallog.attach(logfile);
+  deallog.depth_console(0);
+  deallog.threshold_double(1.e-10);
+
+  // check product of scalars
+  check<Tensor<1,1,double>,double,Tensor<1,1,double> >();
+  check<double,Tensor<1,1,double>,Tensor<1,1,double> >();
+
+  check<Tensor<1,1,double>,float,Tensor<1,1,double> >();
+  check<float,Tensor<1,1,double>,Tensor<1,1,double> >();
+
+  check<Tensor<1,1,double>,std::complex<double>,Tensor<1,1,std::complex<double> > >();
+  check<std::complex<double>,Tensor<1,1,double>,Tensor<1,1,std::complex<double> > >();
+
+  check<Tensor<1,1,double>,std::complex<float>,Tensor<1,1,std::complex<double> > >();
+  check<std::complex<float>,Tensor<1,1,double>,Tensor<1,1,std::complex<double> > >();
+
+  check<Tensor<1,1,float>,std::complex<double>,Tensor<1,1,std::complex<double> > >();
+  check<std::complex<double>,Tensor<1,1,float>,Tensor<1,1,std::complex<double> > >();
+
+  check<Tensor<1,1,float>,std::complex<float>,Tensor<1,1,std::complex<float> > >();
+  check<std::complex<float>,Tensor<1,1,float>,Tensor<1,1,std::complex<float> > >();
+  
+  deallog << "OK" << std::endl;
+}
diff --git a/tests/base/product_type_02.output b/tests/base/product_type_02.output
new file mode 100644 (file)
index 0000000..0fd8fc1
--- /dev/null
@@ -0,0 +1,2 @@
+
+DEAL::OK
diff --git a/tests/base/product_type_03.cc b/tests/base/product_type_03.cc
new file mode 100644 (file)
index 0000000..7de4b4b
--- /dev/null
@@ -0,0 +1,69 @@
+// ---------------------------------------------------------------------
+//
+// Copyright (C) 2015 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.
+//
+// ---------------------------------------------------------------------
+
+
+// test that the product between a tensor of rank 2 and a scalar
+// results a result type as expected
+
+#include "../tests.h"
+#include <iomanip>
+#include <iomanip>
+#include <fstream>
+#include <cmath>
+#include <typeinfo>
+#include <complex>
+
+#include <deal.II/base/template_constraints.h>
+#include <deal.II/base/tensor.h>
+
+
+template <typename T, typename U, typename CompareType>
+void check()
+{
+  Assert (typeid(T() * U()) == typeid(CompareType),
+         ExcInternalError());
+  Assert (typeid(T() * U()) == typeid(CompareType),
+         ExcInternalError());
+}
+
+
+int main()
+{
+  std::ofstream logfile("output");
+  deallog.attach(logfile);
+  deallog.depth_console(0);
+  deallog.threshold_double(1.e-10);
+
+  // check product of scalars
+  check<Tensor<2,1,double>,double,Tensor<2,1,double> >();
+  check<double,Tensor<2,1,double>,Tensor<2,1,double> >();
+
+  check<Tensor<2,1,double>,float,Tensor<2,1,double> >();
+  check<float,Tensor<2,1,double>,Tensor<2,1,double> >();
+
+  check<Tensor<2,1,double>,std::complex<double>,Tensor<2,1,std::complex<double> > >();
+  check<std::complex<double>,Tensor<2,1,double>,Tensor<2,1,std::complex<double> > >();
+
+  check<Tensor<2,1,double>,std::complex<float>,Tensor<2,1,std::complex<double> > >();
+  check<std::complex<float>,Tensor<2,1,double>,Tensor<2,1,std::complex<double> > >();
+
+  check<Tensor<2,1,float>,std::complex<double>,Tensor<2,1,std::complex<double> > >();
+  check<std::complex<double>,Tensor<2,1,float>,Tensor<2,1,std::complex<double> > >();
+
+  check<Tensor<2,1,float>,std::complex<float>,Tensor<2,1,std::complex<float> > >();
+  check<std::complex<float>,Tensor<2,1,float>,Tensor<2,1,std::complex<float> > >();
+  
+  deallog << "OK" << std::endl;
+}
diff --git a/tests/base/product_type_03.output b/tests/base/product_type_03.output
new file mode 100644 (file)
index 0000000..0fd8fc1
--- /dev/null
@@ -0,0 +1,2 @@
+
+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.