We’re updating our badges platform. Badge issuance is temporarily paused, but all completions are being recorded and will be fulfilled once the platform is live. Thank you for your patience.
Fluids

Fluids

Topics related to Fluent, CFX, Turbogrid and more.

How to define a periodic piecewise function for inlet velocity in UDF

    • lytsophy
      Subscriber
      Dear all,nI would like to ask how to define a periodic piecewise function for inlet velocity in UDF.nthe function can be like:nv=f(t), (n=0,1,2,...)n0.07n<=t<0.07n+0.02, v=1n0.07n+0.02<=t<0.07(n+1), v=0nthanks a lot!n
    • Rob
      Forum Moderator
      I've done this using a mix of IF statements, sin(t) and floor https://www.programiz.com/cpp-programming/library-function/cmath/floor I'll leave you to work out the maths! n
    • lytsophy
      Subscriber
      I have solved this problem already~n
    • Rob
      Forum Moderator
      Excellent. Please post the solution for others to learn from. n
    • lytsophy
      Subscriber
      Thanks a lot!nthe code could be like:n#include udf.hnDEFINE_PROFILE(inlet_velocity,th,i)n{nface_t f;nbegin_f_loop(f,th)nreal t=(CURRENT_TIME-floor(CURRENT_TIME/0.7)*0.7);n{nif(t<0.2)nF_PROFILE(f,th,i)=0.01;nelsenF_PROFILE(f,th,i)=0;n}nend_f_loop(f,th);n}n
Viewing 4 reply threads
  • The topic ‘How to define a periodic piecewise function for inlet velocity in UDF’ is closed to new replies.