Hello everyone,
I am currently working on solving a Poisson problem using FEniCSx, and I am encountering issues with correctly imposing Dirichlet boundary conditions. Despite following several tutorials, I find that the Dirichlet conditions are being applied to nodes that do not correspond to the boundaries of the hole or the plate in my mesh.
Here is a brief overview of my setup:
- I generate a mesh using GMSH, which includes a square plate with a circular hole in the center.
- I then read the mesh using Meshio and attempt to apply Dirichlet boundary conditions using FEniCSx.
Specifically, I need to impose a Dirichlet condition of u = 5
on the outer boundary of the plate and u = -1
on the boundary of the hole. However, these conditions are not being correctly applied to the intended nodes.
I suspect that there might be an issue with how I am reading the mesh or locating the degrees of freedom for the boundary conditions. I can provide the .msh file or the code used to generate the mesh if needed.
Here are the relevant parts of my code:
domain, cell_markers, facet_markers = gmshio.model_to_mesh(gmsh.model, mesh_comm, gmsh_model_rank, gdim=2)
…
Define Dirichlet boundary conditions
u_bc_outer = fem.Function(V)
u_bc_outer.interpolate(lambda x: np.full_like(x[0], 5))
u_bc_hole = fem.Function(V)
u_bc_hole.interpolate(lambda x: np.full_like(x[0], -1))
Apply Dirichlet conditions on the outer boundary
outer_boundary_dofs = fem.locate_dofs_geometrical(V, lambda x: np.isin(facet_markers.values, [3]))
bc_outer = fem.dirichletbc(u_bc_outer, outer_boundary_dofs)
Apply Dirichlet conditions on the hole boundary
hole_boundary_dofs = fem.locate_dofs_geometrical(V, lambda x: np.isin(facet_markers.values, [2]))
bc_hole = fem.dirichletbc(u_bc_hole, hole_boundary_dofs)
I would greatly appreciate any insights or suggestions on how to correctly impose these boundary conditions. If needed, I can attach the .msh file or provide more details about my mesh generation process.
Thank you very much for your assistance!
Best regards,
Diego.