]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Optimize SphericalManifold::get_new_point() 3654/head
authorRene Gassmoeller <rene.gassmoeller@mailbox.org>
Sat, 3 Dec 2016 00:44:29 +0000 (17:44 -0700)
committerRene Gassmoeller <rene.gassmoeller@mailbox.org>
Sat, 3 Dec 2016 00:44:29 +0000 (17:44 -0700)
source/grid/manifold_lib.cc

index 431cbe8d66a4fb39642004d26fe5ca18d4a9cb77..ef7e48ec69817cc3731e6163925ad62d1eb4b823 100644 (file)
@@ -275,13 +275,17 @@ SphericalManifold<dim,spacedim>::
 get_new_point (const std::vector<Point<spacedim> > &vertices,
                const std::vector<double> &weights) const
 {
+  const unsigned int n_points = vertices.size();
+
   double rho = 0.0;
   Tensor<1,spacedim> candidate;
-  for (unsigned int i = 0; i<vertices.size(); i++)
+  for (unsigned int i = 0; i<n_points; i++)
     {
-      rho += (vertices[i]-center).norm()*weights[i];
-      candidate += (vertices[i]-center)*weights[i];
+      const Tensor<1,spacedim> direction (vertices[i]-center);
+      rho += direction.norm()*weights[i];
+      candidate += direction*weights[i];
     }
+
   // Unit norm direction.
   candidate /= candidate.norm();
 

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.