### get a displacement at a node in parallel

282
views
0
7 months ago by
Dear all,

I am solving a linear elasticity problem in parallel. I wanted to ouput the vertical displacement at a node of which coordinates are (0,8.1):

self.out_u = self.u(0, 8.1)[1]

*** Error: Unable to evaluate function at point.
*** Reason: The point is not inside the domain. Consider calling "Function::set_allow_extrapolation(true)" on this Function to allow extrapolation.
*** Where: This error was encountered inside Function.cpp.
*** Process: 3

Thanks.
Phu
Community: FEniCS Project

0
7 months ago by
Function is distributed amongst processes so you can't efficiently (without communication) evaluate the function at an arbitrary process. If you really need to do so, you have to communicate the value:

from dolfin import *

mesh = UnitSquareMesh(3, 3)
comm = mesh.mpi_comm()
V = FunctionSpace(mesh, "P", 1)
u = Function(V)

try:
u0 = u(0.0, 0.0)
except RuntimeError:
u0 = None

u0 = comm.bcast(u0)

print('rank {}: value {}'.format(comm.rank, u0))​

This is tested with the 2018.1.0.dev0 version of FEniCS with new pybind11 Python interface and mpi4py installed. I suspect that with old versions casting the comm to mpi4py comm by comm = comm.tompi4py() should be enough.
Thanks, Jan. As we used old versions, could you please give more details on how to make it work? The following is the code:

comm = self.mesh.mpi_comm()
 comm = comm.tompi4py()
 try:
  u0 = u(0.0, 8.1)[1]
 except RuntimeError:
  u0 = None

Then when I want to output u0 as usual "%.5e", it reports:

TypeError: Mismatch between array dtype ('object') and format specifier ('%.5e')

what should I do? Thank you.
written 7 months ago by jywu
You have to do the MPI broadcast. See above.
written 7 months ago by Jan Blechta
Hi, Jan,

I used the following code:

comm = self.mesh.mpi_comm()
 comm = comm.tompi4py()
 try:
  u = self.u(0.0, 8.1)[1]
 except RuntimeError:
  u = None

 out_u = comm.bcast(u)

However, the output gives value None for all processors. Any more hint?
written 7 months ago by jywu
If you want me to debug your code, post an MWE please.
written 7 months ago by Jan Blechta
0
7 months ago by
If you want parallel projections on different domains try this:

https://github.com/mikaem/fenicstools/wiki/Interpolate-nonmatching-mesh
by Prof. Mortensen.

Your problem is not the parallel. You are trying to take information from another domain. *** Reason: The point is not inside the domain. Consider calling "Function::set_allow_extrapolation(true)" on this Function to allow extrapolation.

If you fix your code using interpolate_nonmatching_mesh you will not be getting this error.

Minas
1
This functionality has been pulled into FEniCS as class LagrangeInterpolator.
written 7 months ago by Jan Blechta
Thanks, Minas. I just want to output the solution of a specific vertex. This is easy in serial computation but seems very hard for parallel one. But it should be a very common question, shouldn't it?
written 7 months ago by jywu