dokken
November 21, 2024, 4:41pm
2
rsz7ncf24p:
Am I overlooking something or is this intended behavior? If so, why, and can I, in an inexpensive post-processing step, reorder the DOFs such that they are aligned with the mesh coordinates again?
Thank you.
It is intended behavior as:
the function is designed to work with arbitrary order function spaces and meshes, you cannot rely on this 1-1 correspondence.
It is supposed to work in parallel (on data partitioned with mpi), which introduces a whole other set of considerations
Why do you rely on this ordering being the same?
There are several functions to map data from degrees of freedom to vertices, and even the mesh geometry nodes, as discussed in:
Here is a vectorized version of the code above (credit to @dokken )
def vertex_to_dof_map_original(mesh, V):
num_vertices = (
mesh.topology.index_map(0).size_local + mesh.topology.index_map(0).num_ghosts
)
vertex_to_dof_map = np.empty(num_vertices, dtype=np.int32)
num_cells = (
mesh.topology.index_map(mesh.topology.dim).size_local
+ mesh.topology.index_map(mesh.topology.dim).num_ghosts
)
c_to_v = mesh.topology.connectivity(mesh.topology.dim, 0)
…
I don’t have time to read that user manual.
Assuming that what is in NSET describes the original nodes in the mesh you would like to constrain, you need to:
Create a map from the input node index to a vertex on your process, this is simply a matter of inverting mesh.geometry.input_global_indices.
Once you have a map from the global indices (in your case a map from 97, 96, 95, ... to what is local on the process), you remove all the results that are -1.
You then map from geometry to topology …
(And to some extent in: Renumbered .msh imported data giving wrong subdomains - #4 by dokken )
I would start with mapping dofs in the submesh to the nodes of the geometry in the submesh, and then use the last output argument of ‘create_submesh` to map these geometry indices from the submesh to the parent mesh.
https://docs.fenicsproject.org/dolfinx/v0.9.0/python/generated/dolfinx.mesh.html#dolfinx.mesh.create_submesh
1 Like