]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Vertex to cell centers directions.
authorLuca Heltai <luca.heltai@sissa.it>
Thu, 14 Sep 2017 08:43:02 +0000 (10:43 +0200)
committerLuca Heltai <luca.heltai@sissa.it>
Thu, 14 Sep 2017 16:20:13 +0000 (18:20 +0200)
include/deal.II/grid/tria_info_cache.h
include/deal.II/grid/tria_info_cache_flags.h
source/grid/tria_info_cache.cc

index d48b5209d0ab29ae9d644e2d38431b52a24a27e9..5ef199d1f8dec73f1b0a317c506410dbc24a0602 100644 (file)
@@ -96,6 +96,13 @@ public:
   const std::vector< std::set<typename Triangulation<dim,spacedim>::active_cell_iterator> >
   &get_vertex_to_cell_map() const;
 
+  /**
+   * Return the cached vertex_to_cell_centers_directions as computed by
+   * GridTools::vertex_to_cell_centers_directions().
+   */
+  const std::vector<std::vector<Tensor<1,spacedim>>>
+  &get_vertex_to_cell_centers_directions() const;
+
   /**
    * Exception for uninitialized cache fields.
    */
@@ -130,6 +137,12 @@ private:
    * GridTools::vertex_to_cell_map()
    */
   std::vector< std::set<typename Triangulation<dim,spacedim>::active_cell_iterator> > vertex_to_cells;
+
+  /**
+   * Store vertex to cell center directions, as generated by
+   * GridTools::vertex_to_cell_centers_directions.
+   */
+  std::vector<std::vector<Tensor<1,spacedim>>> vertex_to_cell_centers;
 };
 
 DEAL_II_NAMESPACE_CLOSE
index 181b2f38151eedc04ed3552742d09ac504c3181e..165d735c68794e9cacb0d64272b7f84049a73422 100644 (file)
@@ -41,6 +41,12 @@ enum TriangulationInfoCacheFlags
    * Cache vertex_to_cell_map, as returned by GridTools::vertex_to_cell_map().
    */
   cache_vertex_to_cell_map = 0x0001,
+
+  /**
+   * Cache vertex_to_cell_centers_directions, as returned by
+   * GridTools::vertex_to_cell_centers_directions()
+   */
+  cache_vertex_to_cell_centers_directions = cache_vertex_to_cell_map | 0x0002,
 };
 
 
@@ -54,7 +60,8 @@ inline
 StreamType &operator << (StreamType &s, TriangulationInfoCacheFlags u)
 {
   s << " TriangulationInfoCacheFlags";
-  if (u & cache_vertex_to_cell_map) s << "|vertex_to_cell_map"        ;
+  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";
   return s;
 }
 
index 5be00323a021b18748fcec85566f57725e17a221..dc975f59af63be4a7ae12dcf4ce13f40c5349034 100644 (file)
@@ -20,9 +20,9 @@ DEAL_II_NAMESPACE_OPEN
 
 template<int dim, int spacedim>
 TriangulationInfoCache<dim,spacedim>::TriangulationInfoCache(
-    const Triangulation<dim, spacedim> &tria,
-    const TriangulationInfoCacheFlags &flags,
-    const Mapping<dim, spacedim> &mapping) :
+  const Triangulation<dim, spacedim> &tria,
+  const TriangulationInfoCacheFlags &flags,
+  const Mapping<dim, spacedim> &mapping) :
   tria(&tria),
   flags(flags),
   mapping(&mapping)
@@ -32,7 +32,7 @@ TriangulationInfoCache<dim,spacedim>::TriangulationInfoCache(
     update();
   });
 
-  if(tria.n_active_cells()>0)
+  if (tria.n_active_cells()>0)
     update();
 }
 
@@ -41,12 +41,19 @@ TriangulationInfoCache<dim,spacedim>::TriangulationInfoCache(
 template<int dim, int spacedim>
 void TriangulationInfoCache<dim,spacedim>::update(bool topology_is_unchanged)
 {
-  if(topology_is_unchanged == false) {
-    if (cache_vertex_to_cell_map & flags)
+  if (topology_is_unchanged == false)
+    {
+      if (cache_vertex_to_cell_map & flags)
         vertex_to_cells = GridTools::vertex_to_cell_map(*tria);
-  }
+    }
+
+  if (cache_vertex_to_cell_centers_directions & flags)
+    vertex_to_cell_centers =
+      GridTools::vertex_to_cell_centers_directions(*tria, vertex_to_cells);
 }
 
+
+
 template<int dim, int spacedim>
 const std::vector<std::set<typename Triangulation<dim,spacedim>::active_cell_iterator> > &
 TriangulationInfoCache<dim,spacedim>::get_vertex_to_cell_map() const
@@ -58,5 +65,13 @@ TriangulationInfoCache<dim,spacedim>::get_vertex_to_cell_map() const
 
 
 
+template<int dim, int spacedim>
+const std::vector<std::vector<Tensor<1,spacedim>>> &
+TriangulationInfoCache<dim,spacedim>::get_vertex_to_cell_centers_directions() const
+{
+  Assert(flags & cache_vertex_to_cell_centers_directions,
+         ExcAccessToInvalidCacheObject(cache_vertex_to_cell_centers_directions, flags));
+  return vertex_to_cell_centers;
+}
 
 DEAL_II_NAMESPACE_CLOSE

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.