Savevtk with multiple scalar node field and cell scalar field


I have two questions related to the savevtk function :

  • is there a way to save multiple (more than one) scalar node fields, in my case i need to save in the same vtu 10 scalar fields.
  • is there a way to save a scalar cell field ? For instance i want to save the average flux by cell.

Best regards.

Yes, for the both questions. Also, both of these can be done in a single line and saved in a single .vtu file.
See documentation Visualization for the essentials.

Something like this should work (in both 2D and 3D):

load "iovtk"
mesh Th = (...);
fespace Vh(Th,P1); Vh uh, vh;
fespace Qh(Th,P0); Qh qh;
int[int] vtuOrder=[1,1,0];
savevtk("data.vtu",Th,uh,vh,qh,dataname="u v q",order=vtuOrder);


1 Like