


{"id":436101,"date":"2025-07-04T13:44:28","date_gmt":"2025-07-04T13:44:28","guid":{"rendered":"https:\/\/innovationspace.ansys.com\/forum\/forums\/topic\/uds_flux-incorrectly-computing-advective-sink-term\/"},"modified":"2025-07-04T13:44:28","modified_gmt":"2025-07-04T13:44:28","slug":"uds_flux-incorrectly-computing-advective-sink-term","status":"publish","type":"topic","link":"https:\/\/innovationspace.ansys.com\/forum\/forums\/topic\/uds_flux-incorrectly-computing-advective-sink-term\/","title":{"rendered":"UDS_FLUX incorrectly computing advective sink term"},"content":{"rendered":"<p>&lt;p&gt;Hello all,&lt;br&gt;&lt;br&gt;I am trying to implement a custom advection-like term that occurs at a gas-liquid interface using User-Defined Scalara functions. See equation (1)&nbsp;&lt;br&gt;<img decoding=\"async\" src=\"https:\/\/innovationspace.ansys.com\/forum\/wp-content\/uploads\/sites\/2\/2025\/07\/04-07-2025-1751636055-mceclip0.png\" \/>&lt;br&gt;&lt;br&gt;To accomplish this term I am manipulating the DEFINE_UDS_FLUX term. See image below :&lt;br&gt;<img decoding=\"async\" src=\"https:\/\/innovationspace.ansys.com\/forum\/wp-content\/uploads\/sites\/2\/2025\/07\/04-07-2025-1751636098-mceclip1.png\" \/>&lt;br&gt;To implement this term using DEFINE_UDS_FLUX, the volume fraction gradient is obtained from a specific adjustment function where it is read by the DEFINE_UDS_FLUX. To make this term a flux, I linearly interpolate the volume fraction gradient values at neighboring cells to get a face value. See code below:&nbsp;&lt;\/p&gt;&lt;div&gt;&lt;div&gt;DEFINE_UDS_FLUX(VolumFracGrad_Sink, f, t, i)&lt;\/div&gt;&lt;div&gt;{&lt;\/div&gt;&lt;div&gt;&nbsp; &nbsp; cell_t c0, c1 = -1;&lt;\/div&gt;&lt;div&gt;&nbsp; &nbsp; Thread *t0, *t1 = NULL;&lt;\/div&gt;&lt;div&gt;&nbsp; &nbsp; real NV_VEC(A), flux = 0.0;&lt;\/div&gt;&lt;div&gt;&nbsp;&lt;\/div&gt;&lt;div&gt;&nbsp; &nbsp; \/\/ Cell pointers&lt;\/div&gt;&lt;div&gt;&nbsp; &nbsp; c0 = F_C0(f, t);&lt;\/div&gt;&lt;div&gt;&nbsp; &nbsp; t0 = F_C0_THREAD(f, t);&lt;\/div&gt;&lt;div&gt;&nbsp; &nbsp; c1 = F_C1(f, t);&lt;\/div&gt;&lt;div&gt;&nbsp; &nbsp; t1 = F_C1_THREAD(f, t);&lt;\/div&gt;&lt;br&gt;&lt;div&gt;&nbsp; &nbsp; real grad_alpha[3];&lt;\/div&gt;&lt;br&gt;&lt;div&gt;&nbsp; &nbsp; \/\/ Compute face area vector&lt;\/div&gt;&lt;div&gt;&nbsp; &nbsp; F_AREA(A, f, t);&lt;\/div&gt;&lt;br&gt;&lt;div&gt;&nbsp; &nbsp; if (BOUNDARY_FACE_THREAD_P(t))&lt;\/div&gt;&lt;div&gt;&nbsp; &nbsp; &nbsp;{&lt;\/div&gt;&lt;div&gt;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; flux = 0;&lt;\/div&gt;&lt;div&gt;&nbsp; &nbsp; &nbsp;}&lt;\/div&gt;&lt;div&gt;&nbsp; &nbsp; else&lt;\/div&gt;&lt;div&gt;&nbsp; &nbsp; {&lt;\/div&gt;&lt;br&gt;&lt;div&gt;&nbsp; &nbsp; &nbsp; \/\/ &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-&lt;\/div&gt;&lt;div&gt;&nbsp; &nbsp; \/\/ 5. Gradient of alpha&lt;\/div&gt;&lt;div&gt;&nbsp; &nbsp; \/\/ &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-&lt;\/div&gt;&lt;div&gt;&nbsp; &nbsp; grad_alpha[0] =(C_UDMI(c0, t0, 0)+C_UDMI(c1, t1, 0))*0.5;&lt;\/div&gt;&lt;div&gt;&nbsp; &nbsp; grad_alpha[1] =(C_UDMI(c0, t0, 1)+C_UDMI(c1, t1, 1))*0.5;&lt;\/div&gt;&lt;div&gt;&nbsp; &nbsp; grad_alpha[2] =(C_UDMI(c0, t0, 2)+C_UDMI(c1, t1, 2))*0.5;&lt;\/div&gt;&lt;br&gt;&lt;br&gt;&lt;div&gt;&nbsp; &nbsp; flux =&nbsp; &lt;span style=&#8221;font-size: 14pt;&#8221;&gt;-NV_DOT(grad_alpha,A);&lt;\/span&gt;&lt;\/div&gt;&lt;br&gt;&lt;br&gt;&lt;div&gt;&nbsp; &nbsp; }&lt;\/div&gt;&lt;div&gt;&nbsp;&lt;\/div&gt;&lt;br&gt;&lt;div&gt;&nbsp; &nbsp; return flux;&lt;\/div&gt;&lt;div&gt;}&lt;br&gt;&lt;br&gt;However, when I run this code using a volume of fluid approach with a sharp interface and a highly refined domain, I obtain this result.&lt;\/div&gt;&lt;\/div&gt;&lt;p&gt;&lt;br&gt;<img decoding=\"async\" src=\"https:\/\/innovationspace.ansys.com\/forum\/wp-content\/uploads\/sites\/2\/2025\/07\/04-07-2025-1751636405-mceclip3.png\" \/>&lt;br&gt;&lt;br&gt;Has anyone came across a similar problem? I&#8217;d expect a uniform result, not a skewed result. If I just take the x-direction gradient with no face area attachted, I get this result :&lt;br&gt;<img decoding=\"async\" src=\"https:\/\/innovationspace.ansys.com\/forum\/wp-content\/uploads\/sites\/2\/2025\/07\/04-07-2025-1751636553-mceclip4.png\" \/>&lt;br&gt;&lt;br&gt;It is very strange because If I plot the volume fraction gradient obtained in the defined adjust function (which is saved as C_UDMI(c,t,0 to 2) this is the results:&nbsp;&lt;br&gt;<img decoding=\"async\" src=\"https:\/\/innovationspace.ansys.com\/forum\/wp-content\/uploads\/sites\/2\/2025\/07\/04-07-2025-1751636620-mceclip5.png\" \/>&lt;br&gt;&lt;br&gt;However, it does seem that ansys is predicting a y-direction volume fraction gradient.. could this be the issue?&nbsp;&lt;br&gt;<img decoding=\"async\" src=\"https:\/\/innovationspace.ansys.com\/forum\/wp-content\/uploads\/sites\/2\/2025\/07\/04-07-2025-1751636664-mceclip6.png\" \/>&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;\/p&gt;<\/p>\n","protected":false},"template":"","class_list":["post-436101","topic","type-topic","status-publish","hentry"],"aioseo_notices":[],"acf":[],"custom_fields":[{"0":{"_bbp_forum_id":["27792"],"_bbp_topic_id":["436101"],"_bbp_subscription":["12734","62368"],"_bbp_author_ip":["217.147.184.241"],"_bbp_last_reply_id":["436928"],"_bbp_last_active_id":["436928"],"_bbp_last_active_time":["2025-07-15 16:45:51"],"_bbp_reply_count":["1"],"_bbp_reply_count_hidden":["0"],"_bbp_voice_count":["2"],"_bbp_engagement":["12734","62368"],"_btv_view_count":["179"],"_bbp_topic_status":["unanswered"]},"test":"anthony_bowersstudent-uml-edu"}],"_links":{"self":[{"href":"https:\/\/innovationspace.ansys.com\/forum\/wp-json\/wp\/v2\/topics\/436101","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\/436101\/revisions"}],"wp:attachment":[{"href":"https:\/\/innovationspace.ansys.com\/forum\/wp-json\/wp\/v2\/media?parent=436101"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}