Extracting boundary values in parallel

Hi,

I am running this code using mpirun:

import dolfin as dl
from mpi4py import MPI

comm = MPI.COMM_WORLD
mesh = dl.RectangleMesh(comm,dl.Point(0,0),dl.Point(1,1),100,100)

V = dl.FunctionSpace(mesh,'CG',1)
f = dl.Expression('(1-sin(x[0]))*(1-cos(x[1]))', degree=2)

u = dl.Function(V)
u = dl.project(f,V)

out_boundary = lambda x, on_boundary: on_boundary and dl.near(x[1],1, 1E-14)

I would like to evaluate f on the out_boundary and collect this information on rank=0. The issue is that this boundary is shared among all processes. Does anyone know what is the correct way to do this?

Thank you very much for the help.

What you state is the easiest way to do what you require: Evaluate f on each process which contains out_boundary then communicate that information to rank 0.

Thank you Nate! Do you know how to check which process contains a point?

See, e.g., Implementation — FEniCSx tutorial

1 Like