MATLAB Answers


How can we save transient CFD results in a file during running the code?

Ahmed Saeed Mansour さんによって質問されました 2019 年 1 月 20 日
最新アクティビティ Ahmed Saeed Mansour さんによって コメントされました 2019 年 1 月 21 日
  • Hello, I have a CFD code solves a domain and generates transient resluts, I can plot the results vs time but howcan we save the time history of the results in a file during running the code?
  • Thank you!

  0 件のコメント

サインイン to comment.

1 件の回答

回答者: Precise Simulation 2019 年 1 月 21 日

It is hard to say what the best approch is without knowing anything about your code, but assuming you have access to the data why not just use the standard save command? Something like
filename = sprintf('cfd_data_at_time_%g.dat',t);
save( filename, cfd_data_at_time_step )
where t is the simulation time, and cfd_data_at_time_step a variable containing you data to save. This will save it in binary format, you can add the "-ascii" flag to save it as a text file.

  1 件のコメント

Hello, thank you so much, here is the main lines of the code:
n = n + 1;
T_n = T;
for j = 2:ny-1
for i = 2:nx-1
T(j,i) = T_n(j,i) + r_x*(T_n(j,i+1)-2*T_n(j,i)+T_n(j,i-1))...
+ r_y*(T_n(j+1,i)-2*T_n(j,i)+T_n(j-1,i));
It solves the heat transfer at each time step, the question is, where can we put the 2 save lines you thankfully worte above? in the loop or outside it? I get an error " Argument must contain a string." I am using GUI.
Thank you and tell me please if you need anything else...

サインイン to comment.

Translated by