record a variable in UDF
hello
i have an unsteady problem with an UDF. how can i record a variable by time in a file, to get a list? at the moment i use fprintf but i get only the value of the last time step. thanks reto |
Re: record a variable in UDF
My suggestion:
1. Define a DEFINE_ON_DEMAND subroutine. In this subroutine you open an output file. Something like this,"ofp=fopen("out2.txt","w");" 2. Define a DEFINE_EXECUTE_AT_END subroutine. This subroutine will be executed at the end of each time step. In this subroutine your output the value of desired variables. e.g. "fprintf (ofp,"%e\n",variablename);" 3. Define another DEFINE_ON_DEMAND subroutine. In this subroutine you close the output file. "fclose(ofp);" 4. Please include, #include "stdio.h" #include "udf.h" and define, FILE *ofp; at the beginning of your source code file. 5. Before you start the iteration, run the first subroutine through "Define -> User-Defined -> Execute On Demand...". Then iterate. Once the iteration finished, run the third subroutine through "Define -> User-Defined -> Execute On Demand...". 6. Hope it works. Good luck! Zhang |
Re: record a variable in UDF
many thanks for your suggestion, it works!
reto |
All times are GMT -4. The time now is 12:27. |