]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Revert changing due to boost
authorDaniel Arndt <arndtd@ornl.gov>
Wed, 7 Dec 2022 22:15:41 +0000 (22:15 +0000)
committerDaniel Arndt <arndtd@ornl.gov>
Thu, 8 Dec 2022 22:13:15 +0000 (17:13 -0500)
source/grid/grid_tools.cc
source/particles/particle_handler.cc

index 9d5da20c39de90c70cb29d82145958b604e56311..dc2aa6242ae79d109a3b25b279ca7d145c9e66cd 100644 (file)
@@ -2963,7 +2963,30 @@ namespace GridTools
           {
             if (!used_vertices_rtree.empty())
               {
-                Assert(false, ExcInternalError());
+                // If we have an rtree at our disposal, use it.
+                using ValueType = std::pair<Point<spacedim>, unsigned int>;
+                std::function<bool(const ValueType &)> marked;
+                if (marked_vertices.size() == mesh.n_vertices())
+                  marked = [&marked_vertices](const ValueType &value) -> bool {
+                    return marked_vertices[value.second];
+                  };
+                else
+                  marked = [](const ValueType &) -> bool { return true; };
+
+                std::vector<std::pair<Point<spacedim>, unsigned int>> res;
+                used_vertices_rtree.query(
+                  boost::geometry::index::nearest(p, 1) &&
+                    boost::geometry::index::satisfies(marked),
+                  std::back_inserter(res));
+
+                // Searching for a point which is located outside the
+                // triangulation results in res.size() = 0
+                Assert(res.size() < 2,
+                       dealii::ExcMessage("There can not be multiple results"));
+
+                if (res.size() > 0)
+                  if (any_cell_marked(vertex_to_cells[res[0].second]))
+                    closest_vertex_index = res[0].second;
               }
             else
               {
index 20f260cc6b5c09de0d81d3640eba2632f26767b6..e55fe4da7f58ecf8c38a163df108106a4f20c441 100644 (file)
@@ -1395,7 +1395,37 @@ namespace Particles
 
           if (!found_cell)
             {
-              Assert(false, ExcInternalError());
+              // The particle is not in a neighbor of the old cell.
+              // Look for the new cell in the whole local domain.
+              // This case is rare.
+              std::vector<std::pair<Point<spacedim>, unsigned int>>
+                closest_vertex_in_domain;
+              triangulation_cache->get_used_vertices_rtree().query(
+                boost::geometry::index::nearest(out_particle->get_location(),
+                                                1),
+                std::back_inserter(closest_vertex_in_domain));
+
+              // We should have one and only one result
+              AssertDimension(closest_vertex_in_domain.size(), 1);
+              const unsigned int closest_vertex_index_in_domain =
+                closest_vertex_in_domain[0].second;
+
+              // Search all of the cells adjacent to the closest vertex of the
+              // domain. Most likely we will find the particle in them.
+              for (const auto &cell :
+                   vertex_to_cells[closest_vertex_index_in_domain])
+                {
+                  mapping->transform_points_real_to_unit_cell(
+                    cell, real_locations, reference_locations);
+
+                  if (GeometryInfo<dim>::is_inside_unit_cell(
+                        reference_locations[0]))
+                    {
+                      current_cell = cell;
+                      found_cell   = true;
+                      break;
+                    }
+                }
             }
 
           if (!found_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.