Forum Message

 

 

We have moved the forum to https://forum.ngsolve.org . This is an archived version of the topics until 05/05/23. All the topics were moved to the new forum and conversations can be continued there. This forum is just kept as legacy to not invalidate old links. If you want to continue a conversation just look for the topic in the new forum.

Notice

The forum is in read only mode.

Process solution u (GridFunction) further with python

More
5 years 7 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
5 years 7 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.131 seconds