error when using Integrate

I’m trying to integrate a function over a subset of the domain, but I keep getting the following error

File "/usr/local/ngsxfem/lib/python3/dist-packages/xfem/", line 304, in Integrate_X_special_args heapsize=heapsize) netgen.libngpy._meshing.NgException: lsets need to be GridFunctions!

The function is called using

stopcritval = sqrt(Integrate(levelset_domain=lset_haspos, cf=f, mesh=mesh))

where f is a GridFunction, and lset_haspos is defined by:

lsetp1 = GridFunction(H1(mesh,order=1)) InterpolateToP1(lset,lsetp1) lset_haspos = { "levelset" : lsetp1, "domain_type" : HASPOS, "subdivlvl" : 0}

As far as I can tell, all arguments are of the right type, so I have no idea why I’m being told that “lsets need to be GridFunctions”. Does anyone know what I’m doing wrong?



Dear Julien,

HASPOS is not a DOMAIN_TYPE (but a COMBINED_DOMAIN_TYPE). This leads to the fact that the dictionary lset_haspos does not fit the interface. If you want to integrate on the part where the level set function is positive, simply use “domain_type”: POS.

I have to admit that the Exception is not really helpful and rather misleading. I will have a look at that.


Hi Christoph,

Switching to POS did the trick.

thanks for the fast reply,