]> https://gitweb.dealii.org/ - dealii-svn.git/commitdiff
Next try for a sane interface
authormaier <maier@0785d39b-7218-0410-832d-ea1e28bc413d>
Fri, 21 Feb 2014 18:50:42 +0000 (18:50 +0000)
committermaier <maier@0785d39b-7218-0410-832d-ea1e28bc413d>
Fri, 21 Feb 2014 18:50:42 +0000 (18:50 +0000)
git-svn-id: https://svn.dealii.org/branches/branch_periodic_bc@32527 0785d39b-7218-0410-832d-ea1e28bc413d

deal.II/include/deal.II/dofs/dof_tools.h
deal.II/include/deal.II/grid/grid_tools.h
deal.II/source/dofs/dof_tools_constraints.cc
deal.II/source/dofs/dof_tools_constraints.inst.in
deal.II/source/grid/grid_tools.cc
deal.II/source/grid/grid_tools.inst.in

index 889cae42608b8be471db445531984a826e829955..3b82ea25c13b459eea88473ba3eb1a8bd242349c 100644 (file)
@@ -870,8 +870,8 @@ namespace DoFTools
    const bool                                  face_orientation = true,
    const bool                                  face_flip = false,
    const bool                                  face_rotation = false,
-   const FullMatrix<double>                    &matrix = IdentityMatrix(FaceIterator::space_dimension),
-   const bool                                  rotation_matrix = true);
+   const FullMatrix<double>                    &matrix = FullMatrix<double>(),
+   const std::vector<unsigned int>             &first_vector_components = std::vector<unsigned int>());
 
 
 
index 96308f07133fee2363a1b3b95c0363492e531910..5844243ead70a5bb00417bbb30ea46604d3dd228 100644 (file)
@@ -1018,19 +1018,20 @@ namespace GridTools
     /**
      * A matrix that describes how vector valued DoFs of the first face
      * should be modified prior to constraining to the DoFs of the second
-     * face. If rotation_matrix is true the matrix is enterpreted as a
-     * rotation matrix applied to all vector valued blocks of an FESystem.
-     * For more details see make_periodicity_constraints and the glossary
-     * @ref GlossPeriodicConstraints "glossary entry on periodic
+     * face. If the std::vector first_vector_components is non empty the
+     * matrix is interpreted as a rotation matrix that is applied to all
+     * vector valued blocks listed in first_vector_components of the
+     * FESystem. For more details see make_periodicity_constraints and the
+     * glossary @ref GlossPeriodicConstraints "glossary entry on periodic
      * boundary conditions".
      */
     FullMatrix<double> matrix;
 
     /**
-     * A flag indicating whether matrix should be interpreted as rotation
-     * matrix or as an interpolation matrix.
+     * A vector of unsigned ints pointing to the first components of all
+     * vector valued blocks that should be rotated by matrix.
      */
-    bool rotation_matrix;
+    std::vector<unsigned int> first_vector_components;
   };
 
 
@@ -1143,12 +1144,13 @@ namespace GridTools
    * them to the corresponding vertices of the 'second' boundary. This can
    * be used to implement conditions such as $u(0,y)=u(1,y+1)$.
    *
-   * Optionally a rotation matrix @p matrix along with a flag @p
-   * rotation_matrix can be specified that describes how vector valued DoFs
-   * of the first face should be modified prior to constraining to the DoFs
-   * of the second face. If rotation_matrix is true the matrix is
-   * enterpreted as a rotation matrix applied to all vector valued blocks
-   * of an FESystem. For more details see make_periodicity_constraints and
+   * Optionally a rotation matrix @p matrix along with a vector @p
+   * first_vector_components can be specified that describes how vector
+   * valued DoFs of the first face should be modified prior to constraining
+   * to the DoFs of the second face. If @p first_vector_components is non
+   * empty the matrix is interpreted as a rotation matrix that is applied
+   * to all vector valued blocks listet in @p first_vector_components of
+   * the FESystem. For more details see make_periodicity_constraints and
    * the glossary @ref GlossPeriodicConstraints "glossary entry on periodic
    * boundary conditions".
    *
@@ -1173,8 +1175,8 @@ namespace GridTools
    const int                direction,
    std::vector<PeriodicFacePair<typename CONTAINER::cell_iterator> > &matched_pairs,
    const Tensor<1,CONTAINER::space_dimension> &offset = dealii::Tensor<1,CONTAINER::space_dimension>(),
