-
-
August 1, 2019 at 1:05 pm
engineer72
SubscriberHello there
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 pm
Rob
Ansys EmployeeListing 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 pm
rachels1001
SubscriberIt'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 am
engineer72
Subscriberthank 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 am
Rob
Ansys EmployeeIf 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 am
engineer72
Subscriberi need the number calculated in udf, so i cant find it in reports.
-
August 4, 2019 at 8:43 am
SK95
Subscriberfp 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:
DEFINE_RW_FILE(writer, fp)
{
fprintf(fp, %d, kount);
}
-
August 4, 2019 at 8:53 am
SK95
SubscriberIf 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 am
DrAmine
Ansys EmployeeTalking 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 pm
SK95
SubscriberSorry I forgot to mention...you have to define the variable fp first, before using it.
FILE *fp;
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.

Ansys Blog
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
-
2524
-
2066
-
1285
-
1096
-
459
© 2023 Copyright ANSYS, Inc. All rights reserved.