August 1, 2019 at 1:05 pmengineer72Subscriber
i have problems in using fprintf in my compiled udf. i used it in a simple udf as below, but still not working:
August 1, 2019 at 1:26 pmRobAnsys Employee
Listing the problems will help, as will putting the source code in the post: staff are not permitted to open/download attachments.
August 1, 2019 at 5:19 pm
August 1, 2019 at 6:38 pmrachels1001Subscriber
It's hard to tell without the console errors, but as an initial guess, the DEFINE_RW_FILE command can't be used in UDFs that are executed on Windows systems, according to the Ansys documentation.
August 2, 2019 at 7:47 amengineer72Subscriber
thank U for answering. there is no error at all, the solution is done but no data is written.
so how can i export a variable's magnitudes into an external file? in simple above example, for compiled udf and using windows system?
August 2, 2019 at 11:06 amRobAnsys Employee
If you just need a number from a point/surface use the reports and write to a file: much easier too!
August 4, 2019 at 4:01 amengineer72Subscriber
i need the number calculated in udf, so i cant find it in reports.
August 4, 2019 at 8:43 amSK95Subscriber
fp in the function header is a pointer to a file which is already open, therefore using fopen can lead to undefined behaviour. Try to use this code:
fprintf(fp, %d, kount);
August 4, 2019 at 8:53 amSK95Subscriber
If you want to print to your own file you don't need the DEFINE_RW_FILE function. You can just write your 3 lines fopen, fprintf, fclose anywhere you want (e.g. in your DEFINE_ADJUST function). But keep in mind opening and closing a file each time, takes "a lot of time" and therefore your runtime will be longer.
August 4, 2019 at 5:31 pm
August 5, 2019 at 5:03 amDrAmineAnsys Employee
Talking about errors: share wuth us the error? I guess your forgot to define the File you want to open.
August 5, 2019 at 12:56 pmSK95Subscriber
Sorry I forgot to mention...you have to define the variable fp first, before using it.
fp = fopen...
- You must be logged in to reply to this topic.
Earth Rescue – An Ansys Online Series
The climate crisis is here. But so is the human ingenuity to fight it. Earth Rescue reveals what visionary companies are doing today to engineer radical new ideas in the fight against climate change. Click here to watch the first episode.
Subscribe to the Ansys Blog to get great new content about the power of simulation delivered right to your email on a weekly basis. With content from Ansys experts, partners and customers you will learn about product development advances, thought leadership and trends and tips to better use Ansys tools. Sign up here.
- Suppress Fluent to open with GUI while performing in journal file
- Floating point exception in Fluent
- What are the differences between CFX and Fluent?
- Heat transfer coefficient
- Getting graph and tabular data from result in workbench mechanical
- The solver failed with a non-zero exit code of : 2
- Difference between K-epsilon and K-omega Turbulence Model
- Time Step Size and Courant Number
- Mesh Interfaces in ANSYS FLUENT
- error in cfd post
© 2023 Copyright ANSYS, Inc. All rights reserved.