How to Plot Field Lines


I’m comfortable with using the plot function to visualise the potential over a field, but how can I plot the field lines (perpendicular to the equipotentials, so that I can take a closer look at the flux paths)?

For context, I’m working on an electrical capacitance tomography problem and so seeing these paths of the electric flux will allow me to better understand the capacitance between each electrode in my system.

Thank you very much,

Can’t you just take the negative gradient of the function and plot the vector field?

So say you have solved for you scalar fespace u, then the following code should plot the field lines on top of u.

xomp = -dx(u);
ycomp = -dy(u);
zcomp = -dz(u);
plot(u,[xcomp,ycomp,zcomp],wait = true, fill = true);

If your problem is 2d not 3d then it would be the almost the same:

xomp = -dx(u);
ycomp = -dy(u);
plot(u,[xcomp,ycomp],wait = true, fill = true);

Sorry no simple way, in FreeFem++, but may be in Paraview it is possible but I don’t know.