Boundary terms


I have a Laplacian in a nonlinear PDE, which I want to discretize. The weak form of the Laplace operator gives me

\int_{\Omega} \nabla u \nabla v dx - \int_{\Gamma} \nabla u \cdot n v ds

Therefore I defined the following BilinearForm in 1D (the first part of the Laplacian is clear :))

V = H1(ngsmesh, order=1)
w = V.TrialFunction()
phi = V.TestFunction()

n = specialcf.normal(1)

boundaryterm = BilinearForm(V)
boundaryterm += SymbolicBFI(grad(w) * n * phi, definedon=ngsmesh.Boundaries(“default”))

If I run the code I get the following warning

used dof inconsistency
(silence this warning by setting BilinearForm(…check_unused=False) )

and the respective matrix is equal to zero everywhere. However I would expect entries at the two endpoints of the 1D mesh.

I suppose it’s a stupid mistake - but at the moment I don’t see what I am doing wrong.

Thanks a lot


The function “ngsmesh.Boundaries(“default”)” gives you a boundary region. Therefore your integrator just integrates over your boundary (where you do not have any volume information) and there the gradient is not defined.
If you set proper boundary conditions, the term is replaced by a function for neumann boundaries and it vanishes for a dirichlet boundary.

If you use a DG method, such terms can make sense. But then you have to use “element_boundary=True” or “skeleleton=True”.
The following integrator integrates over ALL element boundaries (loop over the inner interfaces twices and boundary elements once).

boundaryterm += SymbolicBFI(grad(w) * n * phi, element_boundary=True)

The next one integrates over all boundary elements.

boundaryterm += SymbolicBFI(grad(w) * n * phi, BND, skeleton=True)

It is always easier to help if we know more details of the problem you want to solve.