Dear all,
I am currently working on a code that computes the mean flow in a supersonic nozzle. To properly initialize each CFD run, I need to save and later read the simulation results. I chose to use ifstream
and ofstream
for this purpose. My problem is that I can write the solution to a file, but I can’t seem to read it back correctly.
To better isolate the problem, I created a simplified toy example (square geometry, no equation resolution, simple functions). Below is a minimal version of my code that reproduces the issue:
// Macro definition
macro defu(u) [u,u#y]//
// Mesh
mesh Th = square(50,50);
// FE space
fespace Xh(Th,[P2,P2]);
Xh defu(u) = [cos(0.5*pi*x),sin(0.5*pi*y)];
// Visualization
plot(Th,u,wait=1,fill=1);
plot(Th,uy,wait=1,fill=1);
// Saving
ofstream save("square.base");
save << u[] << endl;
// Reading
Xh defu(v);
ifstream read("square.base");
read >> v[];
It’s a fairly naive implementation, but I’m not sure what’s causing the problem. Any insights or suggestions would be greatly appreciated.
Best regards,
Ilyan