


{"id":284672,"date":"2023-05-18T12:13:24","date_gmt":"2023-05-18T12:13:24","guid":{"rendered":"\/forum\/forums\/topic\/get-the-temperature-difference-from-different-zones-using-udf\/"},"modified":"2023-09-10T16:13:08","modified_gmt":"2023-09-10T16:13:08","slug":"get-the-temperature-difference-from-different-zones-using-udf","status":"closed","type":"topic","link":"https:\/\/innovationspace.ansys.com\/forum\/forums\/topic\/get-the-temperature-difference-from-different-zones-using-udf\/","title":{"rendered":"get the temperature difference from different zones using UDF"},"content":{"rendered":"<p>Hello Dears,<\/p>\n<p>My problem is I am using a UDF code to collect temperature values at different cell zones (solid region and fluid region). I am saving temperature values in arrays (as shown in the code) by looping over them and using them later to get the temperature difference to use it in a formula for the fluid cell zone.<\/p>\n<p>in (c0_array[n]) and (c1_array[n]) the data was saved as I want in the first two loops<\/p>\n<div>\n<div class=\"smallfont\">Code:<\/div>\n<pre class=\"alt2\" dir=\"ltr\">(begin_c_loop(c01,ft1)<\/pre>\n<\/div>\n<p>and<\/p>\n<div>\n<div class=\"smallfont\">Code:<\/div>\n<pre class=\"alt2\" dir=\"ltr\">begin_c_loop(c02,ft2))<\/pre>\n<\/div>\n<p>, and they saved correctly, but when I loop them inside the third loop<\/p>\n<div>\n<div class=\"smallfont\">Code:<\/div>\n<pre class=\"alt2\" dir=\"ltr\">(begin_c_loop(c, t))<\/pre>\n<\/div>\n<p>to receive the data saved in the first two loops the values of (c0_array[n]) in the third loop are saved correctly as I want, but for (c1_array[n]) the data became chaotic and disorganized! so why do I get something like that?<\/p>\n<p>knowing both zones are coincided and have the same number of cells. and I have to use the define profile macro.<\/p>\n<div>\n<div class=\"smallfont\">Code:<\/div>\n<pre class=\"alt2\" dir=\"ltr\">#include \"udf.h\"\n#include \"mem.h\"\n\nDEFINE_PROFILE(Heat_Transfer_Coeff, t, position) \n\t{\n    Domain* domain = Get_Domain(1);\n    Thread* ft1 = Lookup_Thread(domain, 2);\n    Thread* ft2 = Lookup_Thread(domain, 4);\n    cell_t c, c01, c02;\n    Thread* t01, t02;\n    int n;\n    real c0_array[10000], c1_array[10000];\n\n    n = 0;\n    begin_c_loop(c01, ft1) \n\t{\n        C_UDMI(c01, ft1, 0) = C_T(c01, ft1);\n        c0_array[n] = C_T(c01, ft1);\n\t\tC_UDMI(c01, ft1, 1) = c0_array[n];\n        n++;\n    }\n    end_c_loop(c01, ft1)\n\n    n = 0;\n    begin_c_loop(c02, ft2) \n\t{\n        C_UDMI(c02, ft2, 2) = C_T(c02, ft2);\n        c1_array[n] = C_T(c02, ft2);\n\t\tC_UDMI(c02, ft2, 3) = c1_array[n];\n        n++;\n    }\n    end_c_loop(c02, ft2)\n\n    n = 0;\n    begin_c_loop(c, t)\n\t{\n        C_UDMI(c, t, 4) = c0_array[n]; \/\/ or C_UDMI(c,t,2)= c0_array[n] - c1_array[n]; \n        C_UDMI(c, t, 5) = c1_array[n];\n\n        C_PROFILE(c, t, position) = C_UDMI(c, t, 4)-C_UDMI(c, t, 5);\n        C_UDMI(c, t, 6) = C_PROFILE(c, t, position);\n        n++;\n    }\n    end_c_loop(c, t)\n}<\/pre>\n<\/div>\n<p>Your help is appreciated,<br \/>Thanks<\/p>\n","protected":false},"template":"","class_list":["post-284672","topic","type-topic","status-closed","hentry","topic-tag-array","topic-tag-cell-zone-conditions-1","topic-tag-coordinate","topic-tag-temperature","topic-tag-udf"],"aioseo_notices":[],"acf":[],"custom_fields":[{"0":{"_bbp_subscription":["285233","199"],"_bbp_author_ip":["23.47.145.29"]," _bbp_last_reply_id":["0"]," _bbp_likes_count":["0"],"_btv_view_count":["584"],"_edit_lock":["1684427659:218430"],"_bbp_status":["publish"],"_bbp_topic_status":["unanswered"],"_bbp_topic_id":["284672"],"_bbp_forum_id":["27792"],"_bbp_engagement":["199","285233"],"_bbp_voice_count":["2"],"_bbp_reply_count":["4"],"_bbp_last_reply_id":["284759"],"_bbp_last_active_id":["284759"],"_bbp_last_active_time":["2023-05-18 18:08:52"]},"test":"moh-qasim97gmail-com"}],"_links":{"self":[{"href":"https:\/\/innovationspace.ansys.com\/forum\/wp-json\/wp\/v2\/topics\/284672","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\/284672\/revisions"}],"wp:attachment":[{"href":"https:\/\/innovationspace.ansys.com\/forum\/wp-json\/wp\/v2\/media?parent=284672"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}