Process solution u (GridFunction) further with python


i compute a solution for a 3D Magnetostatic problem using ngsolve.

u = GridFunction(fes)
... = solver * f.vec

I’d like to compute the energy stored in the field. Therefore i need the solutionvector (in a flat manner) and the assembled load vector (in the same order).

At the moment i’m stuck how to transform the ngsolve vectors into scipy/numpy vectors. I can’t find any documentation. The method NumPy() doesn’t seem to exist for the u and f vector.

With best regards


it’s documented here:

see also documentation->i-Tutorials for helpful documentation.

You could also use NGSolve’s InnerProduct:

InnerProduct (u.vec, f.vec)