Reference documentation for deal.II version 9.1.0-pre
grid_tools_cache.cc
1 // ---------------------------------------------------------------------
2 //
3 // Copyright (C) 2017 by the deal.II authors
4 //
5 // This file is part of the deal.II library.
6 //
7 // The deal.II library is free software; you can use it, redistribute
8 // it, and/or modify it under the terms of the GNU Lesser General
9 // Public License as published by the Free Software Foundation; either
10 // version 2.1 of the License, or (at your option) any later version.
11 // The full text of the license can be found in the file LICENSE.md at
12 // the top level directory of deal.II.
13 //
14 // ---------------------------------------------------------------------
15 
16 #include <deal.II/grid/grid_tools.h>
17 #include <deal.II/grid/grid_tools_cache.h>
18 
19 DEAL_II_NAMESPACE_OPEN
20 
21 namespace GridTools
22 {
23  template <int dim, int spacedim>
25  const Mapping<dim, spacedim> & mapping)
26  : update_flags(update_all)
27  , tria(&tria)
28  , mapping(&mapping)
29  {
30  tria_signal =
31  tria.signals.any_change.connect([&]() { mark_for_update(update_all); });
32  }
33 
34  template <int dim, int spacedim>
36  {
37  // Make sure that the signals that was attached to the triangulation
38  // is removed here.
39  if (tria_signal.connected())
40  tria_signal.disconnect();
41  }
42 
43 
44 
45  template <int dim, int spacedim>
46  void
48  {
49  update_flags |= flags;
50  }
51 
52 
53 
54  template <int dim, int spacedim>
55  const std::vector<
56  std::set<typename Triangulation<dim, spacedim>::active_cell_iterator>> &
58  {
60  {
62  update_flags = update_flags & ~update_vertex_to_cell_map;
63  }
64  return vertex_to_cells;
65  }
66 
67 
68 
69  template <int dim, int spacedim>
70  const std::vector<std::vector<Tensor<1, spacedim>>> &
72  {
74  {
77  update_flags = update_flags & ~update_vertex_to_cell_centers_directions;
78  }
80  }
81 
82 
83 
84  template <int dim, int spacedim>
85  const std::map<unsigned int, Point<spacedim>> &
87  {
89  {
91  update_flags = update_flags & ~update_used_vertices;
92  }
93  return used_vertices;
94  }
95 
96 
97 
98 #ifdef DEAL_II_WITH_NANOFLANN
99  template <int dim, int spacedim>
100  const KDTree<spacedim> &
102  {
104  {
105  vertex_kdtree.set_points(tria->get_vertices());
106  update_flags = update_flags & ~update_vertex_kdtree;
107  }
108  return vertex_kdtree;
109  }
110 #endif
111 
112 #include "grid_tools_cache.inst"
113 
114 } // namespace GridTools
115 
116 DEAL_II_NAMESPACE_CLOSE
boost::signals2::connection tria_signal
std::map< unsigned int, Point< spacedim > > extract_used_vertices(const Triangulation< dim, spacedim > &container, const Mapping< dim, spacedim > &mapping=StaticMappingQ1< dim, spacedim >::mapping)
Definition: grid_tools.cc:4740
KDTree< spacedim > vertex_kdtree
Cache(const Triangulation< dim, spacedim > &tria, const Mapping< dim, spacedim > &mapping=StaticMappingQ1< dim, spacedim >::mapping)
std::vector< std::set< typename Triangulation< dim, spacedim >::active_cell_iterator > > vertex_to_cell_map(const Triangulation< dim, spacedim > &triangulation)
Definition: grid_tools.cc:1919
Definition: tria.h:81
const std::map< unsigned int, Point< spacedim > > & get_used_vertices() const
Signals signals
Definition: tria.h:2287
Abstract base class for mapping classes.
Definition: dof_tools.h:57
const std::vector< std::vector< Tensor< 1, spacedim > > > & get_vertex_to_cell_centers_directions() const
SmartPointer< const Mapping< dim, spacedim >, Cache< dim, spacedim > > mapping
SmartPointer< const Triangulation< dim, spacedim >, Cache< dim, spacedim > > tria
void mark_for_update(const CacheUpdateFlags &flags=update_all)
std::vector< std::vector< Tensor< 1, spacedim > > > vertex_to_cell_centers_directions(const Triangulation< dim, spacedim > &mesh, const std::vector< std::set< typename Triangulation< dim, spacedim >::active_cell_iterator >> &vertex_to_cells)
Definition: grid_tools.cc:1436
void set_points(const std::vector< Point< dim >> &pts)
Definition: kdtree.cc:84
const KDTree< spacedim > & get_vertex_kdtree() const
CacheUpdateFlags update_flags
std::map< unsigned int, Point< spacedim > > used_vertices
std::vector< std::vector< Tensor< 1, spacedim > > > vertex_to_cell_centers
std::vector< std::set< typename Triangulation< dim, spacedim >::active_cell_iterator > > vertex_to_cells
const std::vector< std::set< typename Triangulation< dim, spacedim >::active_cell_iterator > > & get_vertex_to_cell_map() const