We have an exciting announcement about badges coming in May 2025. Until then, we will temporarily stop issuing new badges for course completions and certifications. However, all completions will be recorded and fulfilled after May 2025.
Fluids

Fluids

Topics related to Fluent, CFX, Turbogrid and more.

Stop steady state iteration process from UDF

    • mardott
      Subscriber
      I am running a steady state simulation and my aim is to send the journal file with a large number of iterations and no convergence criteria to the cluster. I would like the FLUENT solver to stop the calculation once a certain value inside my UDF is met. nHow can I achieve that? (Note that this value is a variable that exists only inside the UDF)nI saw online some methods that use scheme variables and/or creating a command inside Execute commands but they do not seem to work in my case.nMaybe I'm implementing them in the wrong way, also because I have no idea how the syntax for Execute commands work nor where to look for learning it.nCould you help me?.
    • YasserSelima
      Subscriber
      HinDefine a global variable likenint my_convergence_variable=0;nThen write a function to report this variable nDEFINE_REPORT_DEFINITION_FN(my_convergence_function)n{n return my_convergence_variable;n}nThen when you need to stop inside any functionnif (condition){n my_convergence_variable=1;n}nThen. before you start simulations go to Residuals,>Convergence criteria ... Now you should find your variable in the list ... put the condition ... n
    • YasserSelima
      Subscriber
      You might need to add this variable in the report definition before you find it in the convergence criteria n
    • Keyur Kanade
      Ansys Employee
      Thank you nYou have been very helpful on many posts. nAppreciate it. nRegards,nKeyurnHow to access Ansys Online Help DocumentnHow to show full resolution imagenGuidelines on the Student CommunitynHow to use Google to search within Ansys Student Communityn
    • YasserSelima
      Subscriber
      My pleasuren
    • mardott
      Subscriber
      Arraythank you for you answer, but unfortunately when I tested your solution I see in the console Solution for report definition report-convergence has converged but the iterations go on. I would like them to stop when the report has converged.nDo you may know how I can do that?n
    • Rob
      Forum Moderator
      Have the rest of the equations converged? n
    • mardott
      Subscriber
      Arraydoes it matter? I would like the calculation to stop when I ask for it, as if I was pressing the stop button in FLUENT. nSo, in the test, the other equations did not converge but since I tried with none in the Convergence Criterion, I expected the calculation to stop only when the report definition converged.n*edit: setting absolute in the Convergence Criterion and unselecting all the check convergence ticks works.nThanks again for the help Array :)n
    • YasserSelima
      Subscriber
      You must set the criteria as only one condition converges ... this is a check box in the residuals tabn
    • Rob
      Forum Moderator
      yes as the check in Fluent is on residuals and the report, thanks for the fix. n
    • mardott
      Subscriber
      Actually I am still have issues. Maybe it depends on what I set in the Convergence Conditions box?n
    • YasserSelima
      Subscriber
      yes, it depends. In the same panel of residuals, uncheck the boxes under check convergence.nThen in the convergence conditions panel when you selected your variable, make sure to check at the bottom only one condition is met.n
    • mardott
      Subscriber
      So, I discovered what the problem was.nThe stop criterion stands for something different based on the FLUENT version one uses.nIn your version (and so the one in the file in knowledge resources:solutions of Ansys Portal) I put in stop criterion the value at which my variable has to stop. E.g. for the solution you suggested it should be 1nUnfortunately. in the version I am using (FLUENT 19 R2), the stop criterion stands for the residuals for the function, calculated as nSo, with your solution, if I put 1, my solution converges when the residuals of my function is <= 1, i.e. after 2 iterations.nI solved it by:n putting a very small number e.g. 1e-10 as stop criterionnusing the current iteration as variable in the UDF:nn
    • mardott
      Subscriber
      (as global variable) int conv;nninside a function eg. DEFINE_EXECUTE_AT_END(...):n {conv = N_ITER;n if(convergence condition meet)n conv = N_ITER -1;}nnDEFINE_REPORT_DEFINITION_FN(...)n {return conv;}n
    • YasserSelima
      Subscriber
      Glad it works and nice idea .. I did not know that this is the residual value .. thanks for sharing the idean
Viewing 14 reply threads
  • The topic ‘Stop steady state iteration process from UDF’ is closed to new replies.