jorgensd / dolfinx-tutorial

A reimplementation of the Springer book: https://github.com/hplgit/fenics-tutorial/, covering new topics as well as transitioning from dolfin to dolfinx
https://jorgensd.github.io/dolfinx-tutorial/
114 stars 64 forks source link

Issue on page /chapter3/component_bc.html #205

Open tyagi-ankit opened 2 months ago

tyagi-ankit commented 2 months ago

It says:

Next, we locate the degrees of freedom on the top boundary. However, as the boundary condition is in a sub space of our solution, we need to supply both the parent space $V$ and the sub space $V_0$ to dolfinx.locate_dofs_topological.

But only the subspace is provided:

boundary_dofs_x = locate_dofs_topological(V.sub(0), mesh.topology.dim - 1, boundary_facets)

Please clarify. I have also seen examples on the discourse where both are specified. It's confusing.

Thanks.

jorgensd commented 2 months ago

In the case above, we are constraining a single constant value to an interface. Then we only supply a single space in the locate_dofs_topological function.

When we want to use a function to apply the boundary condition in a sub space, we create a function in the collapsed sub-space

V0, _ = V.sub(0).collapse()
u_bc = dolfinx.fem.Function(V0)
u_bc.interpolate(....)

For this use-case, one provides a tuple (V.sub(0), V0) to locate dofs topological, as we want the degrees of freedom in both V0 (to extract data from u_bc) and V.sub(0) (to apply the boundary condition to our system with the full function space V.

tyagi-ankit commented 2 months ago

Thanks Jørgen for a very quick reply. You are doing a great job. Your reply has clarified things for me.

Still, I think the mentioned chap-3 text still need updating, as it's not consistent with the code.

Also, the clarification you gave, isn't available either in the tutorials or particularly in the API docs. I find many things in FEniCSx to be magical, which the API docs don't clarify.

What you mentioned for locate_dofs_topological, is that true for locate_dofs_geometrical also?

One side question, is there an updated version of "FEniCS book" consistent with the FEniCSx?

Thanks a lot