


{"id":165889,"date":"2022-01-27T13:06:27","date_gmt":"2022-01-27T13:06:27","guid":{"rendered":"\/forum\/forums\/topic\/dpm-injection-on-surface-with-predefined-conditions-using-udf\/"},"modified":"2022-01-28T14:28:37","modified_gmt":"2022-01-28T14:28:37","slug":"dpm-injection-on-surface-with-predefined-conditions-using-udf","status":"closed","type":"topic","link":"https:\/\/innovationspace.ansys.com\/forum\/forums\/topic\/dpm-injection-on-surface-with-predefined-conditions-using-udf\/","title":{"rendered":"DPM injection on surface with predefined conditions using UDF"},"content":{"rendered":"<div class=\"Item-Body\">\n<div class=\"Message userContent\">\n<p>Hello everyone,<\/p>\n<p>I am a PhD student and I am trying to perform particle injections using the discrete phase model in Ansys Fluent. My final goal is to inject one particle per parcel with defined settings like diameter and massflow on my velocity-inlet at the face centers but not at every face of the surface.<\/p>\n<p>I first used a surface injection, but that is not want I want. What I want to do is to define a radius, starting from the center of my inlet and to inject one particle per parcel at the face centers lying within this radius. To inject particles I use the macro DEFINE_DPM_INJECTION_INIT(name,I). Therefore I need to loop over all particles with loop(p, I -&gt;init). I am not sure, if I need this command, because to check if the face centers are within my predefined radius I loop over all faces of my inlet using begin_f_loop(f,thread). So I have two loops now but so far I did not manage to find out a way to store the coordinates of the face centers without F_CENTROID(x,f,thread). And therefore I used begin_f_loop(f,thread) to loop over the inlet faces. Another problem is, that with DEFINE_DPM_INJECTION_INIT(name,I) I loop over particles, not parcels and depending on whether I set single or surface injection in the DPM settings in Fluent, loop(p, I-&gt;p_init) is repeated as many times as the number of faces of the inlet (surface injection) or only once (single injection) and then the right number of particles that should be injected starting from the center of the faces that fullfill the condition to be within the radius is divided on to one parcel (single injection) or as many parcels as the complete surface has faces (surface injection). I wanted to solve this problem by choosing the option one particle per parcel but this option seems not to be possible in Fluent. Is there a possibility to write a UDF to define the positions and properties of parcels and to get one particle per parcel doing a loop over all faces?<\/p>\n<p>My code is:<\/p>\n<p>&nbsp;#include &quot;udf.h&quot;<\/p>\n<p>&nbsp;#include &quot;surf.h&quot; \/* RP_CELL and RP_THREAD are defined in surf.h *\/<\/p>\n<p>&nbsp;#include &quot;dpm.h&quot;<\/p>\n<p><\/p>\n<\/p>\n<p>&nbsp;DEFINE_DPM_INJECTION_INIT(init_bubbles_wuerfel,I)<\/p>\n<p>&nbsp;{<\/p>\n<p>&nbsp;&nbsp;Particle *p;<\/p>\n<p>&nbsp;&nbsp;cell_t cell;<\/p>\n<p>&nbsp;&nbsp;face_t f;<\/p>\n<p>&nbsp;&nbsp;real r;<\/p>\n<p><\/p>\n<\/p>\n<p>&nbsp;&nbsp;int zone_ID = 12;<\/p>\n<p>&nbsp;&nbsp;Domain *domain;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\/* domain is declared as a variable&nbsp;&nbsp;*\/<\/p>\n<p>&nbsp;&nbsp;domain = Get_Domain(1);<\/p>\n<p>&nbsp;&nbsp;Thread *thread = Lookup_Thread(domain,zone_ID);<\/p>\n<p>&nbsp;&nbsp;Thread *cthread;<\/p>\n<p><\/p>\n<\/p>\n<p>&nbsp;&nbsp;&nbsp;\/*the centroid of the boundary face (x0,y0,z0) *\/<\/p>\n<p>&nbsp;&nbsp;real x0 = 0.0702225;<\/p>\n<p>&nbsp;&nbsp;real y0 = -0.0911812;<\/p>\n<p>&nbsp;&nbsp;real z0 = 1.3; <\/p>\n<p><\/p>\n<\/p>\n<p>&nbsp;&nbsp;\/*x holds the position vector of the face center <\/p>\n<p>&nbsp;&nbsp;it is 3 long because of 3D case&nbsp;&nbsp;*\/<\/p>\n<p>&nbsp;&nbsp;real x[3];<\/p>\n<p><\/p>\n<\/p>\n<p>&nbsp;&nbsp;\/*the maximum radius of the offset where particles should be emitted*\/<\/p>\n<p>&nbsp;&nbsp;real dpm_radius = 0.005; \/*radius of the pipe in m*\/<\/p>\n<p><\/p>\n<\/p>\n<p>&nbsp;&nbsp;loop(p, I-&gt;p_init)<\/p>\n<p>&nbsp;&nbsp;{<\/p>\n<p>&nbsp;&nbsp;&nbsp;&nbsp;begin_f_loop(f,thread)<\/p>\n<p>&nbsp;&nbsp;&nbsp;&nbsp;{<\/p>\n<p>&nbsp;&nbsp;&nbsp;\/* this function stores the center coordinates of every face in the predefined 2D or 3D vector x*\/<\/p>\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;F_CENTROID(x,f,thread);<\/p>\n<p><\/p>\n<\/p>\n<p>&nbsp;&nbsp;&nbsp;\/* three-dimensional pythagoras to calculate distance *\/<\/p>\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;r = pow(pow((x[0]-x0),2)+pow((x[1]-y0),2)+pow((x[2]-z0),2),0.5);<\/p>\n<p><\/p>\n<\/p>\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if (r &lt; dpm_radius) <\/p>\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{Message(&quot;r ist kleiner als der definierte Radius: %s<br \/>\n&quot;,I-&gt;name);<\/p>\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\/* Standard Ansys Fluent Looping Macro to get particle<\/p>\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;streams in an Injection*\/ <\/p>\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;cell = PP_CELL(p); \/*Get the cell and thread that<\/p>\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;* the particle is currently in *\/<\/p>\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;cthread = PP_CELL_THREAD(p);<\/p>\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;PP_POS(p)[0] = x[0];<\/p>\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\/*P_INIT_POS(p)[1] = x[1];<\/p>\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;P_INIT_POS(p)[2] = x[2]*\/<\/p>\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;PP_DIAM(p) = 3e-7;<\/p>\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;PP_RHO(p) = 1000.0;<\/p>\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;PP_MASS(p) = 1.413716694115407e-17;<\/p>\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;PP_FLOW_RATE(p) = 1.979203371761569e-15;<\/p>\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Message(&quot;loop: %s<br \/>\n&quot;,I-&gt;name);&nbsp;<\/p>\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;} <\/p>\n<p>&nbsp;&nbsp;&nbsp;&nbsp;}<\/p>\n<p>&nbsp;&nbsp;&nbsp;&nbsp;end_f_loop(f,thread) <\/p>\n<p>&nbsp;&nbsp;}<\/p>\n<p>&nbsp;}<\/p>\n<p>I would be really glad, if anyone could help me. Thank you very much,<\/p>\n<p>Vera<\/p>\n","protected":false},"template":"","class_list":["post-165889","topic","type-topic","status-closed","hentry"],"aioseo_notices":[],"acf":[],"custom_fields":[{"0":{"_btv_view_count":["2838"],"_bbp_likes_count":["0"],"_bbp_subscription":["246636"],"_bbp_topic_status":["unanswered"],"_bbp_status":["publish"],"_bbp_topic_id":["165889"],"_bbp_forum_id":["27792"],"_bbp_engagement":["199","246636"],"_bbp_voice_count":["2"],"_bbp_reply_count":["2"],"_bbp_last_reply_id":["203857"],"_bbp_last_active_id":["203857"],"_bbp_last_active_time":["2022-01-28 14:28:37"]},"test":"vera-stelzeroth-regensburg-de"}],"_links":{"self":[{"href":"https:\/\/innovationspace.ansys.com\/forum\/wp-json\/wp\/v2\/topics\/165889","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\/165889\/revisions"}],"wp:attachment":[{"href":"https:\/\/innovationspace.ansys.com\/forum\/wp-json\/wp\/v2\/media?parent=165889"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}