]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Vertex to cells center directions.
authorLuca Heltai <luca.heltai@sissa.it>
Sat, 12 Aug 2017 21:53:13 +0000 (15:53 -0600)
committerLuca Heltai <luca.heltai@sissa.it>
Mon, 14 Aug 2017 19:09:00 +0000 (13:09 -0600)
include/deal.II/grid/grid_tools.h
source/grid/grid_tools.cc

index 32d3bc5245192cfc87ae138f8ef479c23ebd3709..4e16025de79205bbe01a930c186267d1d53d1927 100644 (file)
@@ -1024,6 +1024,17 @@ namespace GridTools
   vertex_to_cell_map(const Triangulation<dim,spacedim> &triangulation);
 
   /**
+   * Returns a vector that contains a tensor for every vertex-cell combination
+   * of the output of GridTools::vertex_to_cell_map() (which is expected as
+   * input parameter for this function). Each tensor represents a geometric
+   * vector from the vertex to the respective cell center.
+   *
+   * @author Rene Gassmoeller, Luca Heltai, 2017.
+   */
+  template <int dim, int spacedim>
+  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);
 
 
   /**
index 6c9e9d5a387cfd93c19cd0c5c9e06a9fd242f6e6..920fd0f78303d72bae77cc6fdf7430254ad56db0 100644 (file)
@@ -1458,6 +1458,31 @@ next_cell:
     return best_cell;
   }
 
+  template <int dim,int spacedim>
+  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)
+  {
+    const std::vector<Point<spacedim> > &vertices = mesh.get_vertices();
+    const unsigned int n_vertices = vertex_to_cells.size();
+
+    std::vector<std::vector<Tensor<1,spacedim> > > vertex_to_cell_centers(n_vertices);
+    for (unsigned int vertex=0; vertex<n_vertices; ++vertex)
+      if (mesh.vertex_used(vertex))
+        {
+          const unsigned int n_neighbor_cells = vertex_to_cells[vertex].size();
+          vertex_to_cell_centers[vertex].resize(n_neighbor_cells);
+
+          typename std::set<typename Triangulation<dim,spacedim>::active_cell_iterator>::iterator it = vertex_to_cells[vertex].begin();
+          for (unsigned int cell=0; cell<n_neighbor_cells; ++cell,++it)
+            {
+              vertex_to_cell_centers[vertex][cell] = (*it)->center() - vertices[vertex];
+              vertex_to_cell_centers[vertex][cell] /= vertex_to_cell_centers[vertex][cell].norm();
+            }
+        }
+    return vertex_to_cell_centers;
+  }
+
 
 
   template <int dim, int spacedim>

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.