From 317dbdacbff6b9fef23fc861d89d4a9d6bcb5f1a Mon Sep 17 00:00:00 2001 From: Luca Heltai Date: Mon, 12 Jun 2017 10:08:00 +0200 Subject: [PATCH] Fixed Determinant in DerivativeForm. --- include/deal.II/base/derivative_form.h | 7 ++-- tests/base/derivative_forms_04.cc | 46 ++++++++++++++++++++++++++ tests/base/derivative_forms_04.output | 7 ++++ 3 files changed, 56 insertions(+), 4 deletions(-) create mode 100644 tests/base/derivative_forms_04.cc create mode 100644 tests/base/derivative_forms_04.output diff --git a/include/deal.II/base/derivative_form.h b/include/deal.II/base/derivative_form.h index 6feebed47b..2dc2f13a6a 100644 --- a/include/deal.II/base/derivative_form.h +++ b/include/deal.II/base/derivative_form.h @@ -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::norm () const template inline -double -DerivativeForm::determinant () const +Number DerivativeForm::determinant() const { Assert( order==1, ExcMessage("Only for order == 1.")); if (dim == spacedim) @@ -337,7 +336,7 @@ DerivativeForm::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 + + +template +void test() +{ + DerivativeForm<1,dim,spacedim,std::complex > dF; + for (unsigned int i=0; i(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 index 0000000000..16e7b65d28 --- /dev/null +++ b/tests/base/derivative_forms_04.output @@ -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) -- 2.39.5