From: Luca Heltai Date: Sat, 12 Aug 2017 21:53:13 +0000 (-0600) Subject: Vertex to cells center directions. X-Git-Tag: v9.0.0-rc1~1252^2~1 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=6847a69ca1a6903730c391b2ad74bf8fc6265c27;p=dealii.git Vertex to cells center directions. --- diff --git a/include/deal.II/grid/grid_tools.h b/include/deal.II/grid/grid_tools.h index 32d3bc5245..4e16025de7 100644 --- a/include/deal.II/grid/grid_tools.h +++ b/include/deal.II/grid/grid_tools.h @@ -1024,6 +1024,17 @@ namespace GridTools vertex_to_cell_map(const Triangulation &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 + std::vector > > + vertex_to_cell_centers_directions(const Triangulation &mesh, + const std::vector::active_cell_iterator> > &vertex_to_cells); /** diff --git a/source/grid/grid_tools.cc b/source/grid/grid_tools.cc index 6c9e9d5a38..920fd0f783 100644 --- a/source/grid/grid_tools.cc +++ b/source/grid/grid_tools.cc @@ -1458,6 +1458,31 @@ next_cell: return best_cell; } + template + std::vector > > + vertex_to_cell_centers_directions(const Triangulation &mesh, + const std::vector::active_cell_iterator> > &vertex_to_cells) + { + const std::vector > &vertices = mesh.get_vertices(); + const unsigned int n_vertices = vertex_to_cells.size(); + + std::vector > > vertex_to_cell_centers(n_vertices); + for (unsigned int vertex=0; vertex::active_cell_iterator>::iterator it = vertex_to_cells[vertex].begin(); + for (unsigned int cell=0; cellcenter() - vertices[vertex]; + vertex_to_cell_centers[vertex][cell] /= vertex_to_cell_centers[vertex][cell].norm(); + } + } + return vertex_to_cell_centers; + } + template