How do I extract coordinates of DOF points in high-order FE Space? #4890
-
Hello, This might be a very simple question, but I have been unable to find an answer. I have a very simple mesh (a 2D square meshed with triangles). I define a finite element space on the mesh using high-order Lagrange basis functions
From here, how do I get the coordinates of the interpolation (DOF) points? GetNode/GetNodes only seem to return the vertices, which I’m assuming is because the mesh itself is affine. Best, |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 3 replies
-
Hi, This is explained in #63, but it can be a bit confusing because by default Alternatively you can set the FiniteElementSpace of the nodes internal to Mesh using |
Beta Was this translation helpful? Give feedback.
-
Another approach that computes the coordinates on the fly, element by element, is: void print_fes_coords_by_element(FiniteElementSpace &fes)
{
DenseMatrix coords;
for (int i = 0; i < fes.GetNE(); i++)
{
const FiniteElement *fe = fes.GetFE(i);
ElementTransformation *T = fes.GetElementTransformation(i);
T->Transform(fe->GetNodes(), coords);
cout << "element " << i << ":\n";
for (int j = 0; j < coords.Width(); j++)
{
cout << " dof " << j << ':';
for (int d = 0; d < coords.Height(); d++)
{
cout << ' ' << coords(d,j);
}
cout << '\n';
}
}
} |
Beta Was this translation helpful? Give feedback.
Hi,
This is explained in #63, but it can be a bit confusing because by default
Mesh::GetNodes()
(for low-order straight-edged meshes) just returns the vertices. For higher-order FE spaces, you can useMesh::GetNodes(GridFunction &gf)
, where the grid function is defined on the FE space of higher-order.Alternatively you can set the FiniteElementSpace of the nodes internal to Mesh using
Mesh::SetNodalFESpace
to one of higher-order and then callMesh::GetNodes()
.