CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Software User Forums > ANSYS > FLUENT

Call udf some Iterations

Register Blogs Community New Posts Updated Threads Search

Like Tree2Likes
  • 1 Post By Bruno Machado
  • 1 Post By Kokemoor

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   September 16, 2015, 05:37
Question Call udf some Iterations
  #1
Member
 
Eduardo Tola
Join Date: Aug 2015
Location: Madrid/Haifa
Posts: 50
Rep Power: 11
edu_aero is on a distinguished road
Hello to everyone!!

I would love to know if there is someone who knows how to call a udf every some iterations (compiled udf), for example 5, instead of every iteration.

In order to not waste computer power, I want to call the function every 'X' iterations and no call every iteration and if a condition is reached then run the function.

Thank you very much
__________________
Having fun with CFD =)
edu_aero is offline   Reply With Quote

Old   September 16, 2015, 06:43
Default
  #2
Senior Member
 
Bruno Machado
Join Date: May 2014
Posts: 271
Rep Power: 13
Bruno Machado is on a distinguished road
what do you want to do? What you can do is add a counter base on the iteration and put it in an if statement.
Bruno Machado is offline   Reply With Quote

Old   September 16, 2015, 08:05
Default
  #3
Member
 
Eduardo Tola
Join Date: Aug 2015
Location: Madrid/Haifa
Posts: 50
Rep Power: 11
edu_aero is on a distinguished road
Quote:
Originally Posted by Bruno Machado View Post
what do you want to do? What you can do is add a counter base on the iteration and put it in an if statement.
I want to do it in order to calculate some variables related with DPM model, so I just want to calculate after every injection. There is no point of calculation more than one time after a ijnection because the values are the same ones.

Thank you =)
__________________
Having fun with CFD =)
edu_aero is offline   Reply With Quote

Old   September 16, 2015, 08:13
Default
  #4
Senior Member
 
Bruno Machado
Join Date: May 2014
Posts: 271
Rep Power: 13
Bruno Machado is on a distinguished road
so in that case you can add one counter

static int counter = 0.0;

if (counter <5)
{
do nothing for example
counter += 1.0;
}
else if (counter = 5)
{
do whatever you want;
counter = 0.0;
}


You can do something like this in your execute at the end or adjust macro.
edu_aero likes this.
Bruno Machado is offline   Reply With Quote

Old   September 16, 2015, 08:50
Default
  #5
Member
 
Eduardo Tola
Join Date: Aug 2015
Location: Madrid/Haifa
Posts: 50
Rep Power: 11
edu_aero is on a distinguished road
Quote:
Originally Posted by Bruno Machado View Post
so in that case you can add one counter

static int counter = 0.0;

if (counter <5)
{
do nothing for example
counter += 1.0;
}
else if (counter = 5)
{
do whatever you want;
counter = 0.0;
}


You can do something like this in your execute at the end or adjust macro.
But by doing something like this, the variable will get initialized as zero every time that I run the the code in this case with a DEFINE_ADJUST code every iteration, am I not right?
__________________
Having fun with CFD =)
edu_aero is offline   Reply With Quote

Old   September 16, 2015, 08:56
Default
  #6
Senior Member
 
Bruno Machado
Join Date: May 2014
Posts: 271
Rep Power: 13
Bruno Machado is on a distinguished road
when the variable reaches 5 (for example), it will execute something and the variable returns to 0. from iterations 1 to 4 it wont do anything. I do not know how to code to do this only every X iterations, but you can say to do nothing in intervals. Not sure if I made myself clear.
Bruno Machado is offline   Reply With Quote

Old   September 16, 2015, 09:09
Talking
  #7
Member
 
Eduardo Tola
Join Date: Aug 2015
Location: Madrid/Haifa
Posts: 50
Rep Power: 11
edu_aero is on a distinguished road
Quote:
Originally Posted by Bruno Machado View Post
when the variable reaches 5 (for example), it will execute something and the variable returns to 0. from iterations 1 to 4 it wont do anything. I do not know how to code to do this only every X iterations, but you can say to do nothing in intervals. Not sure if I made myself clear.
Thank you very much, I didn't know about the use of static, what was exactly what I needed
__________________
Having fun with CFD =)
edu_aero is offline   Reply With Quote

Old   September 16, 2015, 12:18
Default
  #8
Senior Member
 
Andrew Kokemoor
Join Date: Aug 2013
Posts: 122
Rep Power: 14
Kokemoor is on a distinguished road
Bruno's answer is probably easier to implement, but I'll put out an alternative option, just in case.

Under Calculation Activities, you can run some scheme code every X iterations or timesteps. If you have an on-demand UDF, you can call it with
Code:
(%udf-on-demand "udfname::libudf")
pat-cfd likes this.
Kokemoor is offline   Reply With Quote

Old   September 14, 2017, 13:48
Default
  #9
Senior Member
 
Astio Lamar
Join Date: May 2012
Location: Pipe
Posts: 186
Rep Power: 14
asal is on a distinguished road
Quote:
Originally Posted by Bruno Machado View Post
so in that case you can add one counter

static int counter = 0.0;

if (counter <5)
{
do nothing for example
counter += 1.0;
}
else if (counter = 5)
{
do whatever you want;
counter = 0.0;
}


You can do something like this in your execute at the end or adjust macro.
Hello!

I have the same issue and want to use this method to call the UDF every certain iteration.
If I understand correctly, this code needs to be compiled rather than interpret.
However, when I interpret, I got "Parse error"

In another try, I have successfully compiled the UDF, but cannot load it due to the following error:

Code:
Error: The UDF library you are trying to load (libudf) is not compiled for
 parallel use on the current platform (win64).
\n\nThe system cannot find the file specified.
\n\nC:\...\libudf\win64\3ddp_host\libudf.dll
Error Object: #f
Any advice to fix this error would much appritiated.
Thanks.
asal is offline   Reply With Quote

Reply

Tags
compiled, dpm, fluent, iteration, udf


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Problem with chtMultiregionFoam radiation boundary condition baran_foam OpenFOAM Running, Solving & CFD 10 December 17, 2019 18:36
High Courant Number @ icoFoam Artex85 OpenFOAM Running, Solving & CFD 11 February 16, 2017 14:40
Wrong fluctuation of pressure in transient simulation caitao OpenFOAM Running, Solving & CFD 2 March 5, 2015 22:33
Moving mesh Niklas Wikstrom (Wikstrom) OpenFOAM Running, Solving & CFD 122 June 15, 2014 07:20
pisoFoam with k-epsilon turb blows up - Some questions Heroic OpenFOAM Running, Solving & CFD 26 December 17, 2012 04:34


All times are GMT -4. The time now is 07:56.