How to interpolate 3D simulation results onto a cartesian grid in Matlab?

I think I can use convert_pde_data_3d so no problem now.

=============================================================================

Hi everyone. I am a beginner of Freefem. Now I am computing on a cubic domain and want to plot the solution in Matlab with “ffmatlib”. I am using periodic boundary condition and a periodic fespace.

I wish could interpolate the solution but cannot find a proper function to do this. I also tried to write a script on my own but failed, since I have difficulties understanding the fespace data “Vh” and solution data “u” from “ffsavedata” together with the mesh data.

May I ask if there is such an interpolation function in 3D? Otherwise where can I find information about “ffsavedata”?

Many thanks!

The interpolation appears to be automatic when accessing with parenthesis. I had a problem
with using old solution on a new mesh so I wrote a resampler which appears
to work. It samples the old solution on dof’s for the new mesh. You can see
that calling A(xp,yp) appears to return “A” at that location. This uses
kind of a kluge to get x and y suggested by someone else here.
There may be a better way to do that however.

``````macro RESAMPLE( B,Th2,A,Th,E) {
fespace Ah(Th,E); fespace Bh(Th2,E);
Bh xx=x; Bh yy=y;
for(int i=0; i<xx.n; ++i) {real xp=xx[][i]; real yp=yy[][i];
B[][i]=A(xp,yp); }
} // EOM

``````
1 Like