]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Small performance hack.
authorWolfgang Bangerth <bangerth@math.tamu.edu>
Tue, 14 Apr 1998 13:37:24 +0000 (13:37 +0000)
committerWolfgang Bangerth <bangerth@math.tamu.edu>
Tue, 14 Apr 1998 13:37:24 +0000 (13:37 +0000)
git-svn-id: https://svn.dealii.org/trunk@170 0785d39b-7218-0410-832d-ea1e28bc413d

deal.II/deal.II/Attic/examples/poisson/equation.cc
tests/big-tests/poisson/equation.cc

index 405d59704fa18a0c05ed61d2f7a256993a8da1d9..20f1724589735f95264481f03557b32e9bebbc2e 100644 (file)
@@ -30,16 +30,23 @@ void PoissonEquation<2>::assemble (dFMatrix            &cell_matrix,
                                   dVector             &rhs,
                                   const FEValues<2>   &fe_values,
                                   const Triangulation<2>::cell_iterator &) const {
+  const vector<vector<Point<2> > >&gradients = fe_values.get_shape_grads ();
+  const dFMatrix       &values    = fe_values.get_shape_values ();
+  vector<double>        rhs_values;
+  const vector<double> &weights   = fe_values.get_JxW_values ();
+
+  right_hand_side.value_list (fe_values.get_quadrature_points(), rhs_values);
+   
   for (unsigned int point=0; point<fe_values.n_quadrature_points; ++point)
     for (unsigned int i=0; i<fe_values.total_dofs; ++i) 
       {
        for (unsigned int j=0; j<fe_values.total_dofs; ++j)
-         cell_matrix(i,j) += (fe_values.shape_grad(i,point) *
-                              fe_values.shape_grad(j,point)) *
-                             fe_values.JxW(point);
-       rhs(i) += fe_values.shape_value(i,point) *
-                 right_hand_side(fe_values.quadrature_point(point)) *
-                 fe_values.JxW(point);
+         cell_matrix(i,j) += (gradients[i][point] *
+                              gradients[j][point]) *
+                             weights[point];
+       rhs(i) += values(i,point) *
+                 rhs_values[point] *
+                 weights[point];
       };
 };
 
index 405d59704fa18a0c05ed61d2f7a256993a8da1d9..20f1724589735f95264481f03557b32e9bebbc2e 100644 (file)
@@ -30,16 +30,23 @@ void PoissonEquation<2>::assemble (dFMatrix            &cell_matrix,
                                   dVector             &rhs,
                                   const FEValues<2>   &fe_values,
                                   const Triangulation<2>::cell_iterator &) const {
+  const vector<vector<Point<2> > >&gradients = fe_values.get_shape_grads ();
+  const dFMatrix       &values    = fe_values.get_shape_values ();
+  vector<double>        rhs_values;
+  const vector<double> &weights   = fe_values.get_JxW_values ();
+
+  right_hand_side.value_list (fe_values.get_quadrature_points(), rhs_values);
+   
   for (unsigned int point=0; point<fe_values.n_quadrature_points; ++point)
     for (unsigned int i=0; i<fe_values.total_dofs; ++i) 
       {
        for (unsigned int j=0; j<fe_values.total_dofs; ++j)
-         cell_matrix(i,j) += (fe_values.shape_grad(i,point) *
-                              fe_values.shape_grad(j,point)) *
-                             fe_values.JxW(point);
-       rhs(i) += fe_values.shape_value(i,point) *
-                 right_hand_side(fe_values.quadrature_point(point)) *
-                 fe_values.JxW(point);
+         cell_matrix(i,j) += (gradients[i][point] *
+                              gradients[j][point]) *
+                             weights[point];
+       rhs(i) += values(i,point) *
+                 rhs_values[point] *
+                 weights[point];
       };
 };
 

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.