#include <deal.II/grid/tria_info_cache_flags.h>
#include <deal.II/fe/mapping_q1.h>
+#include <deal.II/numerics/kdtree.h>
+
#include <cmath>
DEAL_II_NAMESPACE_OPEN
const std::vector<std::vector<Tensor<1,spacedim>>>
&get_vertex_to_cell_centers_directions() const;
+#ifdef DEAL_II_WITH_NANOFLANN
+ /**
+ * Return the cached vertex_kdtree object, constructed with the vertices of
+ * the stored triangulation.
+ */
+ const KDTree<spacedim> &get_vertex_kdtree() const;
+#endif
+
/**
* Exception for uninitialized cache fields.
*/
/**
* A pointer to the Triangulation.
*/
- SmartPointer<Triangulation<dim,spacedim>,
+ SmartPointer<const Triangulation<dim,spacedim>,
TriangulationInfoCache<dim,spacedim>> tria;
/**
/**
* Mapping to use when computing on the Triangulation.
*/
- SmartPointer<Mapping<dim,spacedim>,
+ SmartPointer<const Mapping<dim,spacedim>,
TriangulationInfoCache<dim,spacedim>> mapping;
* GridTools::vertex_to_cell_centers_directions.
*/
std::vector<std::vector<Tensor<1,spacedim>>> vertex_to_cell_centers;
+
+#ifdef DEAL_II_WITH_NANOFLANN
+ /**
+ * A KDTree object constructed with the vertices of the triangulation.
+ */
+ KDTree<spacedim> vertex_kdtree;
+#endif
};
DEAL_II_NAMESPACE_CLOSE
* GridTools::vertex_to_cell_centers_directions()
*/
cache_vertex_to_cell_centers_directions = cache_vertex_to_cell_map | 0x0002,
+
+#ifdef DEAL_II_WITH_NANOFLANN
+ /**
+ * Cache a KDTree object, initialized with the vertices of the Triangulation.
+ */
+ cache_vertex_kdtree = 0x0004,
+#endif
};
s << " TriangulationInfoCacheFlags";
if (u & cache_vertex_to_cell_map) s << "|vertex_to_cell_map";
if (u & cache_vertex_to_cell_centers_directions) s << "|vertex_to_cells_centers_directions";
+#ifdef DEAL_II_WITH_NANOFLANN
+ if (u & cache_vertex_kdtree) s << "|vertex_kdtree";
+#endif
return s;
}
{
if (cache_vertex_to_cell_map & flags)
vertex_to_cells = GridTools::vertex_to_cell_map(*tria);
+
+#ifdef DEAL_II_WITH_NANOFLANN
+ if (cache_vertex_kdtree & flags)
+ vertex_kdtree.set_points(tria->get_vertices());
+#endif
}
if (cache_vertex_to_cell_centers_directions & flags)
return vertex_to_cell_centers;
}
+
+
+#ifdef DEAL_II_WITH_NANOFLANN
+template<int dim, int spacedim>
+const KDTree<spacedim> &TriangulationInfoCache<dim,spacedim>::get_vertex_kdtree() const
+{
+ Assert(flags & cache_vertex_kdtree,
+ ExcAccessToInvalidCacheObject(cache_vertex_kdtree, flags));
+ return vertex_kdtree;
+}
+#endif
+
+#include "tria_info_cache.inst"
+
DEAL_II_NAMESPACE_CLOSE
+