]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Avoid unnecessary inversion of a transformation matrix
authorMatthias Maier <tamiko@kyomu.43-1.org>
Sun, 30 Nov 2014 14:38:23 +0000 (15:38 +0100)
committerMatthias Maier <tamiko@kyomu.43-1.org>
Sun, 30 Nov 2014 14:42:53 +0000 (15:42 +0100)
source/dofs/dof_tools_constraints.cc

index cf1832a4940e9c5487d582a54fd379e7c0ca3cba..3811a3433c44f46cd3ae3a058fcfc97194f79530 100644 (file)
@@ -2129,19 +2129,35 @@ namespace DoFTools
         const FullMatrix<double> transformation =
             compute_transformation(fe, matrix, first_vector_components);
 
-        if (!face_2->has_children())
+        if (! face_2->has_children())
           {
-            FullMatrix<double> inverse(transformation.m());
-            inverse.invert(transformation);
+            // Performance hack: We do not need to compute an inverse if
+            // the matrix is the identity matrix.
+            if (first_vector_components.empty() && matrix.m() == 0)
+              {
+                set_periodicity_constraints(face_2,
+                                            face_1,
+                                            transformation,
+                                            constraint_matrix,
+                                            component_mask,
+                                            face_orientation,
+                                            face_flip,
+                                            face_rotation);
+              }
+            else
+              {
+                FullMatrix<double> inverse(transformation.m());
+                inverse.invert(transformation);
 
-            set_periodicity_constraints(face_2,
-                                        face_1,
-                                        inverse,
-                                        constraint_matrix,
-                                        component_mask,
-                                        face_orientation,
-                                        face_flip,
-                                        face_rotation);
+                set_periodicity_constraints(face_2,
+                                            face_1,
+                                            inverse,
+                                            constraint_matrix,
+                                            component_mask,
+                                            face_orientation,
+                                            face_flip,
+                                            face_rotation);
+              }
           }
         else
           {

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.