From: maier Date: Fri, 21 Feb 2014 18:50:42 +0000 (+0000) Subject: Next try for a sane interface X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=3730a5eca49d62155bc12723236d590f464ab377;p=dealii-svn.git Next try for a sane interface git-svn-id: https://svn.dealii.org/branches/branch_periodic_bc@32527 0785d39b-7218-0410-832d-ea1e28bc413d --- diff --git a/deal.II/include/deal.II/dofs/dof_tools.h b/deal.II/include/deal.II/dofs/dof_tools.h index 889cae4260..3b82ea25c1 100644 --- a/deal.II/include/deal.II/dofs/dof_tools.h +++ b/deal.II/include/deal.II/dofs/dof_tools.h @@ -870,8 +870,8 @@ namespace DoFTools const bool face_orientation = true, const bool face_flip = false, const bool face_rotation = false, - const FullMatrix &matrix = IdentityMatrix(FaceIterator::space_dimension), - const bool rotation_matrix = true); + const FullMatrix &matrix = FullMatrix(), + const std::vector &first_vector_components = std::vector()); diff --git a/deal.II/include/deal.II/grid/grid_tools.h b/deal.II/include/deal.II/grid/grid_tools.h index 96308f0713..5844243ead 100644 --- a/deal.II/include/deal.II/grid/grid_tools.h +++ b/deal.II/include/deal.II/grid/grid_tools.h @@ -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 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 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 > &matched_pairs, const Tensor<1,CONTAINER::space_dimension> &offset = dealii::Tensor<1,CONTAINER::space_dimension>(), - const FullMatrix &matrix = IdentityMatrix(CONTAINER::space_dimension), - const bool rotation_matrix = true); + const FullMatrix &matrix = FullMatrix(), + const std::vector &first_vector_components = std::vector()); /** @@ -1205,8 +1207,8 @@ namespace GridTools const int direction, std::vector > &matched_pairs, const dealii::Tensor<1,CONTAINER::space_dimension> &offset = dealii::Tensor<1,CONTAINER::space_dimension>(), - const FullMatrix &matrix = IdentityMatrix(CONTAINER::space_dimension), - const bool rotation_matrix = true); + const FullMatrix &matrix = FullMatrix(), + const std::vector &first_vector_components = std::vector()); diff --git a/deal.II/source/dofs/dof_tools_constraints.cc b/deal.II/source/dofs/dof_tools_constraints.cc index 3d09923476..d045093d15 100644 --- a/deal.II/source/dofs/dof_tools_constraints.cc +++ b/deal.II/source/dofs/dof_tools_constraints.cc @@ -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 &matrix, - const bool rotation_matrix) + const std::vector &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(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(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 inverse; @@ -2050,7 +2066,7 @@ namespace DoFTools it->orientation[1], it->orientation[2], it->matrix, - it->rotation_matrix); + it->first_vector_components); } } diff --git a/deal.II/source/dofs/dof_tools_constraints.inst.in b/deal.II/source/dofs/dof_tools_constraints.inst.in index 1b8a6d3e14..0b1329a0d5 100644 --- a/deal.II/source/dofs/dof_tools_constraints.inst.in +++ b/deal.II/source/dofs/dof_tools_constraints.inst.in @@ -33,7 +33,7 @@ for (DH : DOFHANDLERS; deal_II_dimension : DIMENSIONS) const ComponentMask &, bool, bool, bool, const FullMatrix &, - const bool); + const std::vector &); template void diff --git a/deal.II/source/grid/grid_tools.cc b/deal.II/source/grid/grid_tools.cc index dacf505b13..a67a64cee0 100644 --- a/deal.II/source/grid/grid_tools.cc +++ b/deal.II/source/grid/grid_tools.cc @@ -2383,7 +2383,7 @@ next_cell: std::vector > &matched_pairs, const dealii::Tensor<1,CellIterator::AccessorType::space_dimension> &offset, const FullMatrix &matrix, - const bool rotation_matrix) + const std::vector &first_vector_components) { static const int space_dim = CellIterator::AccessorType::space_dimension; Assert (0<=direction && direction 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 > &matched_pairs, const Tensor<1,CONTAINER::space_dimension> &offset, const FullMatrix &matrix, - const bool rotation_matrix) + const std::vector &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 > &matched_pairs, const Tensor<1,CONTAINER::space_dimension> &offset, const FullMatrix &matrix, - const bool rotation_matrix) + const std::vector &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 diff --git a/deal.II/source/grid/grid_tools.inst.in b/deal.II/source/grid/grid_tools.inst.in index 4a5ac2eb23..d1c02d06ad 100644 --- a/deal.II/source/grid/grid_tools.inst.in +++ b/deal.II/source/grid/grid_tools.inst.in @@ -322,7 +322,7 @@ for (X : TRIANGULATION_AND_DOFHANDLERS; deal_II_dimension : DIMENSIONS ; deal_II std::vector > &, const Tensor<1,X::space_dimension> &, const FullMatrix &, - const bool); + const std::vector &); template void collect_periodic_faces (const X &, @@ -331,7 +331,7 @@ for (X : TRIANGULATION_AND_DOFHANDLERS; deal_II_dimension : DIMENSIONS ; deal_II std::vector > &, const Tensor<1,X::space_dimension> &, const FullMatrix &, - const bool); + const std::vector &); #endif @@ -355,7 +355,7 @@ for (deal_II_dimension : DIMENSIONS ; deal_II_space_dimension : SPACE_DIMENSIONS std::vector::cell_iterator> > &, const Tensor<1,parallel::distributed::Triangulation::space_dimension> &, const FullMatrix &, - const bool); + const std::vector &); template void @@ -366,7 +366,7 @@ for (deal_II_dimension : DIMENSIONS ; deal_II_space_dimension : SPACE_DIMENSIONS std::vector::cell_iterator> > &, const Tensor<1,parallel::distributed::Triangulation::space_dimension> &, const FullMatrix &, - const bool); + const std::vector &); \} #endif #endif