Spawning independent dolfin processes with mpi4py AND mshr

Hello,

I’m trying to spawn independent processes using mpi4py AND mshr. Each of these processes solves the same PDE using Dolfin. I tried to generalize the result from this discussion. My actual geometry is more complex than in the example below.

import dolfin
import mshr
from petsc4py import PETSc
from mpi4py import MPI
comm = PETSc.Comm(MPI.COMM_SELF)

vertics = [dolfin.Point(0,0),dolfin.Point(1,0),dolfin.Point(1,1),dolfin.Point(0,1),dolfin.Point(0,0)]
domain = mshr.Polygon(vertics)
mesh = mshr.generate_mesh(domain, 20)

How do you pass comm to the mesh?

Or how do you avoid mshr from distributing the mesh to different processes? Back in 2015, there was a discussion of how to implement a bool distribute parameter in generate_mesh, but this hasn’t happened. The function mshr._generate is also no longer available in the 2019 version of fenics and mshr.

1 Like