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

extension of function in a domain with hole to the whole domain

0 votes

I want to extend a function f defined in the cube with obstacle to a cube without obstacle

I have a mesh for the cube with obstacle and the function is f =TrialFunction(mesh1,V1)

I want to define an extension in the new mesh f_extension=TrialFunction(mesh2,V2).

Any help is appreciated.

asked Sep 6, 2013 by meftahi FEniCS Novice (300 points)

This is not a well-formulated question. What should your extension fulfill? There are uncountably many of such extensions.

TrialFunction is not a function per se. It is symbolic (next-to-last) argument of a rank$\ge2$ form.

I will extend the function f by zero in the obstacle. Not that f is equal to zero on the boundary of the obstacle.

1 Answer

+1 vote

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])
answered Sep 11, 2013 by Jan Blechta FEniCS Expert (51,420 points)
...