Hello to all,

I am preparing a text-book on Programming Methods, which includes chapters on mpi4py and elementary FEniCS.

I would like to present an example of the form

mpirun -n 4 python3 poisson.py

that distributes the computation to 4 processes, and then gathers the partial results together into a global one.

The equation is the standard

from dolfin import *

mesh = UnitSquareMesh(32, 32)

V = FunctionSpace(mesh, ‘CG’, 1)

u = TrialFunction(V)

v = TestFunction(V)

f = Constant(-6.0)

g = Expression('1 + x[0]*x[0] + 2*x[1]*x[1]’, degree=2)
bc = DirichletBC(V, g, ‘on_boundary’)
a = inner(grad(u), grad(v))*dx

*dx L = f*v

u = Function(V)

solve(a == L, u, bc)

I use FEniCS 2018.1.0, installed via the standard procedure on a virtual Ubuntu 18.04 envirionment on a Mac.

Preferably I would also like to plot the combined result with

from matplotlib.pyplot import show

plot(u, mode=“warp”)

show()

Thanks in advance