From: Martin Kronbichler Date: Mon, 1 Sep 2014 20:10:58 +0000 (+0200) Subject: Avoid setting the templated 'Number' to '0' (double) in trace(Tensor<2,dim,Number>). X-Git-Tag: v8.2.0-rc1~168^2 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=refs%2Fpull%2F123%2Fhead;p=dealii.git 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 >. --- 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