Plotting particular line in a mesh

More
3 years 11 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 11 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 11 months ago #3432 by bakerk
Great, that works! Thanks
Time to create page: 0.108 seconds