]> https://gitweb.dealii.org/ - dealii.git/commitdiff
exploit symmetries in Local integrators of mass and laplace matrices 943/head
authorDenis Davydov <davydden@gmail.com>
Tue, 19 May 2015 05:31:36 +0000 (07:31 +0200)
committerDenis Davydov <davydden@gmail.com>
Tue, 19 May 2015 06:12:37 +0000 (08:12 +0200)
include/deal.II/integrators/l2.h
include/deal.II/integrators/laplace.h

index 1b54ef493b599cda65532f8e9fb55b25244ade46..24320a8004997faa64b4f09eae520e0b9f9429dd 100644 (file)
@@ -63,12 +63,17 @@ namespace LocalIntegrators
           const double dx = fe.JxW(k) * factor;
 
           for (unsigned int i=0; i<n_dofs; ++i)
-            for (unsigned int j=0; j<n_dofs; ++j)
+            for (unsigned int j=i; j<n_dofs; ++j)
               for (unsigned int d=0; d<n_components; ++d)
                 M(i,j) += dx
                           * fe.shape_value_component(j,k,d)
                           * fe.shape_value_component(i,k,d);
         }
+
+      // exploit symmetry
+      for (unsigned int i=0; i<n_dofs; ++i)
+        for (unsigned int j=i+1; j<n_dofs; ++j)
+          M(j,i) = M(i,j);
     }
 
     /**
@@ -103,12 +108,17 @@ namespace LocalIntegrators
           const double dx = fe.JxW(k) * weights[k];
 
           for (unsigned int i=0; i<n_dofs; ++i)
-            for (unsigned int j=0; j<n_dofs; ++j)
+            for (unsigned int j=i; j<n_dofs; ++j)
               for (unsigned int d=0; d<n_components; ++d)
                 M(i,j) += dx
                           * fe.shape_value_component(j,k,d)
                           * fe.shape_value_component(i,k,d);
         }
+
+      //exploit symmetry
+      for (unsigned int i=0; i<n_dofs; ++i)
+        for (unsigned int j=i+1; j<n_dofs; ++j)
+          M(j,i) = M(i,j);
     }
 
     /**
index ec2878d7d838da32924994c93222324e75fa4ca3..e84b384001301ee4a5c37afd7ecbd9c037f2d59d 100644 (file)
@@ -62,12 +62,18 @@ namespace LocalIntegrators
           const double dx = fe.JxW(k) * factor;
           for (unsigned int i=0; i<n_dofs; ++i)
             {
-              for (unsigned int j=0; j<n_dofs; ++j)
+              for (unsigned int j=i; j<n_dofs; ++j)
                 for (unsigned int d=0; d<n_components; ++d)
                   M(i,j) += dx *
                             (fe.shape_grad_component(j,k,d) * fe.shape_grad_component(i,k,d));
             }
         }
+
+      // exploit symmetry
+      for (unsigned int i=0; i<n_dofs; ++i)
+        for (unsigned int j=i+1; j<n_dofs; ++j)
+          M(j,i) = M(i,j);
+
     }
 
     /**

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.