Custom normal in weak form

Hello,

I am currently doing unfitted methods. In order to guarantee stability for higher order finite elements, the following normal gradient stabilization is proposed

s(w, v) = c h (nh · ∇w, nh · ∇v)Th ,

to be added to the standard weak form, where \mathcal{T}_h and where the normal is the one to the surface of the level set. is the set of all cells cut by the geometry. I am currently not able to implement this, in the sense that it is not clear to me how to pass a custom normal to a weak form in FEniCSx. Of course, simply doing something like

dx_uncut = ufl.dx(subdomain_data=celltags, domain=mesh)
higher_order_stab = beta * h * inner(dot(n, grad(u)), dot(n, grad(v))) * dx_uncut(cut_cell_tag)

gives an error.

You would have to define the custom normal as a function in some function space.

As the integral is over a cell, it boils down to evaluating a function at some given points in the cell (quadrature points). How are you planning to Express the normal as a function of the level set function?

Hello @dokken,

Yes I will compute the normal with the gradient of the level set. So you would say I have to define the normal as a dolfinx.fem.Function and then use this function in the weak form?

If you can simply define it as the gradient of the level set, you can use grad(phi) directly in the variational form.