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:
bang...@colostate.edu
www:
http://www.math.colostate.edu/~bangerth/