This is a read only copy of the old FEniCS QA forum. Please visit the new QA forum to ask questions

Compare 2 different solutions (different meshes) in parallel

+2 votes

Hi,

I'm solving a problem using two different methods, and as a consequence, obtaining two different solutions, lets say phi and phi_h.

The domain for both phi and phi_h is the same, but the meshes used are different (the characteristic element size is low for the phi_h solution).

To calculate the L2-norm between the solutions the following code can be occupied:

  phi_h     = interpolate(phi_h, V)
  m2        = inner(phi-phi_hi, phi - phi_hi)*dx
  m3        = inner(phi, phi)*dx
  l2_norm_dif   = assemble(m2)
  l2_norm   = assemble(m3)
  error_rel = abs(l2_norm_dif/(l2_norm ))

where V is the function space where phi belongs.

The code works perfectly in serial, but in parallel the interpolate() function crash, i think cause try to interpolate the partitioned meshes for each processor.

The error message is (prompted for each processor):

*** 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.

If someone know a way to parallelize the previous code i'd really appreciate it.

Thanks in advice, and sorry for mi poor English.

asked Feb 6, 2016 by felipe_galarce FEniCS User (1,190 points)

1 Answer

+4 votes
 
Best answer

There is a long known problem of interpolation in parallel. You may be able to use the LagrangeInterpolator in dolfin, which can do it I think.

answered Feb 6, 2016 by chris_richardson FEniCS Expert (31,740 points)
selected Feb 6, 2016 by felipe_galarce

thank you, it works.

The implementation is:

  phi_hi = Function(V)
  LI = LagrangeInterpolator() 
  LI.interpolate(phi_hi, phih)
  m2        = inner(phi-phi_hi, phi - phi_hi)*dx
  m3        = inner(phi, phi)*dx
  l2_norm_dif   = assemble(m2)
  l2_norm   = assemble(m3)
  error_rel = abs(l2_norm_dif/(l2_norm))

NOTE: this highly slows the code, but for now is ok.

...