


{"id":377842,"date":"2024-08-09T20:29:23","date_gmt":"2024-08-09T20:29:23","guid":{"rendered":"https:\/\/innovationspace.ansys.com\/forum\/forums\/reply\/377842\/"},"modified":"2024-08-12T04:19:58","modified_gmt":"2024-08-12T04:19:58","slug":"377842","status":"publish","type":"reply","link":"https:\/\/innovationspace.ansys.com\/forum\/forums\/reply\/377842\/","title":{"rendered":"Reply To: Ansys Fluent UDF: DEFINE_DPM_BC"},"content":{"rendered":"<p>&lt;p&gt;Okay I get this, but how do I get the particle to stick on the wall?&lt;br&gt;&lt;br&gt;1. Is there a particular macros I need to look for to access data from P_USER_REAL so I can post process \/ visualise the results?&lt;br&gt;&lt;br&gt;2. What do you think I must do to model particle trajectory after colliding with the boundary?&lt;\/p&gt;&lt;p&gt;3. From the below UDF I do not see a text file being generated to run my simulation, what could be the reason?&lt;br&gt;&lt;br&gt;&lt;\/p&gt;&lt;div&gt;&lt;div&gt;#include &ldquo;udf.h&rdquo;&lt;\/div&gt;&lt;div&gt;#include &ldquo;dpm.h&rdquo;&lt;\/div&gt;&lt;div&gt;#include &ldquo;math.h&rdquo;&lt;\/div&gt;&lt;div&gt;#include &ldquo;mem.h&rdquo;&lt;\/div&gt;&lt;div&gt;#include&lt;\/div&gt;&lt;br&gt;&lt;div&gt;#define Rho_air 1.225 &nbsp;\/* Air density in kg\/m^3 *\/&lt;\/div&gt;&lt;div&gt;#define Cd 0.47 &nbsp; &nbsp; &nbsp; &nbsp;\/* Drag coefficient for a sphere *\/&lt;\/div&gt;&lt;div&gt;#define mu 0.5 &nbsp; &nbsp; &nbsp; &nbsp; \/* Coefficient of friction *\/&lt;\/div&gt;&lt;br&gt;&lt;div&gt;\/* Define your boundary condition function *\/&lt;\/div&gt;&lt;div&gt;DEFINE_DPM_BC(particle_bc, p, t, f, normal, dim)&lt;\/div&gt;&lt;div&gt;{&lt;\/div&gt;&lt;div&gt;&nbsp; &nbsp; real V = sqrt(P_VEL(p)[0] * P_VEL(p)[0] + P_VEL(p)[1] * P_VEL(p)[1] + P_VEL(p)[2] * P_VEL(p)[2]); &nbsp;\/* Velocity magnitude in m\/s *\/&lt;\/div&gt;&lt;div&gt;&nbsp; &nbsp; FILE * fp1 ;&lt;\/div&gt;&lt;br&gt;&lt;div&gt;&nbsp; &nbsp; real alpha; &nbsp;\/* angle of particle path with face normal *\/&lt;\/div&gt;&lt;div&gt;&nbsp; &nbsp; real vn=0.;&lt;\/div&gt;&lt;div&gt;&nbsp; &nbsp; real nor_coeff = 1.;&lt;\/div&gt;&lt;div&gt;&nbsp; &nbsp; real tan_coeff = 0.3;&lt;\/div&gt;&lt;div&gt;&nbsp; &nbsp; \/\/real normal[3];&lt;\/div&gt;&lt;div&gt;&nbsp; &nbsp; int i, idim;&lt;\/div&gt;&lt;div&gt;&nbsp; &nbsp; real NV_VEC(x);&lt;\/div&gt;&lt;br&gt;&lt;div&gt;&nbsp; &nbsp; real radius = P_DIAM(p) \/ 2.0;&lt;\/div&gt;&lt;div&gt;&nbsp; &nbsp; real A = M_PI * radius * radius; &nbsp;\/* M_PI is a constant for &pi; *\/&lt;\/div&gt;&lt;br&gt;&lt;div&gt;&nbsp; &nbsp; \/* Get the face pressure *\/&lt;\/div&gt;&lt;div&gt;&nbsp; &nbsp; real P_local = F_P(f, t);&lt;\/div&gt;&lt;br&gt;&lt;div&gt;&nbsp; &nbsp; \/* Calculate aerodynamic force Fa *\/&lt;\/div&gt;&lt;div&gt;&nbsp; &nbsp; real Fa = 0.5 * Rho_air * A * Cd * V * V;&lt;\/div&gt;&lt;br&gt;&lt;div&gt;&nbsp; &nbsp; \/* Calculate normal force Fn *\/&lt;\/div&gt;&lt;div&gt;&nbsp; &nbsp; real Fn = P_local * A;&lt;\/div&gt;&lt;br&gt;&lt;div&gt;&nbsp; &nbsp; \/* Calculate frictional force Ff *\/&lt;\/div&gt;&lt;div&gt;&nbsp; &nbsp; real Ff = mu * Fn;&lt;\/div&gt;&lt;br&gt;&lt;div&gt;&nbsp; &nbsp; if (Fa &gt; Ff)&lt;\/div&gt;&lt;div&gt;&nbsp; &nbsp; {&lt;\/div&gt;&lt;div&gt;&nbsp; &nbsp; &nbsp; &nbsp; \/* Particle needs to bounce with a coefficient of restitution of 1 *\/&lt;\/div&gt;&lt;div&gt;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; \/* Compute normal velocity. *\/&lt;\/div&gt;&lt;div&gt;&nbsp; &nbsp; &nbsp; for(i=0; i&lt;div&gt;&nbsp; &nbsp; &nbsp; &nbsp;&lt;\/div&gt;&lt;div&gt;&nbsp; &nbsp; &nbsp; &nbsp; vn += P_VEL(p)[i]*normal[i];&lt;\/div&gt;&lt;br&gt;&lt;div&gt;&nbsp; &nbsp; &nbsp; \/* Subtract off normal velocity. *\/&lt;\/div&gt;&lt;div&gt;&nbsp; &nbsp; &nbsp; for(i=0; i&lt;div&gt;&nbsp; &nbsp; &nbsp; &nbsp; P_VEL(p)[i] -= vn*normal[i];&lt;\/div&gt;&lt;br&gt;&lt;div&gt;&nbsp; &nbsp; &nbsp; \/* Apply tangential coefficient of restitution. *\/&lt;\/div&gt;&lt;div&gt;&nbsp; &nbsp; &nbsp; for(i=0; i&lt;div&gt;&nbsp; &nbsp; &nbsp; &nbsp; P_VEL(p)[i] *= tan_coeff;&lt;\/div&gt;&lt;br&gt;&lt;div&gt;&nbsp; &nbsp; &nbsp; \/* Add reflected normal velocity. *\/&lt;\/div&gt;&lt;div&gt;&nbsp; &nbsp; &nbsp; for(i=0; i&lt;div&gt;&nbsp; &nbsp; &nbsp; &nbsp; P_VEL(p)[i] -= nor_coeff*vn*normal[i]; &nbsp;&lt;\/div&gt;&lt;br&gt;&lt;div&gt;&nbsp; &nbsp; &nbsp; \/* Store new velocity in P_VEL0 of particle *\/&lt;\/div&gt;&lt;div&gt;&nbsp; &nbsp; &nbsp; for(i=0; i&lt;div&gt;&nbsp; &nbsp; &nbsp; &nbsp; P_VEL0(p)[i] = P_VEL(p)[i];&lt;\/div&gt;&lt;br&gt;&lt;div&gt;&nbsp; &nbsp; &nbsp; fp1=fopen ( &ldquo;Impact.txt&rdquo; , &ldquo;a&rdquo; ) ;&lt;\/div&gt;&lt;div&gt;&nbsp; &nbsp; &nbsp; fprintf( fp1 , &ldquo;%f %f %f %f\\n&rdquo;, Fa, Ff, radius, P_local);&lt;\/div&gt;&lt;div&gt;&nbsp; &nbsp; &nbsp; fclose( fp1 );&lt;\/div&gt;&lt;br&gt;&lt;div&gt;&nbsp; &nbsp; &nbsp; return PATH_ACTIVE;&lt;\/div&gt;&lt;br&gt;&lt;div&gt;&nbsp; &nbsp; }&lt;\/div&gt;&lt;div&gt;&nbsp; &nbsp; else&lt;\/div&gt;&lt;div&gt;&nbsp; &nbsp; {&lt;\/div&gt;&lt;div&gt;&nbsp; &nbsp; &nbsp; &nbsp; \/* Particle sticks to the boundary *\/&lt;\/div&gt;&lt;div&gt;&nbsp; &nbsp; &nbsp; &nbsp; for (int i = 0; i &lt; dim; i++)&lt;\/div&gt;&lt;div&gt;&nbsp; &nbsp; &nbsp; &nbsp; {&lt;\/div&gt;&lt;div&gt;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; P_VEL(p)[i] = 0; \/* Set velocity to zero *\/&lt;\/div&gt;&lt;div&gt;&nbsp; &nbsp; &nbsp; &nbsp; }&lt;\/div&gt;&lt;br&gt;&lt;div&gt;&nbsp; &nbsp; &nbsp; &nbsp; P_USER_REAL(p, 0) = 1.0; \/* Optionally set a user-defined variable to indicate sticking *\/&lt;\/div&gt;&lt;br&gt;&lt;div&gt;&nbsp; &nbsp; &nbsp; &nbsp; \/* Save the impingement location *\/&lt;\/div&gt;&lt;div&gt;&nbsp; &nbsp; &nbsp; &nbsp; P_USER_REAL(p, 1) = P_POS(p)[0]; &nbsp;\/* X-coordinate *\/&lt;\/div&gt;&lt;div&gt;&nbsp; &nbsp; &nbsp; &nbsp; P_USER_REAL(p, 2) = P_POS(p)[1]; &nbsp;\/* Y-coordinate *\/&lt;\/div&gt;&lt;div&gt;&nbsp; &nbsp; &nbsp; &nbsp; P_USER_REAL(p, 3) = P_POS(p)[2]; &nbsp;\/* Z-coordinate *\/&lt;\/div&gt;&lt;br&gt;&lt;div&gt;&nbsp; &nbsp; &nbsp; &nbsp; P_USER_REAL(p, 4) = 1.0; &nbsp;\/* Mark as stuck *\/&lt;\/div&gt;&lt;br&gt;&lt;div&gt;&nbsp; &nbsp; &nbsp; &nbsp; return PATH_ABORT; \/* Stop tracking the particle *\/&lt;\/div&gt;&lt;div&gt;&nbsp; &nbsp; }&lt;\/div&gt;&lt;div&gt;}&lt;\/div&gt;&lt;\/div&gt;&lt;p&gt;&nbsp;&lt;\/p&gt;&lt;p&gt;&nbsp;&lt;\/p&gt;&lt;\/div&gt;&lt;\/div&gt;&lt;\/div&gt;&lt;\/div&gt;&lt;\/div&gt;&lt;p&gt;&nbsp;&lt;\/p&gt;<\/p>\n","protected":false},"template":"","class_list":["post-377842","reply","type-reply","status-publish","hentry"],"aioseo_notices":[],"aioseo_head":"\n\t\t<!-- All in One SEO 4.9.10 - aioseo.com -->\n\t<meta name=\"description\" content=\"Okay I get this, but how do I get the particle to stick on the wall?1. Is there a particular macros I need to look for to access data from P_USER_REAL so I can post process \/ visualise the results?2. What do you think I must do to model particle trajectory after colliding with the\" \/>\n\t<meta name=\"robots\" content=\"max-image-preview:large\" \/>\n\t<link rel=\"canonical\" href=\"https:\/\/innovationspace.ansys.com\/forum\/forums\/reply\/377842\/\" \/>\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=\"Reply To: Ansys Fluent UDF: DEFINE_DPM_BC | Ansys Learning Forum\" \/>\n\t\t<meta property=\"og:description\" content=\"Okay I get this, but how do I get the particle to stick on the wall?1. Is there a particular macros I need to look for to access data from P_USER_REAL so I can post process \/ visualise the results?2. What do you think I must do to model particle trajectory after colliding with the\" \/>\n\t\t<meta property=\"og:url\" content=\"https:\/\/innovationspace.ansys.com\/forum\/forums\/reply\/377842\/\" \/>\n\t\t<meta property=\"article:published_time\" content=\"2024-08-09T20:29:23+00:00\" \/>\n\t\t<meta property=\"article:modified_time\" content=\"2024-08-12T04:19:58+00:00\" \/>\n\t\t<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n\t\t<meta name=\"twitter:title\" content=\"Reply To: Ansys Fluent UDF: DEFINE_DPM_BC | Ansys Learning Forum\" \/>\n\t\t<meta name=\"twitter:description\" content=\"Okay I get this, but how do I get the particle to stick on the wall?1. Is there a particular macros I need to look for to access data from P_USER_REAL so I can post process \/ visualise the results?2. What do you think I must do to model particle trajectory after colliding with the\" \/>\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\\\/reply\\\/377842\\\/#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\\\/forums\\\/reply\\\/377842\\\/#listItem\",\"name\":\"Reply To: Ansys Fluent UDF: DEFINE_DPM_BC\"}},{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/innovationspace.ansys.com\\\/forum\\\/forums\\\/reply\\\/377842\\\/#listItem\",\"position\":2,\"name\":\"Reply To: Ansys Fluent UDF: DEFINE_DPM_BC\",\"previousItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/innovationspace.ansys.com\\\/forum#listItem\",\"name\":\"Home\"}}]},{\"@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\\\/reply\\\/377842\\\/#webpage\",\"url\":\"https:\\\/\\\/innovationspace.ansys.com\\\/forum\\\/forums\\\/reply\\\/377842\\\/\",\"name\":\"Reply To: Ansys Fluent UDF: DEFINE_DPM_BC | Ansys Learning Forum\",\"description\":\"Okay I get this, but how do I get the particle to stick on the wall?1. Is there a particular macros I need to look for to access data from P_USER_REAL so I can post process \\\/ visualise the results?2. What do you think I must do to model particle trajectory after colliding with the\",\"inLanguage\":\"en-US\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/innovationspace.ansys.com\\\/forum\\\/#website\"},\"breadcrumb\":{\"@id\":\"https:\\\/\\\/innovationspace.ansys.com\\\/forum\\\/forums\\\/reply\\\/377842\\\/#breadcrumblist\"},\"datePublished\":\"2024-08-09T20:29:23+00:00\",\"dateModified\":\"2024-08-12T04:19:58+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":"Reply To: Ansys Fluent UDF: DEFINE_DPM_BC | Ansys Learning Forum","description":"Okay I get this, but how do I get the particle to stick on the wall?1. Is there a particular macros I need to look for to access data from P_USER_REAL so I can post process \/ visualise the results?2. What do you think I must do to model particle trajectory after colliding with the","canonical_url":"https:\/\/innovationspace.ansys.com\/forum\/forums\/reply\/377842\/","robots":"max-image-preview:large","keywords":"","webmasterTools":{"miscellaneous":""},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"BreadcrumbList","@id":"https:\/\/innovationspace.ansys.com\/forum\/forums\/reply\/377842\/#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\/forums\/reply\/377842\/#listItem","name":"Reply To: Ansys Fluent UDF: DEFINE_DPM_BC"}},{"@type":"ListItem","@id":"https:\/\/innovationspace.ansys.com\/forum\/forums\/reply\/377842\/#listItem","position":2,"name":"Reply To: Ansys Fluent UDF: DEFINE_DPM_BC","previousItem":{"@type":"ListItem","@id":"https:\/\/innovationspace.ansys.com\/forum#listItem","name":"Home"}}]},{"@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\/reply\/377842\/#webpage","url":"https:\/\/innovationspace.ansys.com\/forum\/forums\/reply\/377842\/","name":"Reply To: Ansys Fluent UDF: DEFINE_DPM_BC | Ansys Learning Forum","description":"Okay I get this, but how do I get the particle to stick on the wall?1. Is there a particular macros I need to look for to access data from P_USER_REAL so I can post process \/ visualise the results?2. What do you think I must do to model particle trajectory after colliding with the","inLanguage":"en-US","isPartOf":{"@id":"https:\/\/innovationspace.ansys.com\/forum\/#website"},"breadcrumb":{"@id":"https:\/\/innovationspace.ansys.com\/forum\/forums\/reply\/377842\/#breadcrumblist"},"datePublished":"2024-08-09T20:29:23+00:00","dateModified":"2024-08-12T04:19:58+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":"Reply To: Ansys Fluent UDF: DEFINE_DPM_BC | Ansys Learning Forum","og:description":"Okay I get this, but how do I get the particle to stick on the wall?1. Is there a particular macros I need to look for to access data from P_USER_REAL so I can post process \/ visualise the results?2. What do you think I must do to model particle trajectory after colliding with the","og:url":"https:\/\/innovationspace.ansys.com\/forum\/forums\/reply\/377842\/","article:published_time":"2024-08-09T20:29:23+00:00","article:modified_time":"2024-08-12T04:19:58+00:00","twitter:card":"summary_large_image","twitter:title":"Reply To: Ansys Fluent UDF: DEFINE_DPM_BC | Ansys Learning Forum","twitter:description":"Okay I get this, but how do I get the particle to stick on the wall?1. Is there a particular macros I need to look for to access data from P_USER_REAL so I can post process \/ visualise the results?2. What do you think I must do to model particle trajectory after colliding with the"},"aioseo_meta_data":{"post_id":"377842","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 16:33:47","updated":"2026-09-22 16:12:15","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\tReply To: Ansys Fluent UDF: DEFINE_DPM_BC\n\t\t<\/span><\/div>","aioseo_breadcrumb_json":[{"label":"Home","link":"https:\/\/innovationspace.ansys.com\/forum"},{"label":"Reply To: Ansys Fluent UDF: DEFINE_DPM_BC","link":"https:\/\/innovationspace.ansys.com\/forum\/forums\/reply\/377842\/"}],"acf":[],"_links":{"self":[{"href":"https:\/\/innovationspace.ansys.com\/forum\/wp-json\/wp\/v2\/replies\/377842","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/innovationspace.ansys.com\/forum\/wp-json\/wp\/v2\/replies"}],"about":[{"href":"https:\/\/innovationspace.ansys.com\/forum\/wp-json\/wp\/v2\/types\/reply"}],"version-history":[{"count":4,"href":"https:\/\/innovationspace.ansys.com\/forum\/wp-json\/wp\/v2\/replies\/377842\/revisions"}],"predecessor-version":[{"id":377889,"href":"https:\/\/innovationspace.ansys.com\/forum\/wp-json\/wp\/v2\/replies\/377842\/revisions\/377889"}],"wp:attachment":[{"href":"https:\/\/innovationspace.ansys.com\/forum\/wp-json\/wp\/v2\/media?parent=377842"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}