Reference documentation for deal.II version 9.0.0
grid_tools_cache.h
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 at
12 // the top level of the deal.II distribution.
13 //
14 // ---------------------------------------------------------------------
15 
16 #ifndef dealii_grid_grid_tools_cache_h
17 #define dealii_grid_grid_tools_cache_h
18 
19 
20 #include <deal.II/base/config.h>
21 #include <deal.II/base/subscriptor.h>
22 #include <deal.II/base/exceptions.h>
23 #include <deal.II/base/point.h>
24 
25 #include <deal.II/grid/tria.h>
26 #include <deal.II/grid/tria_iterator.h>
27 #include <deal.II/grid/tria_accessor.h>
28 #include <deal.II/grid/grid_tools_cache_update_flags.h>
29 #include <deal.II/fe/mapping_q1.h>
30 
31 #include <deal.II/numerics/kdtree.h>
32 
33 #include <boost/signals2.hpp>
34 
35 #include <cmath>
36 
37 DEAL_II_NAMESPACE_OPEN
38 
39 namespace GridTools
40 {
41 
65  template <int dim, int spacedim = dim>
66  class Cache : public Subscriptor
67  {
68  public:
80 
84  ~Cache();
85 
96  void mark_for_update(const CacheUpdateFlags &flags=update_all);
97 
98 
102  const std::vector< std::set<typename Triangulation<dim,spacedim>::active_cell_iterator> >
103  &get_vertex_to_cell_map() const;
104 
109  const std::vector<std::vector<Tensor<1,spacedim>>>
111 
116  const std::map<unsigned int, Point<spacedim> >
117  &get_used_vertices() const;
118 
123 
127  const Mapping<dim,spacedim> &get_mapping() const;
128 
129 #ifdef DEAL_II_WITH_NANOFLANN
130 
134  const KDTree<spacedim> &get_vertex_kdtree() const;
135 #endif
136 
137  private:
142 
148 
154 
155 
160  mutable std::vector< std::set<typename Triangulation<dim,spacedim>::active_cell_iterator> >
162 
167  mutable std::vector<std::vector<Tensor<1,spacedim>>> vertex_to_cell_centers;
168 
169 #ifdef DEAL_II_WITH_NANOFLANN
170 
174 #endif
175 
180  mutable std::map<unsigned int, Point<spacedim>> used_vertices;
181 
185  boost::signals2::connection tria_signal;
186  };
187 
188 
189 
190  // Inline functions
191  template<int dim, int spacedim>
192  inline const Triangulation<dim, spacedim> &
194  {
195  return *tria;
196  }
197 
198 
199 
200  template<int dim, int spacedim>
201  inline const Mapping<dim, spacedim> &
203  {
204  return *mapping;
205  }
206 }
207 
208 
209 
210 DEAL_II_NAMESPACE_CLOSE
211 
212 #endif
const Triangulation< dim, spacedim > & get_triangulation() const
boost::signals2::connection tria_signal
KDTree< spacedim > vertex_kdtree
const Mapping< dim, spacedim > & get_mapping() const
std::vector< std::set< typename Triangulation< dim, spacedim >::active_cell_iterator > > vertex_to_cells
Cache(const Triangulation< dim, spacedim > &tria, const Mapping< dim, spacedim > &mapping=StaticMappingQ1< dim, spacedim >::mapping)
SmartPointer< const Mapping< dim, spacedim >, Cache< dim, spacedim > > mapping
Definition: tria.h:76
SmartPointer< const Triangulation< dim, spacedim >, Cache< dim, spacedim > > tria
Abstract base class for mapping classes.
Definition: dof_tools.h:46
void mark_for_update(const CacheUpdateFlags &flags=update_all)
const std::vector< std::vector< Tensor< 1, spacedim > > > & get_vertex_to_cell_centers_directions() const
const std::map< unsigned int, Point< spacedim > > & get_used_vertices() const
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
const std::vector< std::set< typename Triangulation< dim, spacedim >::active_cell_iterator > > & get_vertex_to_cell_map() const