From: Matthias Maier Date: Sun, 30 Nov 2014 14:38:23 +0000 (+0100) Subject: Avoid unnecessary inversion of a transformation matrix X-Git-Tag: v8.2.0-rc1~36^2~2 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=eca43782c93a0fd7ea4186a1a0d59c5545abf34a;p=dealii.git Avoid unnecessary inversion of a transformation matrix --- diff --git a/source/dofs/dof_tools_constraints.cc b/source/dofs/dof_tools_constraints.cc index cf1832a494..3811a3433c 100644 --- a/source/dofs/dof_tools_constraints.cc +++ b/source/dofs/dof_tools_constraints.cc @@ -2129,19 +2129,35 @@ namespace DoFTools const FullMatrix transformation = compute_transformation(fe, matrix, first_vector_components); - if (!face_2->has_children()) + if (! face_2->has_children()) { - FullMatrix 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 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 {