]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Changed the signature of collect_periodic_faces to return the result via a reference...
authorDaniel Arndt <d.arndt@math.uni-goettingen.de>
Thu, 5 Dec 2013 12:20:32 +0000 (12:20 +0000)
committerDaniel Arndt <d.arndt@math.uni-goettingen.de>
Thu, 5 Dec 2013 12:20:32 +0000 (12:20 +0000)
git-svn-id: https://svn.dealii.org/trunk@31900 0785d39b-7218-0410-832d-ea1e28bc413d

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

index 29cefdfe526f1312476c4f12e8215d044ef3d12b..aca9b0b885bc08050cb80a16efa79ea3e1be3187 100644 (file)
@@ -1096,12 +1096,13 @@ namespace GridTools
    * @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>());
 
 
@@ -1125,11 +1126,12 @@ namespace GridTools
    * @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>());
 
 
index 4ef7047725ea716d6d45acdc86e106aedd0662ef..b2b3aeb36cedadcd7321ef8fc35e71edc66163d8 100644 (file)
@@ -2030,13 +2030,12 @@ namespace DoFTools
             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);
@@ -2081,13 +2080,12 @@ namespace DoFTools
     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);
index fef813ec37bfb448df673a9fb7eff95ac0b84ffc..445b2694ccffc16d089f6b9ab9de0cdea3993c6d 100644 (file)
@@ -2368,11 +2368,12 @@ next_cell:
    * 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;
@@ -2382,7 +2383,7 @@ next_cell:
     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;
@@ -2406,28 +2407,29 @@ next_cell:
                 // 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;
@@ -2467,17 +2469,19 @@ next_cell:
             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;
@@ -2517,26 +2521,25 @@ next_cell:
     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    
   }
 
 
index 6e827d7111ddf161d3f53ac5070eb23137409801..8089c7dad665c1d58a7a25d95370bfa0869164cf 100644 (file)
@@ -311,21 +311,19 @@ for (X : TRIANGULATION_AND_DOFHANDLERS; deal_II_dimension : DIMENSIONS ; deal_II
     #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
 
@@ -341,20 +339,22 @@ for (deal_II_dimension : DIMENSIONS ; deal_II_space_dimension : SPACE_DIMENSIONS
      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> &);
 
      \}

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.