Fluids

Fluids

Topics related to Fluent, CFX, Turbogrid and more.

Can anyone help me out with writing a UDF for accessing face centered values on the wall zone

    • pkgupta108
      Subscriber

      Hi! Ansys Fluent users! I am trying to write a UDF for post-processing. Here I need to access FACE values from the WALL Zone, then put them in my equation, and store that evaluated values for examining the results.

      So before I do that I wrote a piece of code (the first code below) wherein I am reading (or accessing) variables from FLUENT which are Cell-based values. Here the code is executed on demand. everything is well, and even results I can plot using Contour or xy plot.

      However, when I replace all the Cell-based data access to FACE-based, the FLUENT crashes giving errors. I have attached the same Code for FACE-based access (the second code below).

    • Surya Deb
      Ansys Employee
      Hello, nFrom the brief investigation of the UDF, I think you don't need the thread_loop_f macro. You already have the information of the thread from the Lookup_Thread macro. Why do you want to loop over all threads again? You just need to loop over all the faces in that particular thread. nPlease test it without that loop. That might fix the issue.nAlso, please check if the connectivity macros are needed although I doubt it.nYou will get more information here.nI hope this helps.nnRegards,nSuryan
    • pkgupta108
      Subscriber
      Thank you sdeb! It did work out, and the UDF is executing upon Execute-on_demand. However, I am puzzled as to why values at faces of wall boundary showing ZERO. I tried with other flow variables, such as Volume fraction, Velmag, Granular temperature, but still in all cases, the values shown after executing the UDf is simply ZERO. In fact, I even assigned a value of constant 2650 to F_UDMI, but still the values in contour plot shows zero!!!nCan you please tell me the reason for this? Here is the modified piece of code:n#include udf.hn#include mem.hn#include surf.hn#include metric.hnDEFINE_ON_DEMAND(erosionrate)n{n   real velu, velv, velw, velmag, grantemp, volfrac, afunc, bfunc, cfunc;n   real dens =2650;n   real k =0.000000002;n   int zone_ID=6; /*corresponding to the Wall_Zone_ID = 6 */n   Thread *sandthread;n   Domain *sanddomain;n   face_t faceidentifier;n   sanddomain=Get_Domain(3);  /* Corresponding to Secondary Phase Domain_ID = 3 */n   sandthread=Lookup_Thread(sanddomain,zone_ID);nn   begin_f_loop(faceidentifier,sandthread)n   if PRINCIPAL_FACE_P(faceidentifier,sandthread)n   {n       #if !RP_HOSTn       velu=F_U(faceidentifier,sandthread);n       velv=F_V(faceidentifier,sandthread);n       velw=F_W(faceidentifier,sandthread);n       velmag=sqrt(pow(velu,2)+pow(velv,2)+pow(velw,2));n       grantemp=F_GT(faceidentifier,sandthread);n       volfrac=F_VOF(faceidentifier,sandthread);n       afunc=0.1*pow(2*grantemp,1.5)/sqrt(3.14159265);n       bfunc=0.05*pow(velmag,2)*sqrt(2*grantemp/3.14159265);n       cfunc=0.09*velmag*grantemp;n       F_UDMI(faceidentifier,sandthread,0)=volfrac;n       F_UDMI(faceidentifier,sandthread,1)=velmag;n       F_UDMI(faceidentifier,sandthread,2)=grantemp;n       F_UDMI(faceidentifier,sandthread,3)=velu;n       F_UDMI(faceidentifier,sandthread,4)=velv;n       F_UDMI(faceidentifier,sandthread,5)=velw;n       F_UDMI(faceidentifier,sandthread,6)=dens;n       #endifn   }n   end_f_loop(faceidentifier,sandthread)nn}n
    • Surya Deb
      Ansys Employee
      Hello, nThe value stored in the F_UDMI cannot be checked through contour plots. Please store the F_UDMI values in the C_UDMI values in the cell next to the boundary face and check the values. You can use the connectivity macros (i shared a link earlier) for this. You should then be able to display the C_UDMI values.nnRegards,nSuryan
    • pkgupta108
      Subscriber
      Thanks Surya! Your help is deeply appreciated.nI have now developed a UDF where I am calculating some values. Now the issue is the following:nThe wall shear accessed using F_STORAGE_R_N3V shows negative values, but the same is showing positive values when wall shear stress is contour plotted for wall boundary. Why is this?n I also observed a similar thing with velocity (and its three components). When I access velocity components using F_U(c,t), it shows a very small value, almost 4-5 orders of magnitude smaller than those observed when I plot the velocity components in FLUENT using contour. Why is this difference?nPlease help me out with this. Thanks!n
Viewing 4 reply threads
  • The topic ‘Can anyone help me out with writing a UDF for accessing face centered values on the wall zone’ is closed to new replies.