-   const FullMatrix<double> &matrix = IdentityMatrix(CONTAINER::space_dimension),
-   const bool               rotation_matrix = true);
+   const FullMatrix<double> &matrix = FullMatrix<double>(),
+   const std::vector<unsigned int> &first_vector_components = std::vector<unsigned int>());
 
 
   /**
@@ -1205,8 +1207,8 @@ namespace GridTools
    const int                direction,
    std::vector<PeriodicFacePair<typename CONTAINER::cell_iterator> > &matched_pairs,
    const dealii::Tensor<1,CONTAINER::space_dimension> &offset = dealii::Tensor<1,CONTAINER::space_dimension>(),
-   const FullMatrix<double> &matrix = IdentityMatrix(CONTAINER::space_dimension),
-   const bool               rotation_matrix = true);
+   const FullMatrix<double> &matrix = FullMatrix<double>(),
+   const std::vector<unsigned int> &first_vector_components = std::vector<unsigned int>());
 
 
 
index 3d09923476270ebba505cbb4137b6978957af1fa..d045093d1527fc21442812fce1926e87ef9441fb 100644 (file)
@@ -1858,10 +1858,8 @@ namespace DoFTools
                           // Query the correct face_index on face_2 respecting the given
                           // orientation:
                           const unsigned int j =
-                            cell_to_rotated_face_index[fe.face_to_cell_index(jj, 0, /* It doesn't really matter, just assume
-                               * we're on the first face...
-                               */
-                                                                             face_orientation, face_flip, face_rotation)];
+                            cell_to_rotated_face_index[fe.face_to_cell_index
+                            (jj, 0, face_orientation, face_flip, face_rotation)];
 
                           // And finally constrain the two DoFs respecting component_mask:
                           if (transformation(i,jj) != 0)
@@ -1888,7 +1886,7 @@ namespace DoFTools
                                 const bool                                   face_flip,
                                 const bool                                   face_rotation,
                                 const FullMatrix<double>                    &matrix,
-                                const bool                                  rotation_matrix)
+                                const std::vector<unsigned int>             &first_vector_components)
   {
     static const int dim = FaceIterator::AccessorType::dimension;
 
@@ -1914,6 +1912,21 @@ namespace DoFTools
     Assert(face_1->at_boundary() && face_2->at_boundary(),
            ExcMessage ("Faces for periodicity constraints must be on the boundary"));
 
+    Assert(first_vector_components.size() == 0 || matrix.size(0) == matrix.size(1) == dim,
+           ExcMessage ("first_vector_components is nonempty, so matrix must be a rotation "
+                       "matrix exactly of of size dim"));
+
+#ifdef DEBUG
+    {
+      const unsigned int n_dofs = face_1->get_fe(face_1->nth_active_fe_index(0)).dofs_per_face;
+      Assert(first_vector_components.size() != 0 ||
+             ( (matrix.size(0) == 0 && matrix.size(1) == 0) ||
+               (matrix.size(0) == n_dofs && matrix.size(1) == n_dofs) ),
+             ExcMessage ("first_vector_components is empty, so matrix must have either "
+                         "size 0 or the size must be equal to the number of DoFs on the face"));
+     }
+#endif
+
 
     // A lookup table on how to go through the child faces depending on the
     // orientation:
@@ -1976,7 +1989,7 @@ namespace DoFTools
                                           face_flip,
                                           face_rotation,
                                           matrix,
-                                          rotation_matrix);
+                                          first_vector_components);
           }
       }
     else
@@ -1985,11 +1998,14 @@ namespace DoFTools
       {
         // Build up the transformation matrix:
 
-        if (rotation_matrix)
-          AssertThrow(false, ExcNotImplemented());
-//           FullMatrix<double>(IdentityMatrix(face_1->get_fe(face_1->nth_active_fe_index(0)).dofs_per_face));
+        if (first_vector_components.size() != 0 && matrix.size(0) == 0)
+          {
+            // We need to create a local transformation matrix...
+            AssertThrow(false, ExcNotImplemented());
 
-        if (face_2->has_children() == false)
+            // FullMatrix<double>(IdentityMatrix(face_1->get_fe(face_1->nth_active_fe_index(0)).dofs_per_face));
+          }
+        else if (face_2->has_children() == false)
           {
             // TODO: This is horrible...
             FullMatrix<double> inverse;
@@ -2050,7 +2066,7 @@ namespace DoFTools
                                      it->orientation[1],
                                      it->orientation[2],
                                      it->matrix,
-                                     it->rotation_matrix);
+                                     it->first_vector_components);
       }
   }
 
index 1b8a6d3e14d3885d3403e90b13cf0dec9cd7cf7e..0b1329a0d5e0b4c68ccd51c7c2bd6d35c359f518 100644 (file)
@@ -33,7 +33,7 @@ for (DH : DOFHANDLERS; deal_II_dimension : DIMENSIONS)
                                           const ComponentMask &,
                                           bool, bool, bool,
                                           const FullMatrix<double> &,
-                                          const bool);
+                                          const std::vector<unsigned int> &);
 
   template
   void
index dacf505b139542c28677ff40900da920e85170b2..a67a64cee050331abaff71e28861cb4c1008122a 100644 (file)
@@ -2383,7 +2383,7 @@ next_cell:
    std::vector<PeriodicFacePair<CellIterator> >     &matched_pairs,
    const dealii::Tensor<1,CellIterator::AccessorType::space_dimension> &offset,
    const FullMatrix<double>                         &matrix,
