]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Simplify some code. 7674/head
authorWolfgang Bangerth <bangerth@colostate.edu>
Fri, 1 Feb 2019 15:04:58 +0000 (08:04 -0700)
committerWolfgang Bangerth <bangerth@colostate.edu>
Sat, 2 Feb 2019 15:14:42 +0000 (08:14 -0700)
include/deal.II/base/tensor_function.templates.h

index d760d22070bf2fe47ffd432d6ca76178d8611c84..11c2f54cb73aec6dede6bc860e53963c5270943d 100644 (file)
@@ -123,9 +123,8 @@ template <int rank, int dim, typename Number>
 typename TensorFunction<rank, dim, Number>::gradient_type
 ConstantTensorFunction<rank, dim, Number>::gradient(const Point<dim> &) const
 {
-  static const Tensor<rank + 1, dim, Number> zero{};
-
-  return zero;
+  // Return a zero (=default initialized) tensor
+  return {};
 }
 
 
@@ -140,10 +139,10 @@ ConstantTensorFunction<rank, dim, Number>::gradient_list(
   Assert(gradients.size() == points.size(),
          ExcDimensionMismatch(gradients.size(), points.size()));
 
-  static const Tensor<rank + 1, dim, Number> zero{};
-
-  for (unsigned int i = 0; i < gradients.size(); ++i)
-    gradients[i] = zero;
+  // Return an array of zero tensors.
+  std::fill(gradients.begin(),
+            gradients.end(),
+            typename TensorFunction<rank, dim, Number>::gradient_type());
 }
 
 

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.