TAGGED: udf
-
-
November 17, 2025 at 5:55 pm
muhammaddanishmasood
SubscriberI am having trouble loading a UDF that writes data after defined timestep. The UDF compiles without any errors, but Fluent refuses to load it whenever the code attempts to save data. The strange part is that this happens even when using a single processor in the Fluent Launcher. I am using ANSYS 2025 R2 Student version.
If I remove the file-writing part, the UDF loads and runs normally.
Here is the UDF:
#include "udf.h"#include#define WRITE_FREQUENCY 10DEFINE_EXECUTE_AT_END(write_flow_data)int current_ts = N_TIME; if (current_ts % WRITE_FREQUENCY == 0 && current_ts > 0)#if RP_HOST char filename[256];sprintf(filename, "flowfield_ts_%d.dat", current_ts);Message("[UDF] Writing data file: %s\n", filename);Write_Data(filename);Message("[UDF] Done writing file.\n"); #endifI also tried the alternative version:
#if RP_HOST RP_Write_Data(filename); #endifBoth versions compile correctly, but when I try to load the library Fluent reports:
ERROR: The UDF library you are trying to load (libudf\win64\2ddp_node\libudf.dll) is not compiled for parallel useThis is confusing because:
I launch Fluent in Serial mode
The UDF only fails when data-writing functions are present
Without the Write_Data/RP_Write_Data call, the same UDF loads fine
-
November 18, 2025 at 11:16 am
Rob
Forum ModeratorI assume it's actually compiled, loaded and hooked into Fluent without any errors? Are there any warnings? Is time really an integer?
-
November 18, 2025 at 11:22 am
muhammaddanishmasood
SubscriberRight now, I am only checking for integral values. There are no problem while building it. But on loading, I get the error:
Copyright 1987-2025 ANSYS, Inc. All Rights Reserved. Compiler and linker: Microsoft Visual C++# Generating ud_io1.h UDF_timestep.c
# Generating udf_names.c because of makefile UDF_timestep.obj udf_names.c
# Linking libudf.dll because of makefile user_nt.udf udf_names.obj UDF_timestep.obj Creating library libudf.lib and object libudf.exp
Done.
DESKTOP-G8ISVJC:
Opening library “C:\Fluent_UDF_Test\libudf”… ERROR: The UDF library you are trying to load (libudf) is not compiled for parallel use on the current platform (win64). The system cannot find the file specified. C:\\Fluent_UDF_Test\\libudf\\win64\\2ddp_host\\libudf.dll Done.
-
-
November 18, 2025 at 11:29 am
Rob
Forum ModeratorSo it's not built. Try compiling with the built in CLANG compiler and see what comes up.
-
November 18, 2025 at 11:50 am
muhammaddanishmasood
SubscriberI get this error while using the built i compiler.
Compiler path: "C:\PROGRA~1\ANSYSI~1\ANSYSS~1\v252\fluent"\ntbin\clang\bin\clang-cl
Linker path: "C:\PROGRA~1\ANSYSI~1\ANSYSS~1\v252\fluent"\ntbin\clang\bin\lld-link
C sources: ['MYUDF3.c']
lld-link: error: undefined symbol: Write_Data
>>> referenced by MYUDF3.obj:(write_flow_data)
scons: *** [libudf.dll] Error 1
Creating user_nt.udf file for 2ddp_node ...
But I can build it using Visual code compiler:Compiler and linker: Microsoft Visual C++
# Generating ud_io1.h
MYUDF3.c
# Generating udf_names.c because of makefile MYUDF3.obj
udf_names.c
# Linking libudf.dll because of makefile user_nt.udf udf_names.obj MYUDF3.obj
Creating library libudf.lib and object libudf.exp
Done.
-
November 18, 2025 at 12:05 pm
Rob
Forum ModeratorSo the built in compiler has a problem. Are you compiling the VS version in Fluent or outside Fluent? Note, a .c file can compile as it's gramatically correct but still fail to build for Fluent if it's not appropriate.
-
November 18, 2025 at 12:06 pm
muhammaddanishmasood
SubscriberI am running inside fluent.
-
November 18, 2025 at 1:53 pm
Rob
Forum ModeratorHave you read https://ansyshelp.ansys.com/public/account/Secured?returnurl=/Views/Secured/corp/v252/en/flu_udf/flu_udf_sec_parallel_printing_reading.html%23flu_udf_sec_parallel_reading ?
-
- You must be logged in to reply to this topic.
-
4372
-
1494
-
1375
-
1203
-
1021
© 2025 Copyright ANSYS, Inc. All rights reserved.