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.

Plotting particular line in a mesh

More
3 years 4 months ago #3430 by bakerk
Hi

I was wondering if it is possible to plot a particular part of the mesh rather than the whole thing.

For example in the example for the Poisson equation in the iTutorials ( ngsolve.org/docu/latest/i-tutorials/wta/poisson.html ) how would I go about only plotting a line for the solution on y=0.5. I imagine id probably need to use matplotlib to do the plot but I'm not sure how to take the right data from gfu.vec.

Thanks
Katie
More
3 years 4 months ago #3431 by cwinters
Hi Katie,

you have to evaluate gfu at the desired points, this can be done by "gfu(mesh(x,y))".
As you suggested, it is probably the easiest to use matplotlib to plot the data.
Code:
import matplotlib.pyplot as plt N = 100 xpnts = [i/N for i in range(N+1)] vals = [gfu(mesh(xi,0.5)) for xi in xpnts] plt.plot(xpnts,vals) plt.show(block=False)

Best,
Christoph
The following user(s) said Thank You: bakerk, rgs
More
3 years 4 months ago #3432 by bakerk
Great, that works! Thanks
Time to create page: 0.143 seconds