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

UDF - Execute command : Trigger data sampling and time statistics

Register Blogs Members List Search Today's Posts Mark Forums Read

Like Tree4Likes
  • 1 Post By vinerm
  • 1 Post By AlexanderZ
  • 1 Post By AlexanderZ
  • 1 Post By vinerm

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   June 21, 2020, 11:58
Default UDF - Execute command : Trigger data sampling and time statistics
  #1
New Member
 
Join Date: May 2020
Posts: 23
Rep Power: 4
Bibill is on a distinguished road
Dear all,

I would like to trigger the data sampling and time statistics as soon as a pre-defined accuracy is reached for a quantity of interest in a UDF.

I guess it should be possible to do it by setting up an rp variable of boolean type and an execute command that starts the sampling as soon as rp variable becomes true and the value of rp variable can be set by UDF.

However i am not really familiar to rp variable and execute command. Is it possible to define the rp variable inside the UDF itself ?
Can anyone help me ? I would truly appreciate your help !

Thanks in advance!
Bibill is offline   Reply With Quote

Old   June 21, 2020, 17:29
Default RP-Variable
  #2
Senior Member
 
vinerm's Avatar
 
Vinerm
Join Date: Jun 2009
Location: Nederland
Posts: 2,946
Blog Entries: 1
Rep Power: 34
vinerm will become famous soon enough
Defining and setting an rp-variable is straightforward. Use the following command

