]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Fixed Determinant in DerivativeForm. 4507/head
authorLuca Heltai <luca.heltai@sissa.it>
Mon, 12 Jun 2017 08:08:00 +0000 (10:08 +0200)
committerLuca Heltai <luca.heltai@sissa.it>
Mon, 12 Jun 2017 08:08:47 +0000 (10:08 +0200)
include/deal.II/base/derivative_form.h
tests/base/derivative_forms_04.cc [new file with mode: 0644]
tests/base/derivative_forms_04.output [new file with mode: 0644]

index 6feebed47be5a6957278d7300108086c17e3eecb..2dc2f13a6a19b5b77c3af476ffe04925daf8ab63 100644 (file)
@@ -116,7 +116,7 @@ public:
    * transformation F. That is to say if $DF$ is square, it computes
    * $\det(DF)$, in case DF is not square returns $\sqrt{\det(DF^T * DF)}$.
    */
-  double determinant () const;
+  Number determinant () const;
 
   /**
    * Assuming that the current object stores the Jacobian of a mapping
@@ -325,8 +325,7 @@ DerivativeForm<order,dim,spacedim,Number>::norm () const
 
 template <int order, int dim, int spacedim, typename Number>
 inline
-double
-DerivativeForm<order,dim,spacedim,Number>::determinant () const
+Number DerivativeForm<order, dim, spacedim, Number>::determinant() const
 {
   Assert( order==1, ExcMessage("Only for order == 1."));
   if (dim == spacedim)
@@ -337,7 +336,7 @@ DerivativeForm<order,dim,spacedim,Number>::determinant () const
   else
     {
       Assert( spacedim>dim, ExcMessage("Only for spacedim>dim."));
-      const DerivativeForm<1,spacedim,dim> DF_t = this->transpose();
+      const DerivativeForm<1,spacedim,dim,Number> DF_t = this->transpose();
       Tensor<2,dim,Number> G; //First fundamental form
       for (unsigned int i=0; i<dim; ++i)
         for (unsigned int j=0; j<dim; ++j)
diff --git a/tests/base/derivative_forms_04.cc b/tests/base/derivative_forms_04.cc
new file mode 100644 (file)
index 0000000..19743f6
--- /dev/null
@@ -0,0 +1,46 @@
+// ---------------------------------------------------------------------
+//
+// Copyright (C) 2000 - 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.
+//
+// ---------------------------------------------------------------------
+
+// exercise DerivativeForm::norm() for complex data types
+
+
+#include "../tests.h"
+#include <deal.II/base/derivative_form.h>
+
+
+template<int dim, int spacedim>
+void test()
+{
+  DerivativeForm<1,dim,spacedim,std::complex<double> > dF;
+  for (unsigned int i=0; i<spacedim; ++i)
+    for (unsigned int j=0; j<dim; ++j)
+      {
+        dF[i][j] = std::complex<double>(i+2*j+1,i+2*j+1);
+      }
+
+  // output the determinants of these objects
+  deallog << "det(dF): " << dF.determinant() << std::endl;
+}
+
+int main()
+{
+  initlog();
+  test<1,1>();
+  test<1,2>();
+  test<1,3>();
+  test<2,2>();
+  test<2,3>();
+  test<3,3>();
+}
diff --git a/tests/base/derivative_forms_04.output b/tests/base/derivative_forms_04.output
new file mode 100644 (file)
index 0000000..16e7b65
--- /dev/null
@@ -0,0 +1,7 @@
+
+DEAL::det(dF): (1.00000,1.00000)
+DEAL::det(dF): (2.23607,2.23607)
+DEAL::det(dF): (3.74166,3.74166)
+DEAL::det(dF): (0.00000,-4.00000)
+DEAL::det(dF): (5.99952e-16,9.79796)
+DEAL::det(dF): (0.00000,0.00000)

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.