bool
orthogonal_equality (const FaceIterator &face1,
const FaceIterator &face2,
- const int direction,
+ const int direction,
const dealii::Tensor<1,FaceIterator::AccessorType::space_dimension> &offset);
* parallel::distributed::Triangulation::add_periodicity to enforce
* periodicity algebraically.
*
- * @author Daniel Arndt, 2013
+ * @author Daniel Arndt, Matthias Maier, 2013
*/
template<typename DH>
std::vector<PeriodicFacePair<typename DH::cell_iterator> >
(const DH &dof_handler,
const types::boundary_id b_id1,
const types::boundary_id b_id2,
- const unsigned int direction,
+ const int direction,
const dealii::Tensor<1,DH::space_dimension> &offset);
+
/**
* This compatibility version of collect_periodic_face_pairs only works
* on grids with cells in @ref GlossFaceOrientation "standard orientation".
* meshes with cells not in @ref GlossFaceOrientation
* "standard orientation".
*
- * @author Daniel Arndt, 2013
+ * @author Daniel Arndt, Matthias Maier, 2013
*/
template<typename DH>
std::vector<PeriodicFacePair<typename DH::cell_iterator> >
collect_periodic_faces
(const DH &dof_handler,
const types::boundary_id b_id,
- const unsigned int direction,
+ const int direction,
const dealii::Tensor<1,DH::space_dimension> &offset);
- /**
- * This function does the same as collect_periodic_faces but returns a
- * different data type.
- *
- * @author Matthias Maier, 2012
- *
- * @note The returned data type is not compatible with
- * DoFTools::make_periodicity_constraints
- *
- * @deprecated
- */
- template<typename DH>
- std::map<typename DH::face_iterator, std::pair<typename DH::face_iterator, std::bitset<3> > >
- collect_periodic_face_pairs
- (const DH &container,
- const types::boundary_id b_id1,
- const types::boundary_id b_id2,
- int direction,
- const dealii::Tensor<1,DH::space_dimension> &offset) DEAL_II_DEPRECATED;
-
- /**
- * This compatibility version of collect_periodic_face_pairs only works
- * on grids with cells in @ref GlossFaceOrientation "standard orientation".
- *
- * @author Matthias Maier, 2012
- *
- * @note The returned data type is not compatible with
- * DoFTools::make_periodicity_constraints
- *
- * @deprecated
- */
- template<typename DH>
- std::map<typename DH::face_iterator, typename DH::face_iterator>
- collect_periodic_face_pairs
- (const DH &dof_handler, /*TODO: Name*/
- const types::boundary_id b_id,
- int direction,
- const dealii::Tensor<1,DH::space_dimension> &offset) DEAL_II_DEPRECATED;
-
- /**
- * This version loops over all faces from @p begin to @p end
- * instead of accepting a DoFHandler or a Triangulation.
- *
- * @author Matthias Maier, 2012
- *
- * @note This function cannot produce the return as the other
- * collect_periodic_faces functions.
- *
- * @deprecated
- */
- template<typename FaceIterator>
- std::map<FaceIterator, std::pair<FaceIterator, std::bitset<3> > >
- collect_periodic_face_pairs
- (const FaceIterator &begin,
- const typename identity<FaceIterator>::type &end,
- const types::boundary_id b_id1,
- const types::boundary_id b_id2,
- const int direction,
- const dealii::Tensor<1,FaceIterator::AccessorType::space_dimension> &offset)
- DEAL_II_DEPRECATED;
-
- /**
- * This function does the same as collect_periodic_faces but returns a
- * different data type.
- *
- * @author Daniel Arndt, 2013
- *
- * @note The returned data type is not compatible with
- * DoFTools::make_periodicity_constraints, but with a version of
- * parallel::distributed::Triangulation::add_periodicity
- *
- * @note Use collect_periodic_faces instead.
- *
- * @deprecated
- */
- template<typename DH>
- void
- identify_periodic_face_pairs
- (const DH &dof_handler,
- const types::boundary_id b_id1,
- const types::boundary_id b_id2,
- const unsigned int direction,
- std::vector<std_cxx1x::tuple<typename DH::cell_iterator, unsigned int,
- typename DH::cell_iterator, unsigned int> >
- &periodicity_vector) DEAL_II_DEPRECATED;
-
/**
* Exception
template<int spacedim>
inline bool orthogonal_equality (const dealii::Point<spacedim> &point1,
const dealii::Point<spacedim> &point2,
- const int direction,
+ const int direction,
const dealii::Tensor<1,spacedim> &offset)
{
Assert (0<=direction && direction<spacedim,
inline bool
orthogonal_equality (const FaceIterator &face1,
const FaceIterator &face2,
- const int direction,
+ const int direction,
const dealii::Tensor<1,FaceIterator::AccessorType::space_dimension> &offset)
{
// Call the function above with a dummy orientation array
template<typename CellIterator>
std::vector<PeriodicFacePair<CellIterator> >
match_periodic_face_pairs
- (std::set<std::pair<CellIterator, unsigned int> >
- &pairs1,
- std::set<std::pair<typename identity<CellIterator>::type, unsigned int> >
- &pairs2,
- int direction,
- const dealii::Tensor<1,CellIterator::AccessorType::space_dimension>
- &offset)
+ (std::set<std::pair<CellIterator, unsigned int> > &pairs1,
+ std::set<std::pair<typename identity<CellIterator>::type, unsigned int> > &pairs2,
+ const int direction,
+ const dealii::Tensor<1,CellIterator::AccessorType::space_dimension> &offset)
{
static const int space_dim = CellIterator::AccessorType::space_dimension;
Assert (0<=direction && direction<space_dim,
return matched_faces;
}
- /* Deprecated version of the function above with different return value.
- * It is used the deprecated collect_periodic_face_pairs.
- */
- template<typename FaceIterator>
- std::map<FaceIterator, std::pair<FaceIterator, std::bitset<3> > >
- match_periodic_face_pairs
- (std::set<FaceIterator> &faces1, /* not const! */
- std::set<typename identity<FaceIterator>::type> &faces2, /* not const! */
- int direction,
- const dealii::Tensor<1,FaceIterator::AccessorType::space_dimension> &offset)
- DEAL_II_DEPRECATED;
-
- template<typename FaceIterator>
- std::map<FaceIterator, std::pair<FaceIterator, std::bitset<3> > >
- match_periodic_face_pairs
- (std::set<FaceIterator> &faces1, /* not const! */
- std::set<typename identity<FaceIterator>::type> &faces2, /* not const! */
- int direction,
- const dealii::Tensor<1,FaceIterator::AccessorType::space_dimension> &offset)
- {
- static const int space_dim = FaceIterator::AccessorType::space_dimension;
- Assert (0<=direction && direction<space_dim,
- ExcIndexRange (direction, 0, space_dim));
-
- Assert (faces1.size() == faces2.size(),
- ExcMessage ("Unmatched faces on periodic boundaries"));
-
- typedef std::pair<FaceIterator, std::bitset<3> > ResultPair;
- std::map<FaceIterator, ResultPair> matched_faces;
-
- // Match with a complexity of O(n^2). This could be improved...
- std::bitset<3> orientation;
- typedef typename std::set<FaceIterator>::const_iterator SetIterator;
- for (SetIterator it1 = faces1.begin(); it1 != faces1.end(); ++it1)
- {
- for (SetIterator it2 = faces2.begin(); it2 != faces2.end(); ++it2)
- {
- if (GridTools::orthogonal_equality(orientation, *it1, *it2,
- direction, offset))
- {
- // We have a match, so insert the matching pairs and
- // remove the matched cell in faces2 to speed up the
- // matching:
- matched_faces[*it1] = std::make_pair(*it2, orientation);
- faces2.erase(it2);
- break;
- }
- }
- }
-
- AssertThrow (matched_faces.size() == faces1.size() && faces2.size() == 0,
- ExcMessage ("Unmatched faces on periodic boundaries"));
-
- return matched_faces;
- }
template<typename DH>
(const DH &dof_handler,
const types::boundary_id b_id1,
const types::boundary_id b_id2,
- const unsigned int direction,
+ const int direction,
const dealii::Tensor<1,DH::space_dimension> &offset)
{
- static const unsigned int dim = DH::dimension;
- static const unsigned int space_dim = DH::space_dimension;
+ static const int dim = DH::dimension;
+ static const int space_dim = DH::space_dimension;
Assert (0<=direction && direction<space_dim,
ExcIndexRange (direction, 0, space_dim));
return match_periodic_face_pairs(pairs1, pairs2, direction, offset);
}
+
+
template<typename DH>
std::vector<PeriodicFacePair<typename DH::cell_iterator> >
collect_periodic_faces (const DH &dof_handler,
const types::boundary_id b_id,
- const unsigned int direction,
+ const int direction,
const dealii::Tensor<1,DH::space_dimension> &offset)
{
- static const unsigned int dim = DH::dimension;
- static const unsigned int space_dim = DH::space_dimension;
+ static const int dim = DH::dimension;
+ static const int space_dim = DH::space_dimension;
Assert (0<=direction && direction<space_dim,
ExcIndexRange (direction, 0, space_dim));
-
+
Assert(dim == space_dim,
ExcNotImplemented());
-
+
// Loop over all cells on the highest level and collect all boundary
// faces 2*direction and 2*direction*1:
-
+
std::set<std::pair<typename DH::cell_iterator, unsigned int> > pairs1;
std::set<std::pair<typename DH::cell_iterator, unsigned int> > pairs2;
-
+
for (typename DH::cell_iterator cell = dof_handler.begin(0);
cell != dof_handler.end(0); ++cell)
{
const typename DH::face_iterator face_1 = cell->face(2*direction);
const typename DH::face_iterator face_2 = cell->face(2*direction+1);
-
+
if (face_1->at_boundary() && face_1->boundary_indicator() == b_id)
{
const std::pair<typename DH::cell_iterator, unsigned int> pair1
= std::make_pair(cell, 2*direction);
pairs1.insert(pair1);
}
-
+
if (face_2->at_boundary() && face_2->boundary_indicator() == b_id)
{
const std::pair<typename DH::cell_iterator, unsigned int> pair2
pairs2.insert(pair2);
}
}
-
+
Assert (pairs1.size() == pairs2.size(),
ExcMessage ("Unmatched faces on periodic boundaries"));
-
+
// and call match_periodic_face_pairs that does the actual matching:
typedef std::vector<PeriodicFacePair<typename DH::cell_iterator> >
FaceVector matching = match_periodic_face_pairs(pairs1, pairs2,
direction, offset);
+#ifdef DEBUG
for (typename FaceVector::iterator pairing = matching.begin();
pairing != matching.end(); ++pairing)
{
Assert(pairing->orientation == 1,
- ExcMessage("Found a face match with non standard orientation. "
- "This function is only suitable for meshes with cells "
- "in default orientation"));
+ ExcMessage("Found a face match with non standard orientation. "
+ "This function is only suitable for meshes with cells "
+ "in default orientation"));
}
-
- return matching;
- }
-
- template<typename FaceIterator>
- std::map<FaceIterator, std::pair<FaceIterator, std::bitset<3> > >
- collect_periodic_face_pairs (const FaceIterator &begin,
- const typename identity<FaceIterator>::type &end,
- const types::boundary_id b_id1,
- const types::boundary_id b_id2,
- int direction,
- const dealii::Tensor<1,FaceIterator::AccessorType::space_dimension> &offset)
- {
- static const int space_dim = FaceIterator::AccessorType::space_dimension;
- Assert (0<=direction && direction<space_dim,
- ExcIndexRange (direction, 0, space_dim));
-
- // Collect all faces belonging to b_id1 and b_id2:
-
- std::set<FaceIterator> faces1;
- std::set<FaceIterator> faces2;
-
- for (FaceIterator face = begin; face!= end; ++face)
- {
- if (face->at_boundary() && face->boundary_indicator() == b_id1)
- faces1.insert(face);
-
- if (face->at_boundary() && face->boundary_indicator() == b_id2)
- faces2.insert(face);
- }
-
- Assert (faces1.size() == faces2.size(),
- ExcMessage ("Unmatched faces on periodic boundaries"));
-
- // and call match_periodic_face_pairs that does the actual matching:
- return match_periodic_face_pairs(faces1, faces2, direction, offset);
- }
-
- template<typename DH>
- std::map<typename DH::face_iterator, std::pair<typename DH::face_iterator, std::bitset<3> > >
- collect_periodic_face_pairs (const DH &dof_handler,
- const types::boundary_id b_id1,
- const types::boundary_id b_id2,
- int direction,
- const dealii::Tensor<1,DH::space_dimension> &offset)
- {
- typedef std::vector<PeriodicFacePair<typename DH::cell_iterator> > FaceVector;
-
- const FaceVector face_vector
- = collect_periodic_faces (dof_handler, b_id1, b_id2, direction, offset);
-
- std::map<typename DH::face_iterator,
- std::pair<typename DH::face_iterator, std::bitset<3> > >
- return_value;
- for(typename FaceVector::const_iterator it = face_vector.begin();
- it != face_vector.end(); ++it)
- {
- const typename DH::face_iterator face1 = it->cell[0]->face(it->face_idx[0]);
- const typename DH::face_iterator face2 = it->cell[1]->face(it->face_idx[1]);
- return_value[face1] = std::make_pair(face2, it->orientation);
- }
-
- return return_value;
- }
+#endif
-
- template<typename DH>
- std::map<typename DH::face_iterator, typename DH::face_iterator>
- collect_periodic_face_pairs (const DH &dof_handler,
- const types::boundary_id b_id,
- int direction,
- const dealii::Tensor<1,DH::space_dimension> &offset)
- {
- typedef std::vector<PeriodicFacePair<typename DH::cell_iterator> > FaceVector;
-
- const FaceVector face_vector
- = collect_periodic_faces (dof_handler, b_id, direction, offset);
-
- std::map<typename DH::face_iterator, typename DH::face_iterator> return_value;
- for(typename FaceVector::const_iterator it = face_vector.begin();
- it != face_vector.end(); ++it)
- {
- const typename DH::face_iterator face1 = it->cell[0]->face(it->face_idx[0]);
- const typename DH::face_iterator face2 = it->cell[1]->face(it->face_idx[1]);
- return_value[face1] = face2;
- }
-
- return return_value;
+ return matching;
}
-
- template<typename DH>
- void
- identify_periodic_face_pairs
- (const DH &dof_handler,
- const types::boundary_id b_id1,
- const types::boundary_id b_id2,
- const unsigned int direction,
- std::vector<std_cxx1x::tuple<typename DH::cell_iterator, unsigned int,
- typename DH::cell_iterator, unsigned int> >
- &periodicity_vector)
- {
- typedef std::vector<PeriodicFacePair<typename DH::cell_iterator> >
- FaceVector;
- const FaceVector periodic_faces
- = collect_periodic_faces(dof_handler, b_id1, b_id2, direction,
- dealii::Tensor<1,DH::space_dimension> ());
-
- typename FaceVector::const_iterator it, end_faces;
- it = periodic_faces.begin();
- end_faces = periodic_faces.end();
-
- for(; it!=end_faces; ++it)
- {
-
- const std_cxx1x::tuple<typename DH::cell_iterator, unsigned int,
- typename DH::cell_iterator, unsigned int>
- periodic_tuple (it->cell[0], it->face_idx[0],
- it->cell[1], it->face_idx[1]);
-
- periodicity_vector.push_back(periodic_tuple);
- }
- }
} /* namespace GridTools */
template
std::vector<PeriodicFacePair<X::cell_iterator> >
- collect_periodic_faces
+ collect_periodic_faces<X>
(const X &,
const types::boundary_id,
const types::boundary_id,
- unsigned int,
+ const int,
const Tensor<1,X::space_dimension> &);
-
- template<typename DH>
- std::vector<PeriodicFacePair<X::cell_iterator> >
- collect_periodic_faces
- (const X &,
- const types::boundary_id,
- unsigned int,
- const Tensor<1,X::space_dimension> &);
-
- template
- std::map<X::face_iterator, std::pair<X::face_iterator, std::bitset<3> > >
- collect_periodic_face_pairs
- (const X::face_iterator &,
- const X::face_iterator &,
- const types::boundary_id,
- const types::boundary_id,
- int,
- const Tensor<1,X::space_dimension> &);
- template
- std::map<X::active_face_iterator, std::pair<X::active_face_iterator, std::bitset<3> > >
- collect_periodic_face_pairs
- (const X::active_face_iterator &,
- const X::active_face_iterator &,
- const types::boundary_id,
- const types::boundary_id,
- int,
- const Tensor<1,X::active_face_iterator::AccessorType::space_dimension> &);
template
- std::map<X::face_iterator, std::pair<X::face_iterator, std::bitset<3> > >
- collect_periodic_face_pairs
+ std::vector<PeriodicFacePair<X::cell_iterator> >
+ collect_periodic_faces<X>
(const X &,
const types::boundary_id,
- const types::boundary_id,
- int,
+ const int,
const Tensor<1,X::space_dimension> &);
- template
- std::map<X::face_iterator, X::face_iterator>
- collect_periodic_face_pairs
- (const X &,
- const types::boundary_id,
- int,
- const Tensor<1,deal_II_space_dimension> &);
-
- template
- void
- identify_periodic_face_pairs
- (const X &,
- const types::boundary_id,
- const types::boundary_id,
- const unsigned int,
- std::vector<std_cxx1x::tuple<X::cell_iterator, unsigned int,
- X::cell_iterator, unsigned int> > &);
-
#endif
\}
#endif
}
-for (deal_II_dimension : DIMENSIONS ; deal_II_space_dimension : SPACE_DIMENSIONS)
-{
-#if deal_II_dimension <= deal_II_space_dimension
- #if deal_II_dimension >= 2
- namespace GridTools \{
- template
- void
- identify_periodic_face_pairs
- (const parallel::distributed::Triangulation<deal_II_dimension, deal_II_space_dimension> &,
- const types::boundary_id,
- const types::boundary_id,
- const unsigned int,
- std::vector<std_cxx1x::tuple<parallel::distributed::Triangulation<deal_II_dimension, deal_II_space_dimension>::cell_iterator,
- unsigned int,
- parallel::distributed::Triangulation<deal_II_dimension, deal_II_space_dimension>::cell_iterator,
- unsigned int> > &);
- \}
- #endif
-#endif
-}
-
-