On 5/16/23 16:13, Mathieu wrote:
I have a 2d grid (no hanging nodes) where a scalar finite element field is
defined on it (i.e., one degree of freedom per support point).
For all vertices defined on that grid, I want to get the global dof indices of
all connected vertices.
E.g.: an vertex inside the grid has four vertices connected to it (five-point
stencil), the four corner vertices have two connected vertices each,...
There isn't a function for this at the moment primarily because "connected
vertices" can be interpreted in many ways. You are specifically considering
"connected by a common edge", whereas a more common interpretation in the
finite element context would be "share a common cell".
But if you want "connected by an edge", that suggests the following algorithm:
std::vector<std::set<types::global_dof_indices>>
connections(dof_handler.n_dofs());
for (auto &cell : ...)
for (unsigned int e=0; e<cell->n_lines(); ++e)
{
std::vector<types::global_dof_indices> edge_dofs;
// ...need to set edge_dofs to the right size...
cell->line(e)->get_dof_indices (edge_dofs);
for (auto i : edge_dofs)
for (auto j : edge_dofs)
if (i != j)
connections[i].insert(j);
}
Best
W.
--
------------------------------------------------------------------------
Wolfgang Bangerth email: [email protected]
www: http://www.math.colostate.edu/~bangerth/
--
The deal.II project is located at http://www.dealii.org/
For mailing list/forum options, see
https://groups.google.com/d/forum/dealii?hl=en
---
You received this message because you are subscribed to the Google Groups "deal.II User Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/dealii/244950dd-00f1-518a-d668-13d7493cac09%40colostate.edu.