


{"id":275780,"date":"2023-03-21T22:34:33","date_gmt":"2023-03-21T22:34:33","guid":{"rendered":"\/forum\/forums\/topic\/fluent-udf-passing-information-to-a-face-loop-within-a-cell-loop\/"},"modified":"2023-03-21T23:06:03","modified_gmt":"2023-03-21T23:06:03","slug":"fluent-udf-passing-information-to-a-face-loop-within-a-cell-loop","status":"closed","type":"topic","link":"https:\/\/innovationspace.ansys.com\/forum\/forums\/topic\/fluent-udf-passing-information-to-a-face-loop-within-a-cell-loop\/","title":{"rendered":"Fluent UDF: Passing information to a face loop within a cell loop"},"content":{"rendered":"<p>I have a relatively simple UDF that does the following:<br \/>1. Loops over all the cell threads.<br \/>&nbsp; &nbsp;2. Loops over all cells of each cell thread.<br \/>&nbsp; &nbsp; &nbsp;3. Calculates centroid of each cell.<br \/>&nbsp; &nbsp; &nbsp;4. Loops over all face threads.<br \/>&nbsp; &nbsp; &nbsp; &nbsp; 5. Loops over all faces of each face thread.<br \/>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;6. Calculate centroid of each face.<br \/>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;7. Assign a UDM value to the cell if a condition between the cell and face centroids is met.<\/p>\n<p>The UDF looks something like below, where I have used an example condition which compares the z-coordinate difference between the cell and face centroids. There would be other conditions which stop the loop and move on to the next cell if the UDM value of that cell is 1, but I&#8217;ve omitted these lines for clarity.&nbsp;<\/p>\n<pre class=\"alt2\" dir=\"ltr\">#if !RP_HOST\n\nDomain *domain;\nThread *tc, *tf;\nface_t f;\ncell_t c;\n\ndomain = Get_Domain(ROOT_DOMAIN_ID);\n\nreal xc[ND_ND];\nreal xf[ND_ND];\n\n<strong>thread_loop_c(tc,domain)<\/strong>\n{\n    <strong>begin_c_loop(c,tc)<\/strong>\n    {\n        C_CENTROID(xc,c,tc);\n\t<strong>thread_loop_f(tf,domain)<\/strong>\n        {\n\t    <strong>begin_f_loop(f,tf)<\/strong>\n\t    {\n                F_CENTROID(xf,f,tf);\n                if (fabs(xc[2] - xf[2]) &lt; 0.1)\n                    C_UDMI(c,tc,0) = 1;\n            }\n            <strong>end_f_loop(f,tf)<\/strong>\n        }\n    }\n    <strong>end_c_loop(c,tc)<\/strong>\n}\n\n#endif<strong><br><\/strong><\/pre>\n<p>The code works in serial, but I could not get it to work in parallel. The issue is that the face loop may be done on a different compute node to the node of the cell loop, so that the face loop compute node does not have information calculated in the outside cell loop.<\/p>\n<p><span><strong>How can I pass the cell centroid information from the cell loop into the face loop (and each face thread loop) so that the above code works in parallel?<\/strong><\/span><\/p>\n<p>I&#8217;ve considered intializing and creating a 3D array which contains the centroid of all the faces of each face thread, and then looping over the cells, but this does not seem very efficient as most of the array would need to be filled with null values since the number of faces on each thread would be different. I&#8217;ve also considered using a pointer, but I don&#8217;t know how to feed information about the pointer into the face thread loop.<\/p>\n","protected":false},"template":"","class_list":["post-275780","topic","type-topic","status-closed","hentry","topic-tag-udf"],"aioseo_notices":[],"aioseo_head":"\n\t\t<!-- All in One SEO 4.9.10 - aioseo.com -->\n\t<meta name=\"description\" content=\"I have a relatively simple UDF that does the following:1. Loops over all the cell threads. 2. Loops over all cells of each cell thread. 3. Calculates centroid of each cell. 4. Loops over all face threads. 5. Loops over all faces of each face thread.\" \/>\n\t<meta name=\"robots\" content=\"max-image-preview:large\" \/>\n\t<link rel=\"canonical\" href=\"https:\/\/innovationspace.ansys.com\/forum\/forums\/topic\/fluent-udf-passing-information-to-a-face-loop-within-a-cell-loop\/\" \/>\n\t<meta name=\"generator\" content=\"All in One SEO (AIOSEO) 4.9.10\" \/>\n\t\t<meta property=\"og:locale\" content=\"en_US\" \/>\n\t\t<meta property=\"og:site_name\" content=\"Ansys Learning Forum | Ansys Innovation Space\" \/>\n\t\t<meta property=\"og:type\" content=\"article\" \/>\n\t\t<meta property=\"og:title\" content=\"Fluent UDF: Passing information to a face loop within a cell loop | Ansys Learning Forum\" \/>\n\t\t<meta property=\"og:description\" content=\"I have a relatively simple UDF that does the following:1. Loops over all the cell threads. 2. Loops over all cells of each cell thread. 3. Calculates centroid of each cell. 4. Loops over all face threads. 5. Loops over all faces of each face thread.\" \/>\n\t\t<meta property=\"og:url\" content=\"https:\/\/innovationspace.ansys.com\/forum\/forums\/topic\/fluent-udf-passing-information-to-a-face-loop-within-a-cell-loop\/\" \/>\n\t\t<meta property=\"article:published_time\" content=\"2023-03-21T22:34:33+00:00\" \/>\n\t\t<meta property=\"article:modified_time\" content=\"2023-03-21T23:06:03+00:00\" \/>\n\t\t<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n\t\t<meta name=\"twitter:title\" content=\"Fluent UDF: Passing information to a face loop within a cell loop | Ansys Learning Forum\" \/>\n\t\t<meta name=\"twitter:description\" content=\"I have a relatively simple UDF that does the following:1. Loops over all the cell threads. 2. Loops over all cells of each cell thread. 3. Calculates centroid of each cell. 4. Loops over all face threads. 5. Loops over all faces of each face thread.\" \/>\n\t\t<script type=\"application\/ld+json\" class=\"aioseo-schema\">\n\t\t\t{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/innovationspace.ansys.com\\\/forum\\\/forums\\\/topic\\\/fluent-udf-passing-information-to-a-face-loop-within-a-cell-loop\\\/#breadcrumblist\",\"itemListElement\":[{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/innovationspace.ansys.com\\\/forum#listItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/innovationspace.ansys.com\\\/forum\",\"nextItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/innovationspace.ansys.com\\\/forum\\\/topics\\\/#listItem\",\"name\":\"Topics\"}},{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/innovationspace.ansys.com\\\/forum\\\/topics\\\/#listItem\",\"position\":2,\"name\":\"Topics\",\"item\":\"https:\\\/\\\/innovationspace.ansys.com\\\/forum\\\/topics\\\/\",\"nextItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/innovationspace.ansys.com\\\/forum\\\/forums\\\/topic-tag\\\/udf\\\/#listItem\",\"name\":\"udf\"},\"previousItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/innovationspace.ansys.com\\\/forum#listItem\",\"name\":\"Home\"}},{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/innovationspace.ansys.com\\\/forum\\\/forums\\\/topic-tag\\\/udf\\\/#listItem\",\"position\":3,\"name\":\"udf\",\"item\":\"https:\\\/\\\/innovationspace.ansys.com\\\/forum\\\/forums\\\/topic-tag\\\/udf\\\/\",\"nextItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/innovationspace.ansys.com\\\/forum\\\/forums\\\/topic\\\/fluent-udf-passing-information-to-a-face-loop-within-a-cell-loop\\\/#listItem\",\"name\":\"Fluent UDF: Passing information to a face loop within a cell loop\"},\"previousItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/innovationspace.ansys.com\\\/forum\\\/topics\\\/#listItem\",\"name\":\"Topics\"}},{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/innovationspace.ansys.com\\\/forum\\\/forums\\\/topic\\\/fluent-udf-passing-information-to-a-face-loop-within-a-cell-loop\\\/#listItem\",\"position\":4,\"name\":\"Fluent UDF: Passing information to a face loop within a cell loop\",\"previousItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/innovationspace.ansys.com\\\/forum\\\/forums\\\/topic-tag\\\/udf\\\/#listItem\",\"name\":\"udf\"}}]},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/innovationspace.ansys.com\\\/forum\\\/#organization\",\"name\":\"Ansys Learning Forum\",\"description\":\"Ansys Innovation Space\",\"url\":\"https:\\\/\\\/innovationspace.ansys.com\\\/forum\\\/\"},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/innovationspace.ansys.com\\\/forum\\\/forums\\\/topic\\\/fluent-udf-passing-information-to-a-face-loop-within-a-cell-loop\\\/#webpage\",\"url\":\"https:\\\/\\\/innovationspace.ansys.com\\\/forum\\\/forums\\\/topic\\\/fluent-udf-passing-information-to-a-face-loop-within-a-cell-loop\\\/\",\"name\":\"Fluent UDF: Passing information to a face loop within a cell loop | Ansys Learning Forum\",\"description\":\"I have a relatively simple UDF that does the following:1. Loops over all the cell threads. 2. Loops over all cells of each cell thread. 3. Calculates centroid of each cell. 4. Loops over all face threads. 5. Loops over all faces of each face thread.\",\"inLanguage\":\"en-US\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/innovationspace.ansys.com\\\/forum\\\/#website\"},\"breadcrumb\":{\"@id\":\"https:\\\/\\\/innovationspace.ansys.com\\\/forum\\\/forums\\\/topic\\\/fluent-udf-passing-information-to-a-face-loop-within-a-cell-loop\\\/#breadcrumblist\"},\"datePublished\":\"2023-03-21T22:34:33+00:00\",\"dateModified\":\"2023-03-21T23:06:03+00:00\"},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/innovationspace.ansys.com\\\/forum\\\/#website\",\"url\":\"https:\\\/\\\/innovationspace.ansys.com\\\/forum\\\/\",\"name\":\"Ansys Learning Forum\",\"description\":\"Ansys Innovation Space\",\"inLanguage\":\"en-US\",\"publisher\":{\"@id\":\"https:\\\/\\\/innovationspace.ansys.com\\\/forum\\\/#organization\"}}]}\n\t\t<\/script>\n\t\t<!-- All in One SEO -->\n\n","aioseo_head_json":{"title":"Fluent UDF: Passing information to a face loop within a cell loop | Ansys Learning Forum","description":"I have a relatively simple UDF that does the following:1. Loops over all the cell threads. 2. Loops over all cells of each cell thread. 3. Calculates centroid of each cell. 4. Loops over all face threads. 5. Loops over all faces of each face thread.","canonical_url":"https:\/\/innovationspace.ansys.com\/forum\/forums\/topic\/fluent-udf-passing-information-to-a-face-loop-within-a-cell-loop\/","robots":"max-image-preview:large","keywords":"","webmasterTools":{"miscellaneous":""},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"BreadcrumbList","@id":"https:\/\/innovationspace.ansys.com\/forum\/forums\/topic\/fluent-udf-passing-information-to-a-face-loop-within-a-cell-loop\/#breadcrumblist","itemListElement":[{"@type":"ListItem","@id":"https:\/\/innovationspace.ansys.com\/forum#listItem","position":1,"name":"Home","item":"https:\/\/innovationspace.ansys.com\/forum","nextItem":{"@type":"ListItem","@id":"https:\/\/innovationspace.ansys.com\/forum\/topics\/#listItem","name":"Topics"}},{"@type":"ListItem","@id":"https:\/\/innovationspace.ansys.com\/forum\/topics\/#listItem","position":2,"name":"Topics","item":"https:\/\/innovationspace.ansys.com\/forum\/topics\/","nextItem":{"@type":"ListItem","@id":"https:\/\/innovationspace.ansys.com\/forum\/forums\/topic-tag\/udf\/#listItem","name":"udf"},"previousItem":{"@type":"ListItem","@id":"https:\/\/innovationspace.ansys.com\/forum#listItem","name":"Home"}},{"@type":"ListItem","@id":"https:\/\/innovationspace.ansys.com\/forum\/forums\/topic-tag\/udf\/#listItem","position":3,"name":"udf","item":"https:\/\/innovationspace.ansys.com\/forum\/forums\/topic-tag\/udf\/","nextItem":{"@type":"ListItem","@id":"https:\/\/innovationspace.ansys.com\/forum\/forums\/topic\/fluent-udf-passing-information-to-a-face-loop-within-a-cell-loop\/#listItem","name":"Fluent UDF: Passing information to a face loop within a cell loop"},"previousItem":{"@type":"ListItem","@id":"https:\/\/innovationspace.ansys.com\/forum\/topics\/#listItem","name":"Topics"}},{"@type":"ListItem","@id":"https:\/\/innovationspace.ansys.com\/forum\/forums\/topic\/fluent-udf-passing-information-to-a-face-loop-within-a-cell-loop\/#listItem","position":4,"name":"Fluent UDF: Passing information to a face loop within a cell loop","previousItem":{"@type":"ListItem","@id":"https:\/\/innovationspace.ansys.com\/forum\/forums\/topic-tag\/udf\/#listItem","name":"udf"}}]},{"@type":"Organization","@id":"https:\/\/innovationspace.ansys.com\/forum\/#organization","name":"Ansys Learning Forum","description":"Ansys Innovation Space","url":"https:\/\/innovationspace.ansys.com\/forum\/"},{"@type":"WebPage","@id":"https:\/\/innovationspace.ansys.com\/forum\/forums\/topic\/fluent-udf-passing-information-to-a-face-loop-within-a-cell-loop\/#webpage","url":"https:\/\/innovationspace.ansys.com\/forum\/forums\/topic\/fluent-udf-passing-information-to-a-face-loop-within-a-cell-loop\/","name":"Fluent UDF: Passing information to a face loop within a cell loop | Ansys Learning Forum","description":"I have a relatively simple UDF that does the following:1. Loops over all the cell threads. 2. Loops over all cells of each cell thread. 3. Calculates centroid of each cell. 4. Loops over all face threads. 5. Loops over all faces of each face thread.","inLanguage":"en-US","isPartOf":{"@id":"https:\/\/innovationspace.ansys.com\/forum\/#website"},"breadcrumb":{"@id":"https:\/\/innovationspace.ansys.com\/forum\/forums\/topic\/fluent-udf-passing-information-to-a-face-loop-within-a-cell-loop\/#breadcrumblist"},"datePublished":"2023-03-21T22:34:33+00:00","dateModified":"2023-03-21T23:06:03+00:00"},{"@type":"WebSite","@id":"https:\/\/innovationspace.ansys.com\/forum\/#website","url":"https:\/\/innovationspace.ansys.com\/forum\/","name":"Ansys Learning Forum","description":"Ansys Innovation Space","inLanguage":"en-US","publisher":{"@id":"https:\/\/innovationspace.ansys.com\/forum\/#organization"}}]},"og:locale":"en_US","og:site_name":"Ansys Learning Forum | Ansys Innovation Space","og:type":"article","og:title":"Fluent UDF: Passing information to a face loop within a cell loop | Ansys Learning Forum","og:description":"I have a relatively simple UDF that does the following:1. Loops over all the cell threads. 2. Loops over all cells of each cell thread. 3. Calculates centroid of each cell. 4. Loops over all face threads. 5. Loops over all faces of each face thread.","og:url":"https:\/\/innovationspace.ansys.com\/forum\/forums\/topic\/fluent-udf-passing-information-to-a-face-loop-within-a-cell-loop\/","article:published_time":"2023-03-21T22:34:33+00:00","article:modified_time":"2023-03-21T23:06:03+00:00","twitter:card":"summary_large_image","twitter:title":"Fluent UDF: Passing information to a face loop within a cell loop | Ansys Learning Forum","twitter:description":"I have a relatively simple UDF that does the following:1. Loops over all the cell threads. 2. Loops over all cells of each cell thread. 3. Calculates centroid of each cell. 4. Loops over all face threads. 5. Loops over all faces of each face thread."},"aioseo_meta_data":{"post_id":"275780","title":null,"description":null,"keywords":null,"keyphrases":null,"primary_term":null,"canonical_url":null,"og_title":null,"og_description":null,"og_object_type":"default","og_image_type":"content","og_image_url":null,"og_image_width":null,"og_image_height":null,"og_image_custom_url":null,"og_image_custom_fields":null,"og_video":null,"og_custom_url":null,"og_article_section":null,"og_article_tags":null,"twitter_use_og":true,"twitter_card":"default","twitter_image_type":"default","twitter_image_url":null,"twitter_image_custom_url":null,"twitter_image_custom_fields":null,"twitter_title":null,"twitter_description":null,"schema":{"blockGraphs":[],"customGraphs":[],"default":{"data":{"Article":[],"Course":[],"Dataset":[],"FAQPage":[],"Movie":[],"Person":[],"Product":[],"ProductReview":[],"Car":[],"Recipe":[],"Service":[],"SoftwareApplication":[],"WebPage":[]},"graphName":"","isEnabled":true},"graphs":[]},"schema_type":"default","schema_type_options":null,"pillar_content":false,"robots_default":true,"robots_noindex":false,"robots_noarchive":false,"robots_nosnippet":false,"robots_nofollow":false,"robots_noimageindex":false,"robots_noodp":false,"robots_notranslate":false,"robots_max_snippet":null,"robots_max_videopreview":null,"robots_max_imagepreview":"large","priority":null,"frequency":null,"local_seo":null,"limit_modified_date":false,"created":"2024-10-28 18:17:40","updated":"2024-10-28 18:17:40","ai":null,"breadcrumb_settings":null,"seo_analyzer_scan_date":null},"aioseo_breadcrumb":"<div class=\"aioseo-breadcrumbs\"><span class=\"aioseo-breadcrumb\">\n\t\t\t<a href=\"https:\/\/innovationspace.ansys.com\/forum\" title=\"Home\">Home<\/a>\n\t\t<\/span><span class=\"aioseo-breadcrumb-separator\">&raquo;<\/span><span class=\"aioseo-breadcrumb\">\n\t\t\t<a href=\"https:\/\/innovationspace.ansys.com\/forum\/topics\/\" title=\"Topics\">Topics<\/a>\n\t\t<\/span><span class=\"aioseo-breadcrumb-separator\">&raquo;<\/span><span class=\"aioseo-breadcrumb\">\n\t\t\t<a href=\"https:\/\/innovationspace.ansys.com\/forum\/forums\/topic-tag\/udf\/\" title=\"udf\">udf<\/a>\n\t\t<\/span><span class=\"aioseo-breadcrumb-separator\">&raquo;<\/span><span class=\"aioseo-breadcrumb\">\n\t\t\tFluent UDF: Passing information to a face loop within a cell loop\n\t\t<\/span><\/div>","aioseo_breadcrumb_json":[{"label":"Home","link":"https:\/\/innovationspace.ansys.com\/forum"},{"label":"Topics","link":"https:\/\/innovationspace.ansys.com\/forum\/topics\/"},{"label":"udf","link":"https:\/\/innovationspace.ansys.com\/forum\/forums\/topic-tag\/udf\/"},{"label":"Fluent UDF: Passing information to a face loop within a cell loop","link":"https:\/\/innovationspace.ansys.com\/forum\/forums\/topic\/fluent-udf-passing-information-to-a-face-loop-within-a-cell-loop\/"}],"acf":[],"custom_fields":[{"0":{"_bbp_subscription":["279402","22555"],"_bbp_author_ip":["23.223.149.174"]," _bbp_last_reply_id":["0"]," _bbp_likes_count":["0"],"_btv_view_count":["3101"],"_edit_lock":["1679981404:211250"],"_bbp_topic_status":["unanswered"],"_bbp_status":["publish"],"_bbp_topic_id":["275780"],"_bbp_forum_id":["27792"],"_bbp_engagement":["22555","279402"],"_bbp_voice_count":["2"],"_bbp_reply_count":["11"],"_bbp_last_reply_id":["276751"],"_bbp_last_active_id":["276751"],"_bbp_last_active_time":["2023-03-28 06:19:24"]},"test":"kenneth-funglciconsultants-com-au"}],"_links":{"self":[{"href":"https:\/\/innovationspace.ansys.com\/forum\/wp-json\/wp\/v2\/topics\/275780","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\/275780\/revisions"}],"wp:attachment":[{"href":"https:\/\/innovationspace.ansys.com\/forum\/wp-json\/wp\/v2\/media?parent=275780"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}