*
* @p face1 and @p face2 are considered equal, if a one to one matching
* between its vertices can be achieved via an orthogonal equality
- * relation: Two vertices <tt>v_1</tt> and <tt>v_2</tt> are considered
- * equal, if <code> (v_1 + offset) - v_2</code> is parallel to the unit
- * vector in @p direction.
+ * relation.
+ *
+ * Hereby, two vertices <tt>v_1</tt> and <tt>v_2</tt> are considered
+ * equal, if $M\cdot v_1 + offset - v_2</code> is parallel to the unit
+ * vector in unit direction @p direction. If the parameter @p matrix
+ * is a reference to a spacedim x spacedim matrix, $M$ is set to @p
+ * matrix, otherwise $M$ is the identity matrix.
*
* If the matching was successful, the _relative_ orientation of @p face1
* with respect to @p face2 is returned in the bitset @p orientation,
const FaceIterator &face1,
const FaceIterator &face2,
const int direction,
- const dealii::Tensor<1,FaceIterator::AccessorType::space_dimension> &offset);
+ const Tensor<1,FaceIterator::AccessorType::space_dimension> &offset
+ = Tensor<1,FaceIterator::AccessorType::space_dimension>(),
+ const FullMatrix<double> &matrix = FullMatrix<double>());
/**
orthogonal_equality (const FaceIterator &face1,
const FaceIterator &face2,
const int direction,
- const dealii::Tensor<1,FaceIterator::AccessorType::space_dimension> &offset);
+ const Tensor<2,FaceIterator::AccessorType::space_dimension> &offset
+ = Tensor<1,FaceIterator::AccessorType::space_dimension>(),
+ const FullMatrix<double> &matrix = FullMatrix<double>());
/**
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 = FullMatrix<double>(IdentityMatrix(CONTAINER::space_dimension)),
+ const FullMatrix<double> &matrix = FullMatrix<double>(),
const std::vector<unsigned int> &first_vector_components = std::vector<unsigned int>());
* is parallel to the unit vector in <direction>
*/
template<int spacedim>
- inline bool orthogonal_equality (const dealii::Point<spacedim> &point1,
- const dealii::Point<spacedim> &point2,
- const int direction,
- const dealii::Tensor<1,spacedim> &offset,
- const FullMatrix<double> &matrix)
+ inline bool orthogonal_equality (const Point<spacedim> &point1,
+ const Point<spacedim> &point2,
+ const int direction,
+ const Tensor<1,spacedim> &offset,
+ const FullMatrix<double> &matrix)
{
Assert (0<=direction && direction<spacedim,
ExcIndexRange (direction, 0, spacedim));
+
+ Assert(matrix.m() == matrix.n(), ExcInternalError());
+
+ Point<spacedim> distance;
+
+ if (matrix.m() == spacedim)
+ for (int i = 0; i < spacedim; ++i)
+ for (int j = 0; j < spacedim; ++j)
+ distance(i) = matrix(i,j) * point1(j);
+ else
+ distance = point1;
+
+ distance += offset - point2;
+
for (int i = 0; i < spacedim; ++i)
{
// Only compare coordinate-components != direction:
if (i == direction)
continue;
- double transformed_p1_comp=0.;
-
- for (int j = 0; j < spacedim; ++j)
- transformed_p1_comp += matrix(i,j)*point1(j) + offset[j];
-
- if (fabs(transformed_p1_comp - point2(i)) > 1.e-10)
+ if (fabs(distance(i)) > 1.e-10)
return false;
}
const FaceIterator &face1,
const FaceIterator &face2,
const int direction,
- const dealii::Tensor<1,FaceIterator::AccessorType::space_dimension> &offset,
+ const Tensor<1,FaceIterator::AccessorType::space_dimension> &offset,
const FullMatrix<double> &matrix)
{
+ Assert(matrix.m() == matrix.n(),
+ ExcMessage("The supplied matrix must be a square matrix"));
+
static const int dim = FaceIterator::AccessorType::dimension;
// Do a full matching of the face vertices:
orthogonal_equality (const FaceIterator &face1,
const FaceIterator &face2,
const int direction,
- const dealii::Tensor<1,FaceIterator::AccessorType::space_dimension> &offset,
+ const Tensor<1,FaceIterator::AccessorType::space_dimension> &offset,
const FullMatrix<double> &matrix)
{
// Call the function above with a dummy orientation array
// We have a match, so insert the matching pairs and
// remove the matched cell in pairs2 to speed up the
// matching:
- const PeriodicFacePair<CellIterator> matched_face
- = {{cell1, cell2},{face_idx1, face_idx2}, orientation, matrix, first_vector_components};
+ const PeriodicFacePair<CellIterator> matched_face = {
+ {cell1, cell2},
+ {face_idx1, face_idx2},
+ orientation,
+ matrix,
+ first_vector_components};
matched_pairs.push_back(matched_face);
pairs2.erase(it2);
++n_matches;