


{"id":294077,"date":"2023-07-20T10:27:08","date_gmt":"2023-07-20T10:27:08","guid":{"rendered":"\/forum\/forums\/topic\/issues-compiling-udf-in-ansys-fluent-udf-not-being-read-correctly\/"},"modified":"2023-07-20T10:30:18","modified_gmt":"2023-07-20T10:30:18","slug":"issues-compiling-udf-in-ansys-fluent-udf-not-being-read-correctly","status":"closed","type":"topic","link":"https:\/\/innovationspace.ansys.com\/forum\/forums\/topic\/issues-compiling-udf-in-ansys-fluent-udf-not-being-read-correctly\/","title":{"rendered":"Issues compiling UDF in ANSYS Fluent &#8211; UDF not being read correctly?"},"content":{"rendered":"<p>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 &#8216;cl&#8217; 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?<\/p>\n<p>Thank you<\/p>\n<div>Sample code from ANSYS User Guide:<\/div>\n<div>#include &#8220;udf.h&#8221;<\/div>\n<div>#define C2 100.0<\/div>\n<div>DEFINE_SOURCE(xmom_source, c, t, dS, eqn)<\/div>\n<div>{<\/div>\n<div>real x[ND_ND];<\/div>\n<div>real con, source;<\/div>\n<div>&nbsp;<\/div>\n<div>C_CENTROID(x, c, t);<\/div>\n<div>con = C2 * 0.5 * C_R(c, t) * x[1];<\/div>\n<div>&nbsp;<\/div>\n<div>source = -con * fabs(C_U(c, t)) * C_U(c, t);<\/div>\n<div>dS[eqn] = -2. * con * fabs(C_U(c, t));<\/div>\n<div>&nbsp;<\/div>\n<div>return source;<\/div>\n<div>}<\/div>\n<p>&nbsp;<\/p>\n<p>Errors within fluent :<\/p>\n<p>udf_names.c(6,8): warning: type specifier missing, defaults to &#8216;int&#8217; [-Wimplicit-int]<\/p>\n<p>extern DEFINE_SOURCE(xmom_source, c, t, dS, eqn);<\/p>\n<p>~~~~~~ ^<\/p>\n<p>udf_names.c(6,22): error: a parameter list without types is only allowed in a function definition<\/p>\n<p>extern DEFINE_SOURCE(xmom_source, c, t, dS, eqn);<\/p>\n<p>^<\/p>\n<p>udf_names.c(8,28): error: use of undeclared identifier &#8216;xmom_source&#8217;<\/p>\n<p>{&#8220;xmom_source&#8221;, (void(*)())xmom_source, UDF_TYPE_SOURCE},<\/p>\n<p>^<\/p>\n<p>udf_names.c(10,46): error: invalid application of &#8216;sizeof&#8217; to an incomplete type &#8216;UDF_Data []&#8217;<\/p>\n<p>__declspec(dllexport) int n_udf_data = sizeof(udf_data)\/sizeof(UDF_Data);<\/p>\n<p>^~~~~~~~~~<\/p>\n<p>11 warnings and 3 errors generated.<\/p>\n<p>scons: *** [udf_names.obj] Error 1<\/p>\n<p>scons: building terminated because of errors.<\/p>\n<p>&nbsp;<\/p>\n<p>Done.<\/p>\n","protected":false},"template":"","class_list":["post-294077","topic","type-topic","status-closed","hentry","topic-tag-2d-cfd-1","topic-tag-ansys-cfd-1","topic-tag-udf","topic-tag-udferror"],"aioseo_notices":[],"acf":[],"custom_fields":[{"0":{"_bbp_subscription":["289513","13659","157473"],"_bbp_author_ip":["23.217.200.71"]," _bbp_last_reply_id":["0"]," _bbp_likes_count":["0"],"_btv_view_count":["3270"],"_edit_lock":["1699274880:200352"],"_bbp_topic_status":["unanswered"],"_bbp_status":["publish"],"_bbp_topic_id":["294077"],"_bbp_forum_id":["27792"],"_bbp_engagement":["13659","157473","289513"],"_bbp_voice_count":["3"],"_bbp_reply_count":["9"],"_bbp_last_reply_id":["295758"],"_bbp_last_active_id":["295758"],"_bbp_last_active_time":["2023-07-31 19:48:40"]},"test":"rispence1sheffield-ac-uk"}],"_links":{"self":[{"href":"https:\/\/innovationspace.ansys.com\/forum\/wp-json\/wp\/v2\/topics\/294077","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/innovationspace.ansys.com\/forum\/wp-json\/wp\/v2\/topics"}],"about":[{"href":"https:\/\/innovationspace.ansys.com\/forum\/wp-json\/wp\/v2\/types\/topic"}],"version-history":[{"count":0,"href":"https:\/\/innovationspace.ansys.com\/forum\/wp-json\/wp\/v2\/topics\/294077\/revisions"}],"wp:attachment":[{"href":"https:\/\/innovationspace.ansys.com\/forum\/wp-json\/wp\/v2\/media?parent=294077"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}