]> https://gitweb.dealii.org/ - dealii.git/commitdiff
make_periodicity_constraints: sort dofs when adding equality constraints
authorDenis Davydov <davydden@gmail.com>
Thu, 29 Nov 2018 17:21:25 +0000 (18:21 +0100)
committerMatthias Maier <tamiko@43-1.org>
Wed, 23 Jan 2019 17:05:29 +0000 (11:05 -0600)
When we add add equality constraints of the form dof2 = c dof1, we now
ensure that dof2 > dof1. This helps to avoid having inconsistent
equality constraints for different MPI processes.
Unfortunately, we can only do this if both, dof2 and dof1 are not
constrained. Otherwise the order is forced.

source/dofs/dof_tools_constraints.cc

index 3c098a614d1ba9bfb1efb6790af046b32e00a44b..ecbe6ea5961d058b19585425176d4086ad3efeae 100644 (file)
@@ -2035,11 +2035,19 @@ namespace DoFTools
             cell_to_rotated_face_index[fe.face_to_cell_index(
               target, 0, face_orientation, face_flip, face_rotation)];
 
-          const bool face_2_constrained =
-            affine_constraints.is_constrained(dofs_2[i]);
-          const auto dof_left  = face_2_constrained ? dofs_1[j] : dofs_2[i];
-          const auto dof_right = face_2_constrained ? dofs_2[i] : dofs_1[j];
-          factor               = face_2_constrained ? 1. / factor : factor;
+          auto dof_left  = dofs_1[j];
+          auto dof_right = dofs_2[i];
+
+          // If dof_left is already constrained, or dof_left < dof_right we
+          // flip the order to ensure that dofs are constrained in a stable
+          // manner on different MPI processes.
+          if (affine_constraints.is_constrained(dof_left) ||
+              (dof_left < dof_right &&
+               !affine_constraints.is_constrained(dof_right)))
+            {
+              std::swap(dof_left, dof_right);
+              factor = 1. / factor;
+            }
 
           // Next, we try to enter the constraint
           //   dof_left = factor * dof_right;
@@ -2196,7 +2204,6 @@ namespace DoFTools
         }
       return transformation;
     }
-
   } /*namespace*/
 
 

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.