Feeding one result into BC of another solver

I am solving two systems of PDEs. I want to use the solved function of one system as the boundary condition for the second system of PDEs. So for example, if I solve for f,g in the variational problem F1, I want to use grad(f) as a boundary condition for another variational problem F2. Is that possible?


Hi, i suggest either projecting or interpolating ‘grad(F)’ into a suitable function space, using the resultatnedgang function in the Dirichlet boundary condition

Hi, thanks for your reply! I have tried to do this, but I don’t know how to interpolate or project an existing dolfin function into a suitable function space. I have always interpolated expressions, and now when I try to interpolate a dolfin function, it always gives me an error, and I can’t find any solution online. Could you point me to the syntax to project/interpolate an existing dolfin function into a suitable function space?

Depending on the function space you would like for the boundary condition of the second function, do the following:

V = FunctionSpace(mesh, "CG", 1)
uh = Function(V)
# Solve pde to F(uh, v) = 0 forall v
S = VectorFunctionSpace(mesh, "DG", 0)
Du = project(grad(uh), S)

Du = project(grad(uh), S) is the same as:

Du = Function(S)
u, v = TrialFunction(S), TestFunction(S)
a = inner(u,v)*dx
L = inner(grad(uh), v)*dx
solve(a==L, Du)

Thank you! That worked beautifully!