-
-
Notifications
You must be signed in to change notification settings - Fork 199
Introduce create_identity_partitioner
for refined mesh partitioning
#3661
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
Verification code: import febug
import pyvista
import dolfinx
import dolfinx.mesh
from mpi4py import MPI
mesh = dolfinx.mesh.create_unit_square(MPI.COMM_WORLD, 4, 4)
mesh.topology.create_entities(2 - 1)
mesh.topology.create_connectivity(2 - 1, 2)
mesh.topology.create_entities(1)
[refined_mesh, _, _] = dolfinx.mesh.refine(
mesh, option=dolfinx.mesh.RefinementOption.parent_cell
)
subplotter = pyvista.Plotter(shape=(2, 1))
subplotter.subplot(0, 0)
febug.plot_mesh(mesh, plotter=subplotter)
subplotter.subplot(1, 0)
febug.plot_mesh(refined_mesh, plotter=subplotter)
# subplotter.show()
subplotter.save_graphic(f"out_{MPI.COMM_WORLD.rank}.pdf") |
|
create_identity_partitioner
for refined mesh partitioning
I have a problem with the It comes down to: how can a |
Exporting explicitly the empty partitioner case as m.def("empty_partitioner",
[&]
{
return std::make_optional<
dolfinx_wrappers::part::impl::PythonCellPartitionFunction>(
nullptr);
}); also does not work, since this gets auto transformed into a def test_empty_partitioner():
assert empty_partitioner() is not None |
What about using std::variant to explicitly deal with the three options (something, nullptr, nullopt)? |
I believe that would suffer from the same problem of |
Right - then I can't think of anyway of doing it except introducing an explicit sentinel type for this purpose. |
Introduces
create_identity_partitioner
which facilitates the exchange of ghost cells of a refined mesh whilst maintaining the partition of the coarse mesh. This introduces the necessity of a new sentinel variableredistribute
for the pythonrefine
functionality to distinguish between the C++ cases ofnullptr
andnullopt
correctly.This fixes (partially) #3443.
Additionally, this changes
compute_destination_ranks
from anonymous namespace todolfinx::graph
,dolfinx.mesh.refine
'spartitioner
default argument value was not aligning with cpp layer, fixed,refine
'soption
arg changed fromOption::none
toOption::parent_cell
,partitioner
argument ofrefine
is nowstd::optional
, allows for handling of case of not provided (which is different from providingnullptr
as callable).