Hi all,

I am trying to model a PDE with a time dependent domain. It uses a level set method to track the boundary of the domain with the ngsxfem library. I would like to reinitialize the level set function by sampling points along the boundary of the domain and then compute an approximate signed distance function directly using these sampled points.

My question is: Is there a method which allows me to sample points along the zero level set of a function in ngsxfem?

Say, for instance in the toy problem below, how would one generate a sample of points along the zero level set, given some level set function?

#============================================================

from ngsolve import *

from ngsolve.webgui import Draw

from netgen.geom2d import SplineGeometry

from xfem import *

square = SplineGeometry()

square.AddRectangle([-1.5,-1.5],[1.5,1.5],bc=1)

mesh = Mesh(square.GenerateMesh(maxh=0.4, quad_dominated=False))

levelset = (sqrt(x*x+y*y) - 1.0)

DrawDC(levelset, -3.5, 2.5, mesh,“levelset”)

lsetp1 = GridFunction(H1(mesh,order=1))

InterpolateToP1(levelset,lsetp1)

DrawDC(lsetp1, -3.5, 2.5, mesh, “lsetp1”)

#============================================================