Element Wise integral to a power p

I have an integral which I want to put to a certain power element wise. But I have the following error :

TypeError: unsupported operand type(s) for ** or pow(): ‘ngsolve.bla.VectorD’ and ‘float’

What I aim to do is :

 first = Integrate(5*test_function(u) ** exp, mesh, element_wise=True)**(1/exp -1)

Do you have any clue on how I can achieve this ?
Thank you for any help you can provide ! :slight_smile:

you can loop over vector entries, or you can take powers via numpy-arrays:

from ngsolve import *
mesh = Mesh(unit_square.GenerateMesh(maxh=0.2))

def test_function(x): return x*x
exp = 3

print ([val**exp for val in Integrate(5*test_function(x), mesh, element_wise=True)])

print (Integrate(5*test_function(x), mesh, element_wise=True).NumPy() ** exp)


1 Like

Thank you very much Joachim !!