Hello everybody,
I would like to parallelize the evaluation of a coefficient function at many different MeshPoints using a NumPy array. Unfortunately, there seems to be a problem with pybind and NumPy, as NumPy doesn’t recognize MeshPoint objects. As a result, it creates generic objects that the call function does not recognize. Here is a minimal working example:
from ngsolve import *
import numpy as np
from netgen.geom2d import unit_square
mesh = Mesh(unit_square.GenerateMesh(maxh=0.2))
func = CF(x)
np_points = np.array([mesh(0.1,0.1), mesh(0.2,0.2)], dtype=fem.MeshPoint)
print(func(np_points))
According to the documentation, my expected result would be [0.1, 0.2], but instead, I receive the following error message:
TypeError: call(): incompatible function arguments. The following argument types are supported:
1. (self: ngsolve.fem.CoefficientFunction, mip: ngsolve.fem.BaseMappedIntegrationPoint) → object
2. (self: ngsolve.fem.CoefficientFunction, x: float, y: Optional[float] = None, z: Optional[float] = None) → ngcomp::PointEvaluationFunctional
3. (self: ngsolve.fem.CoefficientFunction, arg0: ngsolve.fem.CoordinateTrafo) → ngsolve.fem.CoefficientFunction
4. (self: ngsolve.fem.CoefficientFunction, arg0: ngsolve.fem.MeshPoint) → object
5. (self: ngsolve.fem.CoefficientFunction, arg0: numpy.ndarray[ngsolve.fem.MeshPoint]) → numpy.ndarray
Invoked with: <ngsolve.fem.CoefficientFunction object at 0x72a9dedd4050>, array([<ngsolve.fem.MeshPoint object at 0x72a9df5c7c30>,
<ngsolve.fem.MeshPoint object at 0x72a9df5c5770>], dtype=object)
Greetings,
Fabian