]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Simplify symmetrize(Tensor<2,dim>) 8428/head
authorMartin Kronbichler <kronbichler@lnm.mw.tum.de>
Tue, 30 Jul 2019 08:24:56 +0000 (10:24 +0200)
committerMartin Kronbichler <kronbichler@lnm.mw.tum.de>
Tue, 30 Jul 2019 08:24:56 +0000 (10:24 +0200)
include/deal.II/base/symmetric_tensor.h

index 127a145a5b34a0abf900173ac27c89372e946469..4e61bcc597f1b80be2081183bcb4b49d4e17b721 100644 (file)
@@ -3469,15 +3469,14 @@ template <int dim, typename Number>
 DEAL_II_CONSTEXPR inline DEAL_II_ALWAYS_INLINE SymmetricTensor<2, dim, Number>
                                                symmetrize(const Tensor<2, dim, Number> &t)
 {
-  Number array[(dim * dim + dim) / 2];
+  SymmetricTensor<2, dim, Number> result;
   for (unsigned int d = 0; d < dim; ++d)
-    array[d] = t[d][d];
-  Number half = {};
-  half        = 0.5;
-  for (unsigned int d = 0, c = dim; d < dim; ++d)
-    for (unsigned int e = d + 1; e < dim; ++e, ++c)
-      array[c] = (t[d][e] + t[e][d]) * half;
-  return SymmetricTensor<2, dim, Number>(array);
+    result[d][d] = t[d][d];
+  Number half = 0.5;
+  for (unsigned int d = 0; d < dim; ++d)
+    for (unsigned int e = d + 1; e < dim; ++e)
+      result[d][e] = (t[d][e] + t[e][d]) * half;
+  return result;
 }
 
 

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.