(make-new-rpvar 'nameofrpvar value type)

e.g., to define a variable lcoeff with initial value 0.81, use

(make-new-rpvar 'lcoeff 0.81 'real)

To fetch its value

(rpgetvar 'lcoeff)

To set it to new value

(rpsetvar 'lcoeff 0.9)

In place of 0.81 or 0.9, you can also use other commands that return a real value. You can use conditional statement in Execute-Commands to check if the value of variable you defined is below or above a specified limit. If that matches, then sampling should be enabled. Other option is to use a boolean instead of real value.
Bibill likes this.
__________________
Regards,
Vinerm

PM to be used if and only if you do not want something to be shared publicly. PM is considered to be of the least priority.
vinerm is offline   Reply With Quote

Old   June 21, 2020, 18:18
Default
  #3
New Member
 
Join Date: May 2020
Posts: 23
Rep Power: 4
Bibill is on a distinguished road
Thank you for your answer !

And is it possible to set the rp variable value inside the UDF and not by means of the text interface ?
I know how to access the value (e.g RP_Get_Boolean) but not how to modify it...


Thanks in advance!
Bibill is offline   Reply With Quote

Old   June 21, 2020, 23:44
Default
  #4
Senior Member
 
Alexander
Join Date: Apr 2013
Posts: 2,206
Rep Power: 32
AlexanderZ will become famous soon enoughAlexanderZ will become famous soon enough
you may modify values of rpvariables from UDF

it is convenient to have separated UDF variable which you will use for any modifications and apply its' value to rpvar you need. For instance, you have created rpvariable with name my_rpvar, value False and type boolean
Code:
(make-new-rpvar 'my_rpvar #f 'boolean)
you can apply True value to your rpvar
Code:
#include "udf.h"

DEFINE_ON_DEMAND(get_boolean) 
{
cxboolean	my_udf_rpvar;
#if !RP_NODE	/* SERIAL or HOST */
my_udf_rpvar = RP_Get_Boolean("my_rpvar");
my_udf_rpvar = TRUE;
RP_Set_Boolean("my_rpvar",my_udf_rpvar);
#endif /* !RP_NODE */
}
if you are going to use parallel computation, you must define the way to send data from rpvars (which could be done on HOST node only) to "computation" parts of your code (which you want to be on computational nodes). THIS IS NOT DONE FOR THIS EXAMPLE.

More information you can find in Ansys Fluent Customization manual
Bibill likes this.
__________________
best regards


******************************
press LIKE if this message was helpful
AlexanderZ is offline   Reply With Quote

Old   June 21, 2020, 23:54
Default
  #5
New Member
 
Join Date: May 2020
Posts: 23
Rep Power: 4
Bibill is on a distinguished road
Thank you again for your great answer AlexanderZ!

A very last question if you still got time, i have tried to trigger the data sampling with the option "execute command". For that purpose, i have previously defined a rp-variable called "variable" which should help to trigger the data sampling when it becomes equal to 5:

(if (= rpgetvar 'variable 5)\n (/solve/set/data-sampling/yes 1 yes yes));

However it doesn't work, the following error message appears :

Error: eval: unbound variable

Error Object: /solve/set/data-sampling/yes

Do you have an idea of why and how to fix it ?

Thank you in advance again!
Bibill is offline   Reply With Quote

Old   June 22, 2020, 02:08
Default
  #6
Senior Member
 
Alexander
Join Date: Apr 2013
Posts: 2,206
Rep Power: 32
AlexanderZ will become famous soon enoughAlexanderZ will become famous soon enough
first of all I recommends you to use name which Fluent doesn't use definitely (which could not be a case for just "variable")
use my_variable instead

you may try
Code:
(if (= (rpgetvar 'my_variable) 5) (/solve/set/data-sampling/yes 1 yes yes) ())
or

Code:
(if (= (rpgetvar 'variable) 5) (ti-menu-load-string (format #f "/solve/set/data-sampling/yes 1 yes yes")) ())
Bibill likes this.
__________________
best regards


******************************
press LIKE if this message was helpful
AlexanderZ is offline   Reply With Quote

Old   June 22, 2020, 03:06
Default
  #7
New Member
 
Join Date: May 2020
Posts: 23
Rep Power: 4
Bibill is on a distinguished road
Thanks !! Second option was the good call!!

By chance, is there also a command to reset the data sampling once it has already been triggered ?
Bibill is offline   Reply With Quote

Old   June 22, 2020, 08:08
Default Statistics reset
  #8
Senior Member
 
vinerm's Avatar
 
Vinerm
Join Date: Jun 2009
Location: Nederland
Posts: 2,946
Blog Entries: 1
Rep Power: 34
vinerm will become famous soon enough
To reset the sampled statistics, you can use the following command

solve init init-flow-stat
Bibill likes this.
__________________
Regards,
Vinerm

PM to be used if and only if you do not want something to be shared publicly. PM is considered to be of the least priority.
vinerm is offline   Reply With Quote

Old   August 22, 2022, 02:58
Default
  #9
Member
 
sina
Join Date: Nov 2021
Posts: 41
Rep Power: 3
sina_sls is on a distinguished road
Quote:
Originally Posted by AlexanderZ View Post
first of all I recommends you to use name which Fluent doesn't use definitely (which could not be a case for just "variable")
use my_variable instead

you may try
Code:
(if (= (rpgetvar 'my_variable) 5) (/solve/set/data-sampling/yes 1 yes yes) ())
or

Code:
(if (= (rpgetvar 'variable) 5) (ti-menu-load-string (format #f "/solve/set/data-sampling/yes 1 yes yes")) ())
Hi AlexanderZ,

I want to write some text command after each iteration when fluent running , is this possible? If yes how could i do it through UDF?

Regards,
sina_sls is offline   Reply With Quote

Reply

Tags
data sampling, rp variable, udf

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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
UDF : Lift coefficient time history and Data sampling Bibill Fluent UDF and Scheme Programming 9 June 5, 2020 07:31
Disturbances in drag monitors after switching on 'Data Sampling for Time statistics' shashanktiwari619 FLUENT 4 August 27, 2017 03:34
Data sampling for time statistics in UDF 4siamak Fluent UDF and Scheme Programming 1 December 3, 2016 16:37
Data sampling for Time Statistics hillat FLUENT 0 February 7, 2015 11:04
Data sampling for time statistics with RANS Flav FLUENT 0 June 6, 2001 05:32


All times are GMT -4. The time now is 21:48.