I am linking to a post that I made on the stack exchange concerning FEniCS. I received a comment that it would be more appropriate to post the question here.
I would suggest to use a lagrange multiplier for the case of non flat surface. You can have a look at my library multiphenics (https://gitlab.com/multiphenics/multiphenics, see tutorial 3) or at @cdaversin mixed-dimensional branch on the dolfin repo.
Fantastic! I will look closer intro the resources you provided and then respond to let you know if I was successful or not.
I find a way to solve this problem. You can just ignore the unnecessary components of a vector function. Here is a simple example.
# V is a vector function space, we want to apply boundary condition on the first component.
very_large = 100000000000
bc = DirichletBC(V, (1, very_large, very_large), mesh_function, 1)
bv_map = bc.get_boundary_values()
for i in bv_map:
if bv_map[i] < very_large:
u.vector()[i] = bv_map[i]
I am able to strongly enforce Dirichlet conditions on a component of a vector valued function, e.g., the first component
bc = DirichletBC(V.sub(0), Constant(1.0), mesh_function, 1)
but what I was looking for here was to be able to strongly enforce a Dirichlet condition on the normal component of a vector field, where the normal is not aligned with any of the coordinate axes. Do you think that your approach would be applicable for my purposes?
Using a Lagrange multiplier is a great idea but this is a bit complicated since the multiplier would only be defined on the boundary. Since this problem was posted I chose to weakly enforce, by a penalty method, the Dirichlet condition by adding a term to the weak form.
Thank you very much and it is what I was searching for. My approach is not able to apply Dirichlet boundary condition on normal direction.