Specify MPI distribution of mesh
Motivated by http://fenicsproject.org/qa/8450/mpi4py-how-to-disable-automatic-distribution-of-mesh
Currently, mshr.generate_mesh() will create a mesh living on all processes. This might not be desired behaviour. Simplest solution would be to change signature of generate_mesh from
generate_mesh(domain, resolution, backend="cgal")
to
generate_mesh(domain, resolution, backend="cgal", mesh=None)
Comments (7)
-
-
reporter There are probably cases where you'd want to distribute over a subset of processes. Passing an MPI-communicator would be consistent with how it works in dolfin. Is it problematic in swig?
-
No, I think the swig part is trivial.
I was just thinking that since meshes are generated in serial anyway, if would be cleaner if the user took care of the distribution if you don't want the default behaviour (ie. generate on process 0 and distribute over all processes).
-
reporter Possibly. Although I'm not sure how to distribute an existing mesh. I have no strong opinions, and I also think the existing workaround is perfectly ok (passing the mesh to _generate).
-
Ok. have you checked that it works?
dolfin::MeshPartitioning can partition and distribute an existing mesh to all processes, but I don't know if you can specify the processes to distribute to. Maybe dolfin::MeshPartitioning should be extended to support this?
-
reporter Yes, it works, also with other group communicators.
I know nothing about how dolfin::MeshPartitioning works.
-Øyvind
-
Ok, good to know. Thanks.
- Log in to comment
Would something like
generate_mesh(domain, resolution, backend, distribute=True)
work?
If distribute is false, then the entire mesh will live on the process where it is created.