Bilinear form on codimension 2,volumes and curves, mixed dimensions

Hello,

I’m trying to define a bilinear form on a curve of a three-dimensional domain.
Doing the analogous procedure for a surface is no-problem using the “ds”-operator.
Is there a way to do the same for a curve?

MRE:

from netgen.occ import *

cube = Box((-20,-2,0), (20,2,1))
cube.faces.Min(Z).name = “bottom”
cube.faces.Min(X).name = “left”
cube.faces[“bottom”].edges.Min(Y).name = “front”
netmesh = OCCGeometry(cube).GenerateMesh(maxh=1)

from ngsolve import *
mesh = Mesh(netmesh)

fes = H1(mesh, order=3, dirichlet=“left”)
u, du = fes.TnT()

a = BilinearForm(fes, symmetric=True, symmetric_storage=True, condense=True)
a += (du * u + InnerProduct(Grad(du), Grad(u))) * dx
a += (du * u + InnerProduct(Grad(du).Trace(), Grad(u).Trace())) * ds(“bottom”)

and on the curve I would like to do something like:

a += (du * u + InnerProduct(Grad(du).Trace(), Grad(u).Trace())) * ds(“front”)

but this doesn’t work, even though I don’t get an error message.

you can give a region to the dx operator instead of a string to also change codimension:

a += (du * u + InnerProduct(Grad(du).Trace().Trace(), Grad(u).Trace().Trace()) * dx(mesh.BBoundaries("front"))

BBoundaries = Boundaries of Boundaries = codim2

best
Christopher

Thanks for the reply!
However, I get an exception for this code:

NgException Traceback (most recent call last)
in
24 # ))
25
—> 26 a += (du * u + InnerProduct(Grad(du).Trace().Trace(), Grad(u).Trace().Trace())) * dx(mesh.BBoundaries(“front”))
27
28 f = LinearForm(fes)
NgException: don’t have a trace, primal evaluator = gradbnd

Removing one Trace()-operator leads to a different error:

NgException Traceback (most recent call last)
in
24 # ))
25
—> 26 a += (du * u + InnerProduct(Grad(du).Trace(), Grad(u).Trace())) * dx(mesh.BBoundaries(“front”))
27
28 f = LinearForm(fes)
NgException: Trialfunction does not support BBND-forms, maybe a Trace() operator is missing, type = gradbnd

I would be grateful for any other tips!

Best,
Adam

sorry

a += (du * u + InnerProduct(grad(du).Trace().Trace(), grad(u).Trace().Trace())) * ds(mesh.BBoundaries("front"))

the Grad != grad thing is a bit confusing here… Internally the “natural” derivative is grad and it has also a BBND trace. Grad is an additional operator that implemented grad in a row/col consistant way since there were legacy reason differences between spaces…

1 Like

Thanks a lot!, that works!