From d5fd2325fe159f3e03489674a2e6bf8c950654c7 Mon Sep 17 00:00:00 2001 From: Martin Kronbichler Date: Mon, 1 Sep 2014 22:10:58 +0200 Subject: [PATCH] Avoid setting the templated 'Number' to '0' (double) in trace(Tensor<2,dim,Number>). Enables using trace also with e.g. Tensor<2,dim,VectorizedArray >. --- include/deal.II/base/symmetric_tensor.h | 4 ++-- include/deal.II/base/tensor.h | 4 ++-- tests/matrix_free/matrix_vector_stokes.cc | 23 +++++++++---------- .../matrix_vector_stokes_noflux.cc | 2 +- 4 files changed, 16 insertions(+), 17 deletions(-) diff --git a/include/deal.II/base/symmetric_tensor.h b/include/deal.II/base/symmetric_tensor.h index 67710ad64e..aa913b69f8 100644 --- a/include/deal.II/base/symmetric_tensor.h +++ b/include/deal.II/base/symmetric_tensor.h @@ -2250,8 +2250,8 @@ double third_invariant (const SymmetricTensor<2,dim,Number> &t) template Number trace (const SymmetricTensor<2,dim,Number> &d) { - Number t=0; - for (unsigned int i=0; i &t) template Number trace (const Tensor<2,dim,Number> &d) { - Number t=0; - for (unsigned int i=0; i sym_grad_u = - velocity.get_symmetric_gradient (q); + Tensor<2,dim,vector_t> grad_u = velocity.get_gradient (q); vector_t pres = pressure.get_value(q); - vector_t div = -velocity.get_divergence(q); + vector_t div = -trace(grad_u); pressure.submit_value (div, q); // subtract p * I for (unsigned int d=0; d > phi_grads_u (dofs_per_cell); - std::vector div_phi_u (dofs_per_cell); - std::vector phi_p (dofs_per_cell); + std::vector > phi_grad_u (dofs_per_cell); + std::vector div_phi_u (dofs_per_cell); + std::vector phi_p (dofs_per_cell); typename DoFHandler::active_cell_iterator cell = dof_handler.begin_active(), @@ -237,16 +236,16 @@ void test () { for (unsigned int k=0; k sym_grad_u = velocity.get_symmetric_gradient (q); vector_t pres = pressure.get_value(q); - vector_t div = -velocity.get_divergence(q); + vector_t div = -trace(sym_grad_u); pressure.submit_value (div, q); // subtract p * I -- 2.39.5