I managed to implement a coefficient function that represents
[tex]
(xx, yy) \mapsto \int_\Omega f((xx,yy),(x,y)) d(x,y);
[/tex] the code is attached. Single threaded it works quite well, but I get odd NaNs at some points
(xx,yy) when computing
[tex]
\int_{[0,1]^2} \sqrt{ (xx - 0.5)^2 + (yy - 0.5)^2 } d(x,y)
[/tex]
with the TaskManager. The following python code should reproduce the error:
Code:
from ngsolve import *
from netgen.geom2d import unit_square
from intcoefffun import XArgumentMarker, YArgumentMarker, IntCoefficientFunction
mesh = Mesh(unit_square.GenerateMesh(maxh=0.1))
xx = XArgumentMarker()
yy = YArgumentMarker()
fun = lambda c1, c2: sqrt((c1-0.5)**2 + (c2-0.5)**2)
intcoeff = IntCoefficientFunction(mesh, fun(xx,yy))
with TaskManager():
print("int = ", Integrate(intcoeff, mesh))
My question is: Did I made some obvious mistake in my implementation?
So far, I have not been able to narrow down the problem more.
Edit:
I did some more debugging and found that changing
Code:
fun = lambda c1, c2: CoefficientFunction(c1-0.5),(c2-0.5)).Norm()
works well. Glad that I could work around this problem I went on just
to discover that I now get other race conditions with coefficient
functions as exp and acos. They show in integral values varying
in a large range. Any idea how this might be related?
All the best,
Philipp