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

Using SubMesh and Extrapolation in parallel

0 votes

Dear all,

i'm trying to extract a submesh using cellmarkers and then interpolate a function f on this new mesh, obtaining a new function named fsub. Later i want to "extrapolate" fsub to the entire mesh using the interpolate function and setting the parameter "allow_extrapolation" equal to True, as i have attached in the below code.

from dolfin import *

parameters["allow_extrapolation"] = True

mesh = RectangleMesh(Point(-1.0, 0.0), Point(1.0, -1.0), 200, 200, "crossed")
V    = FunctionSpace(mesh,"CG", 1)
Vsub = FunctionSpace(mesh,"CG", 1)

f = project(Expression("x[1]*x[1]"), V)

# Create markers for submesh
class interior(SubDomain):
  def inside(self, x, on_boundary):
    return abs(x[0]) <= 0.5

markers = CellFunction("size_t", mesh)
markers.set_all(0)

Interior = interior()
Interior.mark(markers, 1)

# Extracting submesh
# submesh = RectangleMesh(Point(-0.5, 0.0), Point(0.5, -1.0), 100, 100, "crossed")
submesh = SubMesh(mesh, markers, 1)
Vsub = FunctionSpace(submesh,"CG", 1)

fsub = interpolate(f, Vsub)
plot(fsub, title="f on submesh")

ff = interpolate(fsub, V)
plot(ff, title="fsub extrapolated on mesh")
interactive()

The above code works well in serial but doesn't work in parallel for two reasons: (1) SubMesh only works in serial and (2) "extrapolate" a function using the previous approach produces wrong results (and an strange behaviour). At the moment the first reason can be avoided creating a new mesh instead of using the SubMesh functionality, so this not really matters (at the moment).

My question is: there exists a "parallel approach" to "extrapolate" a function in the way described above?

Thanks in advance.

closed with the note: The solution was found!
asked May 31, 2016 by hernan_mella FEniCS Expert (19,460 points)
closed Jun 21, 2016 by hernan_mella

1 Answer

0 votes

The solution to the strange behaviour described above seems to be related to the degree of the function spaces. If i adjust the degree parameter to a value greater than 1 all works as i expected.

answered Jun 21, 2016 by hernan_mella FEniCS Expert (19,460 points)
...