|
[Sponsors] |
Can UDF obtain a variable value in real-time from the nth and (n-1) iteration steps |
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
April 8, 2023, 08:34 |
Can UDF obtain a variable value in real-time from the nth and (n-1) iteration steps
|
#1 |
Senior Member
Join Date: Feb 2020
Posts: 114
Rep Power: 6 |
Can UDF achieve the following function: monitor the minimum value of a physical quantity, obtain its values at the nth and (n-1)th iteration steps, and when the difference approaches zero, switch a boundary condition mounted with a UDF, such as replacing DEFINE_PROFILE(uright0,f_thread,position) with another DEFINE_PROFILE(uright1,f_thread,position). or maybe scheme can achieve it?
|
|
April 8, 2023, 13:16 |
|
#2 | |
Member
Odisha
Join Date: Jan 2020
Posts: 59
Rep Power: 6 |
Quote:
Firstly, write a UDF that calculates the difference between the nth and (n-1)th iteration. Simultaneously, define an RP variable in the console (check this page). Now, when the difference approaches zero, change the value of this RP variable via your first UDF. (using "RP_set_integer"). Now, you can write a second UDF (a DEFINE_PROFILE UDF) with a switch case statement. At some nth iteration, when the RP variable will change its value, it will be detected by the 2nd UDF. And from that iteration onwards, it will switch the boundary condition (using the switch-case statement). |
||
April 8, 2023, 22:12 |
|
#3 | |
Senior Member
Join Date: Feb 2020
Posts: 114
Rep Power: 6 |
Quote:
|
||
April 10, 2023, 03:21 |
|
#4 |
Member
Odisha
Join Date: Jan 2020
Posts: 59
Rep Power: 6 |
Hi. You can use an array (or even pointers) to store the values at each iteration using the in-built macro N_ITER.
|
|
April 10, 2023, 09:57 |
|
#5 |
Senior Member
Join Date: Feb 2020
Posts: 114
Rep Power: 6 |
Hi, can you give me a simple example for how to use it? I'm not sure what do you mean. N_ITER is just a number, how can it be used to monitor the current step and the previous step in real-time?
|
|
April 11, 2023, 16:16 |
|
#6 | |
Member
Odisha
Join Date: Jan 2020
Posts: 59
Rep Power: 6 |
Quote:
Code:
int A[100]; if (N_ITER == 1) A[N_ITER] = C_T(c,t); // assuming you are working with temperature. if (N_ITER > 1) { A[N_ITER] = C_T(c,t); diff = A[N_ITER] - A[N_ITER - 1]; if ('diff' satisfies the tolerance) RP_Set_Integer ("rp-variable", 1); } |
||
April 13, 2023, 00:28 |
|
#7 | ||
Senior Member
Join Date: Feb 2020
Posts: 114
Rep Power: 6 |
Quote:
Quote:
|
|||
Tags |
iteration steps, scheme, udf |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
batch command to run fluent from nth time step | solomon | FLUENT | 13 | August 25, 2015 21:05 |