-
-
July 20, 2023 at 10:27 amRosa SpenceSubscriber
I am attempting to use user defined functions to define the Launder Sharma low reynolds number turbulence model. The source code has been written and published in a paper from 2013, I have made no adaptations to the code provided, however I am getting a host of errors related to unknown type names and undeclared identifiers. Before all the errors is a warning that the MSVC compiler 'cl' could not be found and may need to be installed separately with visual studio. I then attempted to trouble shoot the problem by trying the sample UDF code from the ansys user guide (included below), as a control guide. However I am still getting the compiler warning and 3 errors. Any suggestions on what could be causing the issue, is it a compiler issue as I think?
Thank you
Sample code from ANSYS User Guide:#include "udf.h"#define C2 100.0DEFINE_SOURCE(xmom_source, c, t, dS, eqn){real x[ND_ND];real con, source;C_CENTROID(x, c, t);con = C2 * 0.5 * C_R(c, t) * x[1];source = -con * fabs(C_U(c, t)) * C_U(c, t);dS[eqn] = -2. * con * fabs(C_U(c, t));return source;}Errors within fluent :
udf_names.c(6,8): warning: type specifier missing, defaults to 'int' [-Wimplicit-int]
extern DEFINE_SOURCE(xmom_source, c, t, dS, eqn);
~~~~~~ ^
udf_names.c(6,22): error: a parameter list without types is only allowed in a function definition
extern DEFINE_SOURCE(xmom_source, c, t, dS, eqn);
^
udf_names.c(8,28): error: use of undeclared identifier 'xmom_source'
{"xmom_source", (void(*)())xmom_source, UDF_TYPE_SOURCE},
^
udf_names.c(10,46): error: invalid application of 'sizeof' to an incomplete type 'UDF_Data []'
__declspec(dllexport) int n_udf_data = sizeof(udf_data)/sizeof(UDF_Data);
^~~~~~~~~~
11 warnings and 3 errors generated.
scons: *** [udf_names.obj] Error 1
scons: building terminated because of errors.
Done.
-
July 24, 2023 at 1:16 pmFedericoAnsys Employee
Are you using Fluent's built-in compiler or is your UDF compiled prior to reading it in Fluent?
-
July 24, 2023 at 1:17 pmRosa SpenceSubscriber
I am using Fluents build in compiler
-
July 24, 2023 at 1:54 pmFedericoAnsys Employee
If you get a compiler error/warning, then you should troubleshoot this issue before the subsequent errors/warnings. Your UDF code looks fine to me, but for some reason, it appears that the script is not compiled correctly.
Are you following these steps here to Build and Load the UDF? 5.2. Compiling a UDF Using the GUI (ansys.com)
Do you get any errors when loading the UDF?
-
-
-
July 24, 2023 at 2:30 pmRosa SpenceSubscriber
I am following the steps outlined in the user guide, I believe the source file is in the same folder that holds the case and data files (the cas.h5 and dat.h5 files?). I cannot load the UDF as it is not successfully built, in the previous step.
-
July 24, 2023 at 2:32 pmFedericoAnsys Employee
Can you copy and paste the entire error "MSVC compiler 'cl' could not be found" here?
-
July 24, 2023 at 2:39 pmRosa SpenceSubscriber
Below is the section of the console output with the compiler warnings:
scons: Reading SConscript files ...
scons: warning: Could not find MSVC compiler 'cl', it may need to be installed separately with Visual Studio
File "U:\Dissertation\Mesh convergenced 0AOA_files\dp0\FFF-21\Fluent\libudf\win64\2ddp_host\SConstruct", line 8, in
scons: warning: Could not find MSVC compiler 'cl', it may need to be installed separately with Visual Studio
File "U:\Dissertation\Mesh convergenced 0AOA_files\dp0\FFF-21\Fluent\libudf\win64\2ddp_host\SConstruct", line 18, in
Compiler used is "C:\PROGRA~1\ANSYSI~1\v212\fluent"\ntbin\clang\bin\clang-cl
Linker used is "C:\PROGRA~1\ANSYSI~1\v212\fluent"\ntbin\clang\bin\lld-link
scons: warning: Could not find MSVC compiler 'cl', it may need to be installed separately with Visual Studio
-
-
-
July 24, 2023 at 2:57 pmFedericoAnsys Employee
I just tested the UDF on my end, and it runs fine. Make sure your script .c is located in the working directory.
If the above is correct, I would argue this is probably an installation issue.
-
July 24, 2023 at 3:09 pmRosa SpenceSubscriber
Thank you for your help, I appreciate it. I also think its an installation issue.
-
-
July 31, 2023 at 7:48 pmMangeshANSYSAnsys Employee
Hello
Please avoid any spaces in path where case and data files and UDF files are stored. That should resolve the issue
i.e. DO NOT USE something like this which has spaces and special characters
U:\Projects and Activities\Fan & motor\my CFD Project\fan
instead use a PATH with only letters, numbers and underscores
U:\Projects_and_Activities\Fan_n_motor\my_CFD_Project\fan
-
- The topic ‘Issues compiling UDF in ANSYS Fluent – UDF not being read correctly?’ is closed to new replies.
- Non-Intersected faces found for matching interface periodic-walls
- Unburnt Hydrocarbons contour in ANSYS FORTE for sector mesh
- Fluent fails with Intel MPI protocol on 2 nodes
- Help: About the expression of turbulent viscosity in Realizable k-e model
- Cyclone (Stairmand) simulation using RSM
- error udf
- Mass Conservation Issue in Methane Pyrolysis Shock Tube Simulation
- Script Error
- Facing trouble regarding setting up boundary conditions for SOEC Modeling
- UDF, Fluent: Access count of iterations for “Steady Statistics”
-
1416
-
599
-
591
-
565
-
366
© 2025 Copyright ANSYS, Inc. All rights reserved.