how to write case and data with DEFINE_EXECUTE_AT_END
For example:
DEFINE_EXECUTE_AT_END(timetosave) { real t = CURRENT_TIME; if (t==10) ????save the case and data file for future postprocessing???? } What is the command for "????save the case and data file for future postprocessing????":D Thanks, Regards, François |
same as the C language. Use fopen, fprintf, fclose
Quote:
|
Hi Ji,
I'm familiar with fopen, fprintf and fclose in Matlab, and I understand your answer, but this is not what I'm looking for. I have dozens of variables to save in multiple 3D domains, there must be an elegant way to simply write ALL the data just as we do in the GUI via File\Write\Data... So, again, what would be the UDF command for "File\Write\Data..." and modify filename each time? François |
Sorry for my error. If you want to save case and data at each iteration, you can "File->Write->Autosave" menu to save case and data and set the auto save frequency as "1".
Quote:
|
Ji,
I know about the autosave option. I have good reasons for wanting to save at specific 'flow times' only : my timestep changes with time and I only want to save at every 24h of 'flow time'. An example: Let's say my timestep is 10 s during the first 5 h of flow time, and then my timestep is 5 min for the next 3 days of flow time, what will autosave at every 10 simulations do? It will save at every 100 s of flow time for the first 5 hours, and then it will save at every 50 min for the rest of simulation... Not what I want. I want to tell Fluent : at every 24 hours of flow time (for example), save all data, REGARDLESS OF TIME STEP. I can't believe it's not possible to do that elegantly (without the use of endless fprintf commands throughout all my domains...), there must be a way! |
1 Attachment(s)
Ok, I got your point. Then you can use the following code in UDF.
char* file_name="example-100s.cas"; char scheme_command[1000]; if(CURRENT_TIME==100) { sprintf(scheme_command,"(write-case-data \"%s\")", file_name); CX_Interpret_String(scheme_command); } But as I know, it only works in serial version. If you want to realize the function in parallel version, I think you should program with scheme language. Here is an example of writing case and data at 100s. (if (= 100 (rpgetvar 'flow-time)) (write-case-data "example-100s.cas") (display "not 100s, do nothing\n")) Copy the above source into the command input box from "solve->Execute Commands..." menu Attachment 16308 Then, Fluent will auto save your case and data at 100s and do nothing at other time. Quote:
|
Now you are talking! The 2nd option that you propose is fine with me since I want to save at a couple of flow times only => I will define a couple of 'Execute commands'.
Thanks a lot Ji. |
save case and data by udf
hello dear
I want to save my case and data in some time step not every time step the method that u told by scheme programming save case and data every time step? how can save my case and data by udf when I want? |
Quote:
hello dear I want to save my case and data in some time step not every time step the method that u told by scheme programming save case and data every time step? how can save my case and data by udf when I want? |
a problem
Quote:
your method for serial version is not work for me and I receive an error: Error: eval: unbound variable Error Object: write-case-data can you help me? what can i do? |
All times are GMT -4. The time now is 07:24. |