]> https://gitweb.dealii.org/ - dealii-svn.git/commitdiff
find_active_cell_around_point for the hp case works with a MappingCollection containi...
authorgoll <goll@0785d39b-7218-0410-832d-ea1e28bc413d>
Thu, 26 Jan 2012 09:50:36 +0000 (09:50 +0000)
committergoll <goll@0785d39b-7218-0410-832d-ea1e28bc413d>
Thu, 26 Jan 2012 09:50:36 +0000 (09:50 +0000)
git-svn-id: https://svn.dealii.org/trunk@24934 0785d39b-7218-0410-832d-ea1e28bc413d

deal.II/source/grid/grid_tools.cc

index 1cfd13be6577af965ffc4dc0739bec96edb6840b..e26e2e7d8ddb4c593dc574c93d09887a12c0ee5d 100644 (file)
@@ -840,52 +840,68 @@ namespace GridTools
                                 const hp::DoFHandler<dim,spacedim> &container,
                                 const Point<spacedim>     &p)
   {
+    Assert ((mapping.size() == 1) ||
+             (mapping.size() == container.get_fe().size()),
+             ExcMessage ("Mapping collection needs to have either size 1 "
+                         "or size equal to the number of elements in "
+                         "the FECollection."));
+
     typedef typename hp::DoFHandler<dim,spacedim>::active_cell_iterator cell_iterator;
 
-                                    // The best distance is set to the
-                                    // maximum allowable distance from
-                                    // the unit cell; we assume a
-                                    // max. deviation of 1e-10
-    double best_distance = 1e-10;
-    int    best_level = -1;
     std::pair<cell_iterator, Point<spacedim> > best_cell;
-
-                                    // Find closest vertex and determine
-                                    // all adjacent cells
-    unsigned int vertex = find_closest_vertex(container, p);
-
-    std::vector<cell_iterator> adjacent_cells =
-      find_cells_adjacent_to_vertex(container, vertex);
-
-    typename std::vector<cell_iterator>::const_iterator
-      cell = adjacent_cells.begin(),
-      endc = adjacent_cells.end();
-
-    for(; cell != endc; ++cell)
+            //If we have only one element in the MappingCollection,
+            //we use find_active_cell_around_point using only one
+            //mapping.
+    if(mapping.size()==1)
+      best_cell = find_active_cell_around_point(mapping[0], container, p);
+    else
       {
-       const Point<spacedim> p_cell
-         = mapping[(*cell)->active_fe_index()].transform_real_to_unit_cell(*cell, p);
 
-                                        // calculate the infinity norm of
-                                        // the distance vector to the unit cell.
-       const double dist = GeometryInfo<dim>::distance_to_unit_cell(p_cell);
 
-                                        // We compare if the point is inside the
-                                        // unit cell (or at least not too far
-                                        // outside). If it is, it is also checked
-                                        // that the cell has a more refined state
-       if (dist < best_distance ||
-           (dist == best_distance && (*cell)->level() > best_level))
-         {
-           best_distance = dist;
-           best_level    = (*cell)->level();
-           best_cell     = std::make_pair(*cell, p_cell);
-         }
+                 // The best distance is set to the
+                 // maximum allowable distance from
+                 // the unit cell; we assume a
+                 // max. deviation of 1e-10
+        double best_distance = 1e-10;
+        int    best_level = -1;
+
+
+                 // Find closest vertex and determine
+                 // all adjacent cells
+        unsigned int vertex = find_closest_vertex(container, p);
+
+        std::vector<cell_iterator> adjacent_cells =
+          find_cells_adjacent_to_vertex(container, vertex);
+
+        typename std::vector<cell_iterator>::const_iterator
+          cell = adjacent_cells.begin(),
+          endc = adjacent_cells.end();
+
+        for(; cell != endc; ++cell)
+          {
+      const Point<spacedim> p_cell
+        = mapping[(*cell)->active_fe_index()].transform_real_to_unit_cell(*cell, p);
+
+               // calculate the infinity norm of
+               // the distance vector to the unit cell.
+      const double dist = GeometryInfo<dim>::distance_to_unit_cell(p_cell);
+
+               // We compare if the point is inside the
+               // unit cell (or at least not too far
+               // outside). If it is, it is also checked
+               // that the cell has a more refined state
+      if (dist < best_distance ||
+          (dist == best_distance && (*cell)->level() > best_level))
+        {
+          best_distance = dist;
+          best_level    = (*cell)->level();
+          best_cell     = std::make_pair(*cell, p_cell);
+        }
       }
 
     Assert (best_cell.first.state() == IteratorState::valid,
            ExcPointNotFound<dim>(p));
-
+      }
     return best_cell;
   }
 

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.