-   const bool                                       rotation_matrix)
+   const std::vector<unsigned int>                  &first_vector_components)
   {
     static const int space_dim = CellIterator::AccessorType::space_dimension;
     Assert (0<=direction && direction<space_dim,
@@ -2415,7 +2415,7 @@ next_cell:
                 // remove the matched cell in pairs2 to speed up the
                 // matching:
                 const PeriodicFacePair<CellIterator> matched_face
-                = {{cell1, cell2},{face_idx1, face_idx2}, orientation, matrix, rotation_matrix};
+                = {{cell1, cell2},{face_idx1, face_idx2}, orientation, matrix, first_vector_components};
                 matched_pairs.push_back(matched_face);
                 pairs2.erase(it2);
                 ++n_matches;
@@ -2441,7 +2441,7 @@ next_cell:
    std::vector<PeriodicFacePair<typename CONTAINER::cell_iterator> > &matched_pairs,
    const Tensor<1,CONTAINER::space_dimension> &offset,
    const FullMatrix<double>                   &matrix,
-   const bool                                 rotation_matrix)
+   const std::vector<unsigned int>            &first_vector_components)
   {
     static const int dim = CONTAINER::dimension;
     static const int space_dim = CONTAINER::space_dimension;
@@ -2481,7 +2481,7 @@ next_cell:
 
     // and call match_periodic_face_pairs that does the actual matching:
     match_periodic_face_pairs(pairs1, pairs2, direction, matched_pairs,
-                              offset, matrix, rotation_matrix);
+                              offset, matrix, first_vector_components);
   }
 
 
@@ -2495,7 +2495,7 @@ next_cell:
    std::vector<PeriodicFacePair<typename CONTAINER::cell_iterator> > &matched_pairs,
    const Tensor<1,CONTAINER::space_dimension> &offset,
    const FullMatrix<double>                   &matrix,
-   const bool                                 rotation_matrix)
+   const std::vector<unsigned int>            &first_vector_components)
   {
     static const int dim = CONTAINER::dimension;
     static const int space_dim = CONTAINER::space_dimension;
@@ -2542,7 +2542,7 @@ next_cell:
 
     // and call match_periodic_face_pairs that does the actual matching:
     match_periodic_face_pairs(pairs1, pairs2, direction, matched_pairs,
-                              offset, matrix, rotation_matrix);
+                              offset, matrix, first_vector_components);
 
 #ifdef DEBUG
     //check for standard orientation
index 4a5ac2eb2310d507a0a4dcab6e0ef16dd16d7e7d..d1c02d06adb12305bc434842f8f7a3df7085ffb8 100644 (file)
@@ -322,7 +322,7 @@ for (X : TRIANGULATION_AND_DOFHANDLERS; deal_II_dimension : DIMENSIONS ; deal_II
                                       std::vector<PeriodicFacePair<X::cell_iterator> > &,
                                       const Tensor<1,X::space_dimension> &,
                                       const FullMatrix<double> &,
-                                      const bool);
+                                      const std::vector<unsigned int> &);
 
       template
       void collect_periodic_faces<X> (const X &,
@@ -331,7 +331,7 @@ for (X : TRIANGULATION_AND_DOFHANDLERS; deal_II_dimension : DIMENSIONS ; deal_II
                                       std::vector<PeriodicFacePair<X::cell_iterator> > &,
                                       const Tensor<1,X::space_dimension> &,
                                       const FullMatrix<double> &,
-                                      const bool);
+                                      const std::vector<unsigned int> &);
 
     #endif
 
@@ -355,7 +355,7 @@ for (deal_II_dimension : DIMENSIONS ; deal_II_space_dimension : SPACE_DIMENSIONS
                                   std::vector<PeriodicFacePair<parallel::distributed::Triangulation<deal_II_dimension, deal_II_space_dimension>::cell_iterator> > &,
                                   const Tensor<1,parallel::distributed::Triangulation<deal_II_dimension, deal_II_space_dimension>::space_dimension> &,
                                   const FullMatrix<double> &,
-                                  const bool);
+                                  const std::vector<unsigned int> &);
 
       template
       void
@@ -366,7 +366,7 @@ for (deal_II_dimension : DIMENSIONS ; deal_II_space_dimension : SPACE_DIMENSIONS
                                   std::vector<PeriodicFacePair<parallel::distributed::Triangulation<deal_II_dimension, deal_II_space_dimension>::cell_iterator> > &,
                                   const Tensor<1,parallel::distributed::Triangulation<deal_II_dimension, deal_II_space_dimension>::space_dimension> &,
                                   const FullMatrix<double> &,
-                                  const bool);
+                                  const std::vector<unsigned int> &);
      \}
    #endif
 #endif

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.