Perform projection of f
to space V2
subject to zero BC on obstacle. Having defined f
with support of extrapolation
parameters['allow_extrapolation'] = True
f = Function(V1)
and zero BC on an obstacle
bc = DirichletBC(V2, 0.0, obstacle)
then project
should succeed doing
f_extension = project(f, V=V2, bcs=[bc])
If it does not work for some reason, you have an option of constructing custom projection. Assume obstacle
being instance of SubDomain
. Then you can do something like
cell_domains = CellFunction('size_t', mesh)
cell_domains.set_all(1)
obstacle.mark(cell_domains, 2)
dx = dx[cell_domains]
u, v = TrialFunction(V2), TestFunction(V2)
a = u*v*dx()
L = f*v*dx(1) # this should require evaluating f away from obstacle
bc = DirichletBC(V2, 0.0, obstacle) # this should regularize problem
f_extension = Function(V2)
solve(a == L, f_extension, [bc])