* @author Daniel Arndt, Matthias Maier, 2013
*/
template<typename CONTAINER>
- std::vector<PeriodicFacePair<typename CONTAINER::cell_iterator> >
+ void
collect_periodic_faces
(const CONTAINER &container,
const types::boundary_id b_id1,
const types::boundary_id b_id2,
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>());
* @author Daniel Arndt, Matthias Maier, 2013
*/
template<typename CONTAINER>
- std::vector<PeriodicFacePair<typename CONTAINER::cell_iterator> >
+ void
collect_periodic_faces
(const CONTAINER &container,
const types::boundary_id b_id,
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>());
ExcMessage ("The boundary indicators b_id1 and b_id2 must be"
"different to denote different boundaries."));
- typedef std::vector<GridTools::PeriodicFacePair
- <typename DH::cell_iterator> > FaceVector;
+ std::vector<GridTools::PeriodicFacePair
+ <typename DH::cell_iterator> > matched_faces;
// Collect matching periodic cells on the coarsest level:
- FaceVector matched_faces =
- GridTools::collect_periodic_faces(dof_handler, b_id1, b_id2,
- direction, offset);
+ GridTools::collect_periodic_faces(dof_handler, b_id1, b_id2, direction,
+ matched_faces, offset);
make_periodicity_constraints<DH>
(matched_faces, constraint_matrix, component_mask);
Assert(dim == space_dim,
ExcNotImplemented());
- typedef std::vector<GridTools::PeriodicFacePair
- <typename DH::cell_iterator> > FaceVector;
+ std::vector<GridTools::PeriodicFacePair
+ <typename DH::cell_iterator> > matched_faces;
// Collect matching periodic cells on the coarsest level:
- const FaceVector matched_faces =
- GridTools::collect_periodic_faces(dof_handler, b_id,
- direction, offset);
+ GridTools::collect_periodic_faces(dof_handler, b_id, direction,
+ matched_faces, offset);
make_periodicity_constraints<DH>
(matched_faces, constraint_matrix, component_mask);
* Internally used in collect_periodic_faces
*/
template<typename CellIterator>
- std::vector<PeriodicFacePair<CellIterator> >
+ void
match_periodic_face_pairs
(std::set<std::pair<CellIterator, unsigned int> > &pairs1,
std::set<std::pair<typename identity<CellIterator>::type, unsigned int> > &pairs2,
const int direction,
+ std::vector<PeriodicFacePair<CellIterator> > & matched_pairs,
const dealii::Tensor<1,CellIterator::AccessorType::space_dimension> &offset)
{
static const int space_dim = CellIterator::AccessorType::space_dimension;
Assert (pairs1.size() == pairs2.size(),
ExcMessage ("Unmatched faces on periodic boundaries"));
- typename std::vector<PeriodicFacePair<CellIterator> > matched_faces;
+ unsigned int n_matches = 0;
// Match with a complexity of O(n^2). This could be improved...
std::bitset<3> orientation;
// matching:
const PeriodicFacePair<CellIterator> matched_face
= {{cell1, cell2},{face_idx1, face_idx2}, orientation};
- matched_faces.push_back(matched_face);
+ matched_pairs.push_back(matched_face);
pairs2.erase(it2);
+ ++n_matches;
break;
}
}
}
- AssertThrow (matched_faces.size() == pairs1.size() && pairs2.size() == 0,
+ //Assure that all faces are matched
+ AssertThrow (n_matches == pairs1.size() && pairs2.size() == 0,
ExcMessage ("Unmatched faces on periodic boundaries"));
-
- return matched_faces;
}
template<typename CONTAINER>
- std::vector<PeriodicFacePair<typename CONTAINER::cell_iterator> >
+ void
collect_periodic_faces
- (const CONTAINER &container,
+ (const CONTAINER &container,
const types::boundary_id b_id1,
const types::boundary_id b_id2,
const int direction,
+ std::vector<PeriodicFacePair<typename CONTAINER::cell_iterator> > & matched_pairs,
const dealii::Tensor<1,CONTAINER::space_dimension> &offset)
{
static const int dim = CONTAINER::dimension;
ExcMessage ("Unmatched faces on periodic boundaries"));
// and call match_periodic_face_pairs that does the actual matching:
- return match_periodic_face_pairs(pairs1, pairs2, direction, offset);
+ match_periodic_face_pairs(pairs1, pairs2, direction, matched_pairs, offset);
}
template<typename CONTAINER>
- std::vector<PeriodicFacePair<typename CONTAINER::cell_iterator> >
- collect_periodic_faces (const CONTAINER &container,
- const types::boundary_id b_id,
- const int direction,
- const dealii::Tensor<1,CONTAINER::space_dimension> &offset)
+ void
+ collect_periodic_faces
+ (const CONTAINER &container,
+ const types::boundary_id b_id,
+ const int direction,
+ std::vector<PeriodicFacePair<typename CONTAINER::cell_iterator> > & matched_pairs,
+ const dealii::Tensor<1,CONTAINER::space_dimension> &offset)
{
static const int dim = CONTAINER::dimension;
static const int space_dim = CONTAINER::space_dimension;
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 CONTAINER::cell_iterator> >
- FaceVector;
- FaceVector matching = match_periodic_face_pairs(pairs1, pairs2,
- direction, offset);
+#ifdef DEBUG
+ const unsigned int size_old = matched_pairs.size();
+#endif
+
+ // and call match_periodic_face_pairs that does the actual matching:
+ match_periodic_face_pairs(pairs1, pairs2, direction, matched_pairs, offset);
#ifdef DEBUG
- for (typename FaceVector::iterator pairing = matching.begin();
- pairing != matching.end(); ++pairing)
+ //check for standard orientation
+ const unsigned int size_new = matched_pairs.size();
+ for (unsigned int i = size_old; i < size_new; ++i)
{
- Assert(pairing->orientation == 1,
+ Assert(matched_pairs[i].orientation == 1,
ExcMessage("Found a face match with non standard orientation. "
"This function is only suitable for meshes with cells "
"in default orientation"));
}
-#endif
-
- return matching;
+#endif
}
#if deal_II_dimension >= 2
template
- std::vector<PeriodicFacePair<X::cell_iterator> >
- collect_periodic_faces<X>
- (const X &,
- const types::boundary_id,
- const types::boundary_id,
- const int,
- const Tensor<1,X::space_dimension> &);
+ void collect_periodic_faces<X> (const X &,
+ const types::boundary_id,
+ const types::boundary_id,
+ const int,
+ std::vector<PeriodicFacePair<X::cell_iterator> > &,
+ const Tensor<1,X::space_dimension> &);
template
- std::vector<PeriodicFacePair<X::cell_iterator> >
- collect_periodic_faces<X>
- (const X &,
- const types::boundary_id,
- const int,
- const Tensor<1,X::space_dimension> &);
+ void collect_periodic_faces<X> (const X &,
+ const types::boundary_id,
+ const int,
+ std::vector<PeriodicFacePair<X::cell_iterator> > &,
+ const Tensor<1,X::space_dimension> &);
#endif
namespace GridTools \{
template
- std::vector<PeriodicFacePair<parallel::distributed::Triangulation<deal_II_dimension, deal_II_space_dimension>::cell_iterator> >
+ void
collect_periodic_faces<parallel::distributed::Triangulation<deal_II_dimension, deal_II_space_dimension> >
(const parallel::distributed::Triangulation<deal_II_dimension, deal_II_space_dimension> &,
const types::boundary_id,
const types::boundary_id,
const int,
+ 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> &);
template
- std::vector<PeriodicFacePair<parallel::distributed::Triangulation<deal_II_dimension, deal_II_space_dimension>::cell_iterator> >
+ void
collect_periodic_faces<parallel::distributed::Triangulation<deal_II_dimension, deal_II_space_dimension> >
(const parallel::distributed::Triangulation<deal_II_dimension, deal_II_space_dimension> &,
const types::boundary_id,
const int,
+ 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> &);
\}