Expose num_threads when reading in meshes from XDMFFile and VTKHDF - #4527
MariusCausemann wants to merge 10 commits into
Conversation
Co-authored-by: Jørgen Schartum Dokken <dokken92@gmail.com>
Co-authored-by: Jørgen Schartum Dokken <dokken92@gmail.com>
…emann/dolfinx into read_mesh_num_threads
|
@MariusCausemann can you add some of the notes with respect to your findings of nanobind lookup? |
|
Sure! This is what claude said about it, shortened by me: "
nanobind matches keyword names before it converts anything. The 1st overload has no parameter called element (its elements), so nanobind rejects it straight away." On my example mesh, using keywords reduced edit: On a larger mesh, the nanobind issue alone halves the |
|
Yikes, nice find! Does this mean this is now faster because of differing If so I don't think this is the right fix. We should remove either one of the overloads to unify to a single |
| vol_1 = mesh_1.comm.allreduce( | ||
| dolfinx.fem.assemble_scalar(dolfinx.fem.form(1 * ufl.dx(domain=mesh_1))), op=MPI.SUM | ||
| ) | ||
| vol_n = mesh_n.comm.allreduce( | ||
| dolfinx.fem.assemble_scalar(dolfinx.fem.form(1 * ufl.dx(domain=mesh_n))), op=MPI.SUM | ||
| ) |
I think using keyword arguments as done in this PR is fine. It of course doesn't fix the issue on a deeper level. |
|
I added a fix on the nanobind level now, allowing only list or tuple for the cells argument in the mixed dim create_mesh call. This fixes the issue, what do you think @jorgensd and @schnellerhase ? I also had claude look through the whole dolfinx repo for similar nanobind issues, but it claims everything else is fine. |
You are right, that does not solve the overload standalone - the array also is a sequence so it is no conversion initially. The new code path does not look preferable to me: a lot of special case handling and explicit casting. Revert c4dc8c6, file an issue and can be fixed else where as @jorgensd suggested? |
| cells_nb.push_back(std::move(a)); | ||
| } | ||
|
|
||
| std::vector<std::span<const std::int64_t>> cells; |
There was a problem hiding this comment.
Simpler with std::vector<std::span<const std::int64_t>> cells = vec_of_spans(cells_nb);.
c4dc8c6 to
59b139a
Compare
|
I have reverted the last commit, and opened a new issue for the nanobind overload #4542 |
Addresses #4521