Process solution u (GridFunction) further with python

More
6 years 3 months ago #690 by creativeworker
Hello,

i compute a solution for a 3D Magnetostatic problem using ngsolve.
Code:
u = GridFunction(fes) ... u.vec.data = 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
More
6 years 3 months ago #691 by joachim
u.vec.FV().NumPy()

it's documented here:
ngsolve.org/docu/latest/how_to/howto_numpy.html

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

You could also use NGSolve's InnerProduct:

InnerProduct (u.vec, f.vec)

Joachim
The following user(s) said Thank You: creativeworker
Time to create page: 0.089 seconds