# Ngsxfem Sampling Points Along Zero Level Set

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()

levelset = (sqrt(xx+yy) - 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”)

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

Hey Shahan,

I think it should be possible by using the interpolation points (provided by the integration function). The code would be something like:

``````IntPoints = []
Integrate(levelset_domain = { "levelset" : lsetp1, "domain_type" : IF}, cf=0, mesh = mesh, ip_container = IntPoints, order=1)

``````

Now, the list IntPoints contains all used integration points are located on the zero level. By increasing the order you can increase the number of returned points.

Best wishes,
Paul

Thank you Paul! That is exactly what I needed!