Conversation
|
Side note: please disregard the RUF052 (astral-sh/ruff#14796) and pylint linter failures (pylint-dev/pylint#10000 (comment)). |
| @@ -0,0 +1,90 @@ | |||
| __copyright__ = "Copyright (C) 2014 Andreas Kloeckner" | |||
| from meshmode.distributed import get_reordering_by_pymetis | ||
| perm, iperm = get_reordering_by_pymetis(from_discr.mesh) |
There was a problem hiding this comment.
Could you make the permutation a parameter to this function, rather than unconditionally obtaining it from pymetis?
|
|
||
| # Reorder the local mesh using Metis | ||
| from meshmode.distributed import get_reordering_by_pymetis | ||
| perm, iperm = get_reordering_by_pymetis(from_discr.mesh) |
There was a problem hiding this comment.
Will perm, iperm match the return value of get_reordering_by_pymetis? It seems that returns only a single array?
|
|
||
| # {{{ permute mesh elements | ||
|
|
||
| def make_element_permutation_connection(actx, from_discr): |
There was a problem hiding this comment.
| def make_element_permutation_connection(actx, from_discr): | |
| def make_element_permutation_connection(actx: ArrayContext, from_discr: Discretization) -> DirectDiscretizationConnection: |
|
|
||
|
|
||
| # FIXME: Move somewhere else, since it's not strictly limited to distributed? | ||
| def get_reordering_by_pymetis(mesh, *, connectivity="facial", **kwargs): |
There was a problem hiding this comment.
| def get_reordering_by_pymetis(mesh, *, connectivity="facial", **kwargs): | |
| def get_reordering_by_pymetis(mesh: meshmode.mesh.Mesh, *, connectivity: Literal["facial"] | Literal["nodal"], **kwargs) -> np.ndarray: |
|
|
||
| # {{{ permute mesh elements | ||
|
|
||
| def make_element_permutation_connection(actx, from_discr): |
There was a problem hiding this comment.
From @jonathan-macart's email, my understanding was that the objective of this is a mesh with the elements reordered. This connection instead shuffles DOF data between elements, while leaving the discretization in place.
To achieve the goal I mention above, you would need to make a permuted mesh, then make a discretization based on that.
| from_element_indices=all_elements, | ||
| to_element_indices=all_elements_perm, ## CHK?? |
There was a problem hiding this comment.
This mishandles meshes/discretizations with multiple element groups (e.g. a mesh that's part-hex-part-tet), in that it is silently broken (by using out-of-bounds indices) in that case. It's fine to assume single-group only, but then the code should error if presented with multiple groups.
|
|
||
|
|
||
| # FIXME: Move somewhere else, since it's not strictly limited to distributed? | ||
| def get_reordering_by_pymetis(mesh, *, connectivity="facial", **kwargs): |
There was a problem hiding this comment.
I think an argument could be made that the connectivity-getter could be factored into a separate function, since it seems it's duplicated from get_partition_by_pymetis?
Added:
get_reordering_by_pymetis: Compute mesh element reorderings (permutations) via Metis's nested dissection algorithm.make_element_permutation_connection: First attempt at generating a connection that permutes the elements of an existing mesh, sayfrom_mesh, to those of a new mesh,to_mesh, using the ND-generated permutation. The goal is to be able to passto_meshto a CFD solver. I do not need the mesh nodes to be reordered. My understanding is thatall_elements_permshould contain the permuted element tags offrom_mesh, though this could be completely incorrect.Currently, (2) returns a discretization connection containing two identical discretizations/meshes. A few thoughts/questions:
to_discr = from_discr.copy()a problem? My understanding is that this creates an exact replica offrom_discr.mesh, which is not the goal.to_discr.meshshould contain the same nodes and elements offrom_discr.mesh, but with the mesh ordering permuted usingperm.to_discr.meshactually changed upon creation of the connection?from_discr.meshwith the elements permuted?Any advice would be appreciated! Thank you!