Stokes and Navier-Stokes equations

Hello everyone!
I’m new to using fenics.
I see many tutorials and examples to solve incompressible navier stokes and stoke equations using H1 element (like this [https://fenicsproject.org/olddocs/dolfin/1.6.0/python/demo/documented/stokes-taylor-hood/python/ documentation.html])
I noticed that in 2021, there seems to be such a work, [https://fenics2021.com/slides/dean.pdf.] But the complete code and demo are not given.
Is there any example of using Hdiv element (BDM) or DG element?
Thank you so much.

@jpdean is the best one to ask about this.

See the Navier Stokes demo (which I believe @jpdean wrote) for an example of an inf sup stable formulation with an H(\mathrm{Div};\cdot) conforming velocity space.

1 Like

With rendered latex at Divergence conforming discontinuous Galerkin method for the Navier–Stokes equations — DOLFINx 0.7.0.0 documentation

Thanks for replying so fast, but I don’t quite understand this part of the code for Stoke problem.

# Boundary conditions
boundary_facets = mesh.locate_entities_boundary(msh, msh.topology.dim - 1, boundary_marker)
boundary_vel_dofs = fem.locate_dofs_topological(V, msh.topology.dim - 1, boundary_facets)
bc_u = fem.dirichletbc(u_D, boundary_vel_dofs)
bcs = [bc_u]

Isn’t the boundary condition u_D already weakly imposed?

L_0 = inner(f, v) * dx + (1 / Re) * (- inner(outer(u_D, n), grad(v)) * ds
                                     + (alpha / h) * inner(outer(u_D, n), outer(v, n)) * ds)

Why set bc_u = fem.dirichletbc(u_D, boundary_vel_dofs) again?

Good question. Referring to Cockburn et al. (2007) at the top of the demo’s documentation, the velocity space is constructed such that the velocity’s numerical flux is strongly imposed on the exterior boundary. If you don’t do this the elements adjacent to the boundary will not be diveregence free. The remaining tangential component is enforced weakly through the formulation. @jpdean please correct me if I’m wrong.

1 Like

Thanks! And now I understand why. This is the reason
As pointed out in Section 2, in order to obtain a divergence- free solution in the elements adjacent to the boundary, the Dirichlet boundary condition for the normal component must be implemented in a strong way, while the tangential components obtain their boundary values weakly through the form (2.11).

1 Like

Yes that’s right, you have to enforce the normal component in the function space and the tangential component weakly. That demo is for a divergence conforming discontinuous Galerkin method, whereas the slides you have referenced discuss a hybridized discontinuous Galerkin (HDG) method (as described in [2306.05288] Design and analysis of a hybridized discontinuous Galerkin method for incompressible flows on meshes with quadrilateral cells). The former can be implemented using main FEniCSx, the latter requires my branches which haven’t been merged yet. A demo of the HDG scheme can be found in GitHub - jpdean/mixed_domain_demos, though it needs some tidying up

1 Like