|
[Sponsors] |
UDF - Execute command : Trigger data sampling and time statistics |
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
June 21, 2020, 11:58 |
UDF - Execute command : Trigger data sampling and time statistics
|
#1 |
New Member
Join Date: May 2020
Posts: 23
Rep Power: 6 |
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! |
|
June 21, 2020, 17:29 |
RP-Variable
|
#2 |
Senior Member
|
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.
__________________
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. |
|
June 21, 2020, 18:18 |
|
#3 |
New Member
Join Date: May 2020
Posts: 23
Rep Power: 6 |
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! |
|
June 21, 2020, 23:44 |
|
#4 |
Senior Member
Alexander
Join Date: Apr 2013
Posts: 2,363
Rep Power: 34 |
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) 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 */ } More information you can find in Ansys Fluent Customization manual
__________________
best regards ****************************** press LIKE if this message was helpful |
|
June 21, 2020, 23:54 |
|
#5 |
New Member
Join Date: May 2020
Posts: 23
Rep Power: 6 |
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! |
|
June 22, 2020, 02:08 |
|
#6 |
Senior Member
Alexander
Join Date: Apr 2013
Posts: 2,363
Rep Power: 34 |
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) ()) Code:
(if (= (rpgetvar 'variable) 5) (ti-menu-load-string (format #f "/solve/set/data-sampling/yes 1 yes yes")) ())
__________________
best regards ****************************** press LIKE if this message was helpful |
|
June 22, 2020, 03:06 |
|
#7 |
New Member
Join Date: May 2020
Posts: 23
Rep Power: 6 |
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 ? |
|
June 22, 2020, 08:08 |
Statistics reset
|
#8 |
Senior Member
|
To reset the sampled statistics, you can use the following command
solve init init-flow-stat
__________________
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. |
|
August 22, 2022, 02:58 |
|
#9 | |
Member
sina
Join Date: Nov 2021
Posts: 41
Rep Power: 5 |
Quote:
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, |
||
Tags |
data sampling, rp variable, udf |
|
|
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 |