


{"id":326934,"date":"2023-12-07T18:23:25","date_gmt":"2023-12-07T18:23:25","guid":{"rendered":"\/forum\/forums\/topic\/writing-udf-data-to-a-file-in-parallel\/"},"modified":"2023-12-07T18:23:25","modified_gmt":"2023-12-07T18:23:25","slug":"writing-udf-data-to-a-file-in-parallel","status":"closed","type":"topic","link":"https:\/\/innovationspace.ansys.com\/forum\/forums\/topic\/writing-udf-data-to-a-file-in-parallel\/","title":{"rendered":"Writing UDF data to a file in parallel"},"content":{"rendered":"<p>Hello,&nbsp;<\/p>\n<p>I am writing a UDF as DEFINE_SOURCE that will perform some calculations within a singular cell zone. I want to write the result of those calculations in a text file. Currently, I can write the data using the following code. However, I run into issues where I get duplicates of many values. Additionally, some of those duplicates contain values that aren&#8217;t sensible. I have confirmed that these are duplicate values by having the UDF write the cell coordinates and unique cell ID numbers. Because the DEFINE_SOURCE macro loops over all of the cells in a cell zone I expect that the amount of data written is equal to the total number of cells. This is often not the case as I usually have more data than cells. I think my issue is that my current code is not parallelized for writing the data.<\/p>\n<p><img decoding=\"async\" src=\"\/forum\/wp-content\/uploads\/sites\/2\/2023\/12\/07-12-2023-1701972841-mceclip0.png\"><\/p>\n<p>I have found the Ansys documentation on how to write files in parallel here: https:\/\/www.afs.enea.it\/project\/neptunius\/docs\/fluent\/html\/udf\/node231.htm<\/p>\n<p>I have tried to implement it within the source term by removing the DEFINE_ON_DEMAND, but I either receive a segmentation fault error or the simulation will hang on the iteration that the data is supposed to be written on. Currently, I am only testing by writing each cell&#8217;s temperature instead of all of the data I require. I&#8217;ve included the new code below.<\/p>\n<p>I&#8217;m not sure what is causing the segmentation fault or the hanging behavior. Any help would be greatly appreciated.<\/p>\n<p>Thanks.<\/p>\n<p><img decoding=\"async\" src=\"\/forum\/wp-content\/uploads\/sites\/2\/2023\/12\/07-12-2023-1701973268-mceclip3.png\"><\/p>\n<p><img decoding=\"async\" src=\"\/forum\/wp-content\/uploads\/sites\/2\/2023\/12\/07-12-2023-1701973289-mceclip4.png\"><\/p>\n<p><img decoding=\"async\" src=\"\/forum\/wp-content\/uploads\/sites\/2\/2023\/12\/07-12-2023-1701973307-mceclip5.png\"><\/p>\n","protected":false},"template":"","class_list":["post-326934","topic","type-topic","status-closed","hentry","topic-tag-fluent-ansys-1","topic-tag-udf","topic-tag-udferror"],"aioseo_notices":[],"acf":[],"custom_fields":[{"0":{"_bbp_subscription":["49268","2887","341978"],"_bbp_author_ip":["23.206.193.41"]," _bbp_last_reply_id":["0"]," _bbp_likes_count":["0"],"_btv_view_count":["1181"],"_bbp_topic_status":["unanswered"],"_bbp_status":["publish"],"_bbp_topic_id":["326934"],"_bbp_forum_id":["27792"],"_bbp_engagement":["2887","49268"],"_bbp_voice_count":["2"],"_bbp_reply_count":["1"],"_bbp_reply_count_hidden":["1"],"_bbp_last_reply_id":["342777"],"_bbp_last_active_id":["342777"],"_bbp_last_active_time":["2024-01-02 16:47:09"]},"test":"brandon-hager-63nevada-unr-edu"}],"_links":{"self":[{"href":"https:\/\/innovationspace.ansys.com\/forum\/wp-json\/wp\/v2\/topics\/326934","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\/326934\/revisions"}],"wp:attachment":[{"href":"https:\/\/innovationspace.ansys.com\/forum\/wp-json\/wp\/v2\/media?parent=326934"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}