Tangent gradient and jump terms in Integrate

Hello everyone,

I would like to use NGSolve to compute the integral on a 1D closed line in a 2D tri mesh .

In my integrand i have three kinds of terms:

  • a jump term from a L2(order=0) gridfunction defined on the 2D mesh
  • the norm of the tangential gradient of a P1(order=1) field
  • a term using the normal field of the surface enclosed in my 1D line I integrate on.

I have implemented a version based on the following functions but the current results are not satisfactory.

From what i gathered on the forum:

  • the jump term Inside/Outside can by computed using BoundaryFromVolumeCF(CoefficientFunction([myP0triGridFunction if mat==“Inside” else None for mat in mesh.GetMaterials()]) - BoundaryFromVolumeCF(CoefficientFunction([myP0triGridFunction if mat==“Outside” else None for mat in mesh.GetMaterials()])
    But I can’t seem to be able to visualize the result and confirm that this part is correct.

  • the tangential gradient can be computed using grad(myP1field).Trace()
    Still i cannot visualize it, and i’m not sure about how Integrate(myQuantity,mesh,definedon=mesh.Boundaries(“myLine”)) uses it

  • the normal field i get from BoundaryFromVolumeCF(CoefficientFunction ([specialcf.normal(2) if mat== “Inside” else None for mat in mesh.GetMaterials()]))

To sum it up, is there something wrong with the current implementation of each term (they are just combined in the integrate function) is there a way to properly visualize each term ?

Best,
Thomas