I still want to check my understanding on the first return value point_owners
. Please correct me if I am wrong.
It is a list of int which infers the process ranks to evaluate each DOF point that the current process owns.
Its length may be greater than the number of DOFs that the current process owns as the DOFs are gathered from each cell and piled up.
Then the length of point_owners
should be equal to the following expression.
len(point_owners) = cell_map_total_num * function_space.dofmap.dof_layout.num_dofs
And the corresponding DOF IDs of the list point_owners
should be retrived as follows.
point = [dof for i in range(cell_map_total_num) for dof in function_space.dofmap.cell_dofs(i)]
The full MWE:
# QnA_point_owners.py
# mpirun -n 2 python QnA_point_owners.py
from mpi4py import MPI
from dolfinx import fem, mesh, cpp
rank = MPI.COMM_WORLD.rank
# Mesh
n1, n2 = 5, 5
meshf = mesh.create_unit_square(MPI.COMM_WORLD, n1, n1, cell_type=cpp.mesh.CellType.quadrilateral)
meshs = mesh.create_unit_square(MPI.COMM_WORLD, n2, n2, cell_type=cpp.mesh.CellType.triangle)
meshs.geometry.x[:, : ] *= 0.5
meshs.geometry.x[:, :2] += 0.25
# Function spaces and functions
order = 1
Qf = fem.FunctionSpace(meshf, ("Lagrange", order))
Qs = fem.FunctionSpace(meshs, ("Lagrange", order))
# Interpolation data
point_owners, owned_recv_ranks, owned_recv_points, owned_recv_cells = (
fem.create_nonmatching_meshes_interpolation_data(
Qs.mesh._cpp_object,
Qs.element,
Qf.mesh._cpp_object,
padding=1e-6)
)
topology_s = Qs.mesh.topology
tdim_s = Qs.mesh.topology.dim
cell_map_s = topology_s.index_map(tdim_s)
cell_total_num_s = cell_map_s.size_local + cell_map_s.num_ghosts
assert len(point_owners) == cell_total_num_s * Qs.dofmap.dof_layout.num_dofs
points = [dof for i in range(cell_total_num_s) for dof in Qs.dofmap.cell_dofs(i)]
print(f"rank\n{rank}\n"
f"len(point_owners)\n{len(point_owners)}\n"
f"points:\n{points}\n")