TAGGED: udf
-
-
September 10, 2025 at 5:13 am
ypglez96
SubscriberHi!, anyone can help me to identify the mistake in the following UDF please
#include "udf.h"Â#define N_SOURCES 39Âconst static real F[N_SOURCES] = {0.00396399,Â0.00397615,Â0.00395948,Â0.0039312, Â0.00382969,0.0036884, Â0.00387387,Â0.00385565,Â0.00397089,Â0.00386617,0.00384009,Â0.00389486,Â0.00372965,Â0.00365257,Â0.00386212,0.00398893,Â0.00388632,Â0.00388224,Â0.00390604,Â0.00375784,0.00364968,Â0.00399214,Â0.00396672,Â0.00379819,Â0.00365401,0.00394434,Â0.00398073,Â0.00394522,Â0.00373293,Â0.0036275,0.00383483,Â0.00366572,Â0.00358861,Â0.00371025,0.00358094,0.00354702,Â0.00352607,Â0.00347636,Â0.00346994};Âreal calculate_power(cell_t c, Thread *t, int index){real centroid[ND_ND];real y, Q;ÂC_CENTROID(centroid, c, t);y = centroid[1];ÂQ = (-7833.925 * pow(y, 4) + 31425.223 * pow(y, 3) - 79722.626 * pow(y, 2) + 96939.861 * y) * 1e6;Âreturn F[index] * Q;}ÂDEFINE_SOURCE(power1, c, t, dS, eqn) { return calculate_power(c, t, 0); }DEFINE_SOURCE(power2, c, t, dS, eqn) { return calculate_power(c, t, 1); }DEFINE_SOURCE(power3, c, t, dS, eqn) { return calculate_power(c, t, 2); }DEFINE_SOURCE(power4, c, t, dS, eqn) { return calculate_power(c, t, 3); }DEFINE_SOURCE(power5, c, t, dS, eqn) { return calculate_power(c, t, 4); }DEFINE_SOURCE(power6, c, t, dS, eqn) { return calculate_power(c, t, 5); }DEFINE_SOURCE(power7, c, t, dS, eqn) { return calculate_power(c, t, 6); }DEFINE_SOURCE(power8, c, t, dS, eqn) { return calculate_power(c, t, 7); }DEFINE_SOURCE(power9, c, t, dS, eqn) { return calculate_power(c, t, 8); }DEFINE_SOURCE(power10, c, t, dS, eqn) { return calculate_power(c, t, 9); }DEFINE_SOURCE(power11, c, t, dS, eqn) { return calculate_power(c, t, 10); }DEFINE_SOURCE(power12, c, t, dS, eqn) { return calculate_power(c, t, 11); }DEFINE_SOURCE(power13, c, t, dS, eqn) { return calculate_power(c, t, 12); }DEFINE_SOURCE(power14, c, t, dS, eqn) { return calculate_power(c, t, 13); }DEFINE_SOURCE(power15, c, t, dS, eqn) { return calculate_power(c, t, 14); }DEFINE_SOURCE(power16, c, t, dS, eqn) { return calculate_power(c, t, 15); }DEFINE_SOURCE(power17, c, t, dS, eqn) { return calculate_power(c, t, 16); }DEFINE_SOURCE(power18, c, t, dS, eqn) { return calculate_power(c, t, 17); }DEFINE_SOURCE(power19, c, t, dS, eqn) { return calculate_power(c, t, 18); }DEFINE_SOURCE(power20, c, t, dS, eqn) { return calculate_power(c, t, 19); }DEFINE_SOURCE(power21, c, t, dS, eqn) { return calculate_power(c, t, 20); }DEFINE_SOURCE(power22, c, t, dS, eqn) { return calculate_power(c, t, 21); }DEFINE_SOURCE(power23, c, t, dS, eqn) { return calculate_power(c, t, 22); }DEFINE_SOURCE(power24, c, t, dS, eqn) { return calculate_power(c, t, 23); }DEFINE_SOURCE(power25, c, t, dS, eqn) { return calculate_power(c, t, 24); }DEFINE_SOURCE(power26, c, t, dS, eqn) { return calculate_power(c, t, 25); }DEFINE_SOURCE(power27, c, t, dS, eqn) { return calculate_power(c, t, 26); }DEFINE_SOURCE(power28, c, t, dS, eqn) { return calculate_power(c, t, 27); }DEFINE_SOURCE(power29, c, t, dS, eqn) { return calculate_power(c, t, 28); }DEFINE_SOURCE(power30, c, t, dS, eqn) { return calculate_power(c, t, 29); }DEFINE_SOURCE(power31, c, t, dS, eqn) { return calculate_power(c, t, 30); }DEFINE_SOURCE(power32, c, t, dS, eqn) { return calculate_power(c, t, 31); }DEFINE_SOURCE(power33, c, t, dS, eqn) { return calculate_power(c, t, 32); }DEFINE_SOURCE(power34, c, t, dS, eqn) { return calculate_power(c, t, 33); }DEFINE_SOURCE(power35, c, t, dS, eqn) { return calculate_power(c, t, 34); }DEFINE_SOURCE(power36, c, t, dS, eqn) { return calculate_power(c, t, 35); }DEFINE_SOURCE(power37, c, t, dS, eqn) { return calculate_power(c, t, 36); }DEFINE_SOURCE(power38, c, t, dS, eqn) { return calculate_power(c, t, 37); }DEFINE_SOURCE(power39, c, t, dS, eqn) { return calculate_power(c, t, 38); }ÂÂI get this error when I try to compile it(chdir "power")(chdir "win64\3d_node")udf_names.c
udf_names.c(45): error C2059: error de sintaxis: ';'
udf_names.c(45): error C2059: error de sintaxis: '}'
udf_names.c(46): error C2059: error de sintaxis: ','
udf_names.c(46): error C2059: error de sintaxis: '}'
udf_names.c(47): error C2059: error de sintaxis: ','
udf_names.c(47): error C2059: error de sintaxis: '}'
udf_names.c(48): error C2059: error de sintaxis: ','
udf_names.c(48): error C2059: error de sintaxis: '}'
udf_names.c(49): error C2059: error de sintaxis: ','
udf_names.c(49): error C2059: error de sintaxis: '}'
udf_names.c(50): error C2059: error de sintaxis: ','
udf_names.c(50): error C2059: error de sintaxis: '}'
udf_names.c(51): error C2059: error de sintaxis: ','
udf_names.c(51): error C2059: error de sintaxis: '}'
udf_names.c(52): error C2059: error de sintaxis: ','
udf_names.c(52): error C2059: error de sintaxis: '}'
udf_names.c(53): error C2059: error de sintaxis: ','
udf_names.c(53): error C2059: error de sintaxis: '}'
udf_names.c(54): error C2059: error de sintaxis: ','
udf_names.c(54): error C2059: error de sintaxis: '}'
udf_names.c(55): error C2059: error de sintaxis: ','
udf_names.c(55): error C2059: error de sintaxis: '}'
udf_names.c(56): error C2059: error de sintaxis: ','
udf_names.c(56): error C2059: error de sintaxis: '}'
udf_names.c(57): error C2059: error de sintaxis: ','
udf_names.c(57): error C2059: error de sintaxis: '}'
udf_names.c(58): error C2059: error de sintaxis: ','
udf_names.c(58): error C2059: error de sintaxis: '}'
udf_names.c(59): error C2059: error de sintaxis: ','
udf_names.c(59): error C2059: error de sintaxis: '}'
udf_names.c(60): error C2059: error de sintaxis: ','
udf_names.c(60): error C2059: error de sintaxis: '}'
udf_names.c(61): error C2059: error de sintaxis: ','
udf_names.c(61): error C2059: error de sintaxis: '}'
udf_names.c(62): error C2059: error de sintaxis: ','
udf_names.c(62): error C2059: error de sintaxis: '}'
udf_names.c(63): error C2059: error de sintaxis: ','
udf_names.c(63): error C2059: error de sintaxis: '}'
udf_names.c(64): error C2059: error de sintaxis: ','
udf_names.c(64): error C2059: error de sintaxis: '}'
udf_names.c(65): error C2059: error de sintaxis: ','
udf_names.c(65): error C2059: error de sintaxis: '}'
udf_names.c(66): error C2059: error de sintaxis: ','
udf_names.c(66): error C2059: error de sintaxis: '}'
udf_names.c(67): error C2059: error de sintaxis: ','
udf_names.c(67): error C2059: error de sintaxis: '}'
udf_names.c(68): error C2059: error de sintaxis: ','
udf_names.c(68): error C2059: error de sintaxis: '}'
udf_names.c(69): error C2059: error de sintaxis: ','
udf_names.c(69): error C2059: error de sintaxis: '}'
udf_names.c(70): error C2059: error de sintaxis: ','
udf_names.c(70): error C2059: error de sintaxis: '}'
udf_names.c(71): error C2059: error de sintaxis: ','
udf_names.c(71): error C2059: error de sintaxis: '}'
udf_names.c(72): error C2059: error de sintaxis: ','
udf_names.c(72): error C2059: error de sintaxis: '}'
udf_names.c(73): error C2059: error de sintaxis: ','
udf_names.c(73): error C2059: error de sintaxis: '}'
udf_names.c(74): error C2059: error de sintaxis: ','
udf_names.c(74): error C2059: error de sintaxis: '}'
udf_names.c(75): error C2059: error de sintaxis: ','
udf_names.c(75): error C2059: error de sintaxis: '}'
udf_names.c(76): error C2059: error de sintaxis: ','
udf_names.c(76): error C2059: error de sintaxis: '}'
udf_names.c(77): error C2059: error de sintaxis: ','
udf_names.c(77): error C2059: error de sintaxis: '}'
udf_names.c(78): error C2059: error de sintaxis: ','
udf_names.c(78): error C2059: error de sintaxis: '}'
udf_names.c(79): error C2059: error de sintaxis: ','
udf_names.c(79): error C2059: error de sintaxis: '}'
udf_names.c(80): error C2059: error de sintaxis: ','
udf_names.c(80): error C2059: error de sintaxis: '}'
udf_names.c(81): error C2059: error de sintaxis: ','
udf_names.c(81): error C2059: error de sintaxis: '}'
udf_names.c(82): error C2059: error de sintaxis: ','
udf_names.c(82): error C2059: error de sintaxis: '}'
udf_names.c(83): error C2059: error de sintaxis: ','
udf_names.c(83): error C2059: error de sintaxis: '}'
udf_names.c(84): warning C4034: sizeof devuelve 0
-
September 10, 2025 at 7:51 am
Rob
Forum ModeratorHave a look at the DEFINE_SOURCE example in the manual. Staff don't debug code. Maybe try with just one source to figure out what's going on?
-
September 10, 2025 at 8:28 am
Mark O
Ansys EmployeeAs Rob says, look at the examples for DEFINE_SOURCE. The open close brackets are always on a newline. eg
Â
DEFINE_SOURCE(power1, c, t, dS, eqn)
{
return calculate_power(c, t, 0);
}
The visual studio compiler will fail with a syntax error if they are not. It works with the built-in clang compiler but you want your code to work with any of the supported compilers.
-
September 11, 2025 at 2:15 pm
jcooper
Ansys EmployeeHi:Â
I wonder if there could be a strange character in your code that is preventing the brackets from being recognized properly? I would suggest opening it in Notepad++ and checking that the encoding is UTF-8. Then, save the UDF.
I copied your UDF verbatim from this thread, saved it from Notepad with this encoding and was able to compile it with the the Fluent built-in compiler. I run with one of the hooked source terms and it produced heat.Â
Regards,
Judy
Â
Below is the output from my compile:
Copyright 1987-2025 ANSYS, Inc. All Rights Reserved.
Compiler and linker: Clang (builtin)
Â
scons: warning: No version of Visual Studio compiler found - C/C++ compilers most likely not set correctly
File "F:\FORUM\UDF\libudf\win64\3ddp_host\SConstruct", line 20, in
Compiler path: "C:\PROGRA~1\ANSYSI~1\v251\fluent"\ntbin\clang\bin\clang-cl
Linker path: "C:\PROGRA~1\ANSYSI~1\v251\fluent"\ntbin\clang\bin\lld-link
Â
scons: warning: No version of Visual Studio compiler found - C/C++ compilers most likely not set correctly
File "F:\FORUM\UDF\libudf\win64\3ddp_host\SConstruct", line 156, in
C sources: ['sorce.c']
Â
Copyright 1987-2025 ANSYS, Inc. All Rights Reserved.
Compiler and linker: Clang (builtin)
Â
scons: warning: No version of Visual Studio compiler found - C/C++ compilers most likely not set correctly
File "F:\FORUM\UDF\libudf\win64\3ddp_node\SConstruct", line 20, in
Compiler path: "C:\PROGRA~1\ANSYSI~1\v251\fluent"\ntbin\clang\bin\clang-cl
Linker path: "C:\PROGRA~1\ANSYSI~1\v251\fluent"\ntbin\clang\bin\lld-link
Â
scons: warning: No version of Visual Studio compiler found - C/C++ compilers most likely not set correctly
File "F:\FORUM\UDF\libudf\win64\3ddp_node\SConstruct", line 156, in
C sources: ['sorce.c']
Â
AAPgunEctX8QxJN: Opening library "F:\FORUM\UDF\libudf"...
Done.
Â
AAPgunEctX8QxJN: Opening library "F:\FORUM\UDF\libudf"...
power1
power2
power3
power4
power5
power6
power7
power8
power9
power10
power11
power12
power13
power14
power15
power16
power17
power18
power19
power20
power21
power22
power23
power24
power25
power26
power27
power28
power29
power30
power31
power32
power33
power34
power35
power36
power37
power38
power39
Done.
Â
Done.
-
- You must be logged in to reply to this topic.
- air flow in and out of computer case
- Varying Bond model parameters to mimic soil particle cohesion/stiction
- Eroded Mass due to Erosion of Soil Particles by Fluids
- Centrifugal Fan Analysis for Determination of Characteristic Curve
- Guidance needed for Conjugate Heat Transfer Analysis for a 3s3p Li-ion Battery
- I am doing a corona simulation. But particles are not spreading.
- Issue to compile a UDF in ANSYS Fluent
- JACOBI Convergence Issue in ANSYS AQWA
- affinity not set
- Resuming SAG Mill Simulation with New Particle Batch in Rocky
-
3862
-
1414
-
1220
-
1118
-
1015
© 2025 Copyright ANSYS, Inc. All rights reserved.