Fluids

Fluids

UDF for inlet velocity

    • birbara2
      Subscriber

      I get 0 velocity inlet when using UDF

    • Nownesh
      Ansys Employee

      Hello,


      Can you check if you are accessing variables at cell or face?  You want the DEFINE_PROFILE macro that's described in the ANSYS Customisation manual. 

    • birbara2
      Subscriber

      #include "udf.h"


      DEFINE_PROFILE(inlet_velocity,thread,nv)


      {


      float position[3];


      float x,y,z;


      face_t f;


       


      begin_f_loop(f,thread)


      {


      F_CENTROID(position,f,thread);


      x= position[0];


      y=position[1];


      z=position[2];


      F_PROFILE(f,thread,nv)=0.1;


      }


      end_f_loop(f,thread)


      }



      This is my UDF. Anything wrong with it?

    • Rob
      Ansys Employee

      Have a look in the UDF manual as there's an example there. You also need to hook the UDF up to the velocity inlet after you interpret or compile it. 

    • Konstantine Kourbatski
      Ansys Employee

      Profile distribution  will not be immediately visible when post-processing the variable using either Fluent’s native post-processing or CFD-post. Post-processing functions in Fluent and CFD-post operate on flow variables stored at cell centers, and they will not show profile distribution which is applied to cell faces.


      One workaround for a profile to become visible in post-processing is to iterate the solution to a certain degree of convergence. In a converged solution, flow variables at centers of the cells adjacent to the boundary will have values close to those specified at the boundary faces, and their post-processing interpolation to the boundary will show a distribution close to that of the specified profile. This workaround may not be always practical especially for large cases when it is desirable to confirm correctness of a profile distribution before investing into converging a solution.


      In addition, since cell centered values are calculated by solving discretized flow equations, they are not exactly equal to face values, and post-processed boundary distribution will deviate slightly from its prescribe profile. This discrepancy will be negligible if the mesh next to the boundary is fine enough, but it can be noticeable on a coarser mesh.


      Another approach of displaying a profile distribution is to extract exact cell face values specified at the boundary using a user-defined function (UDF), store them into a user-defined memory (UDM) location and post-process this UDM without node value, which will yield a profile distribution exactly as it was specified. 


      Check using either of these approach a distribution of your profile

    • Raef.Kobeissi
      Subscriber

      Hi,


      Have a look at this example:


    • birbara2
      Subscriber

      This example shows using a profile type. For my case, I am compiling the UDF then using it instead of a "constant" inlet velocity

    • Karthik R
      Administrator

      Hello,


      When you compile the UDF, do you see any errors? Are you able to use the UDF being added in the drop-down list in your velocity inlet boundary condition panel? Are you able to select it and hook it to the boundary condition?


      There are UDF samples in the Fluent Customization Manual for velocity inlet boundary condition. You could try one of those to make sure UDF work on your system and that you have all the prerequisites installed for successfully compiling your UDF. 


      Thank you.


      Best Regards,


      Karthik

    • birbara2
      Subscriber

      I am able to interpret it and hook it up to the BC. I think it should be a convergence problem maybe. Is the absolute criteria for convergence always a good way to go? Continuity doesn't seem to converge to 1e-3...

    • Karthik R
      Administrator

      Hello,


      This seems to be a completely different issue. Could you please create a new post and explain what you are attempting to model? Convergence issues can be because of several reasons - incorrect boundary conditions, improper model set-up, bad initial conditions, non-linearity in model, and mesh issues. You will have to explain your model set-up and its application better.


      Creating a new post will provide your question better visibility on the community.


      Thank you.


      Best Regards,


      Karthik

    • birbara2
      Subscriber

      Ok should I close this one then? or just leave it as is?

    • birbara2
      Subscriber

      and one last question, is there any limitation on the type of functions the UDF supports? exponential , cosine, sine and so on...?

    • Karthik R
      Administrator

      Hello,


      No, there is no limitation on the type of functions you can code using UDFs. 


      About this post, it is recommended that you like useful responses and mark the most useful response that resolved your original question as 'Is Solution'. This will greatly benefit someone who has a similar question.


      Here are the Guidelines for Posting on the Community


      Hope this helps.


      Best Regards,


      Karthik


       

Viewing 12 reply threads
  • You must be logged in to reply to this topic.