Re: [firedrake] Mixed system DirichletBC - mismatching function spaces
Yes, I would always try weak BCs first. On 6 September 2016 at 17:37, Ham, David A <david.ham@imperial.ac.uk> wrote:
At a random guess, I think it might work to apply that BC weakly (ie (u1-u2)*dx). However one would need to see the code.
On Tue, 6 Sep 2016 at 17:31, Mitchell, Lawrence < lawrence.mitchell@imperial.ac.uk> wrote:
Dear Anna,
On 06/09/16 17:19, Anna Kalogirou wrote:
Dear all,
I have the following sample code which gives a ValueError: Mismatching function spaces.
##
V = FunctionSpace(mesh, "CG", 1) W = V*V
w = Function(W) v1, v2 = TestFunctions(W) u1, u2 = split(w)
F1 = F(u1, u2) # function of u1 and u2
F2 = F(u2) # function of u2 only
bc = DirichletBC(W.sub(1), u1, 'top’) # BC for F2
u_problem = NonlinearVariationalProblem(F1 + F2, w, bcs=[bc])
##
Note that the second equation depends on u1 through the DirichletBC only. Is the error generated due to the fact that u1 comes from W.sub(0) and it is given as a BC on W.sub(0)?
There are two problems here.
1. u1 is indexed with component 0, but you're trying to apply it to component 1 (which is why you get the proximate error).
2. This is the bigger problem.
The way you've formulated the problem, even if you removed the error from (1), which would be possible I think, doesn't do what you think it does. We don't support problems where the solution is coupled to itself through the boundary condition. So what would happen is you would end up minimising the residual for F2 subject to the value of u1 on the boundary, *when you started the solve* (i.e. whatever initial guess you had for u1).
I think it might be possible to vary how firedrake works to do what you want, but one would have to work out what's going on on paper first. http://firedrakeproject.org/boundary_conditions.html describes the maths (and the implementation strategy) for applying boundary conditions. Can you see how to modify it so that it still works if the boundary condition value depends on the state variable?
Lawrence
-- http://www.imperial.ac.uk/people/colin.cotter www.cambridge.org/9781107663916
participants (1)
- 
                
                Colin Cotter