|
[Sponsors] |
January 2, 2023, 11:38 |
Reading a udf variable value in TUI
|
#1 |
Member
Nick
Join Date: Feb 2012
Posts: 33
Rep Power: 14 |
Hi there!
I'm trying to get the value of a variable from UDF in TUI. For this, I defined the variable in TUI: (rp-var-define 'test_demand 0 'real #f) I also initialized the domain with temperature = 300 K I compiled the UDF: #include "udf.h" DEFINE_ON_DEMAND(demand_test) { Domain *d; real tx = 1; Thread *t; cell_t c; d = Get_Domain(1); thread_loop_c(t,d) { begin_c_loop(c,t) { tx = C_T(c,t); /* get cell temperature */ } end_c_loop(c,t) } Message ("Test demand = %f\n",tx); RP_Set_Real("test_demand",tx); } Using rpgetvar, I expect to receive the value 300, as the message also displays: Test demand = 1.000000 Test demand = 300.000000 Instead, I receive the value of 1, with which the tx variable was set at the beginning of the code: > (rpgetvar 'test_demand) 1 Can you tell me where I am wrong? How could I get the current value of the tx variable? Thanx! |
|
January 19, 2023, 04:10 |
|
#2 |
Senior Member
Alexander
Join Date: Apr 2013
Posts: 2,363
Rep Power: 34 |
Code:
(%rpgetvar 'test_demand) howver, tx would contain the temperature value of the LAST cell in the loop
__________________
best regards ****************************** press LIKE if this message was helpful |
|
January 21, 2023, 08:54 |
|
#3 | |
Member
Nick
Join Date: Feb 2012
Posts: 33
Rep Power: 14 |
Quote:
I still get the same value, even using %rpgetvar: > (rp-var-define 'test_demand 0 'real #f) test_demand ;; Execute Define_on_demand, after the domain was initialized > Test demand = 1.000000 Test demand = 325.000000 ;; Try to get the variable's value > (%rpgetvar 'test_demand) 1 I know that tx would contain the temperature value of the last cell in the loop (the entire domain was initialized with 325 K), but I'm testing the intercommunication between Fluent macros and Scheme. |
||
February 4, 2023, 11:55 |
|
#4 |
Senior Member
Alexander
Join Date: Apr 2013
Posts: 2,363
Rep Power: 34 |
you should send rpvar from host
Code:
RP_Set_Real("test_demand",tx); read ansys fluent customization manual to check how to define rpvar in scheme code in other way
__________________
best regards ****************************** press LIKE if this message was helpful |
|
February 5, 2023, 08:41 |
|
#5 |
Member
Nick
Join Date: Feb 2012
Posts: 33
Rep Power: 14 |
Thank you, Alexander!
|
|
Tags |
exchange variable, scheme, tui, udf |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
[Commercial meshers] Problem converting fluent mesh | vinz | OpenFOAM Meshing & Mesh Conversion | 28 | October 12, 2015 07:37 |
Possible Bug in pimpleFoam (or createPatch) (or fluent3DMeshToFoam) | cfdonline2mohsen | OpenFOAM | 3 | October 21, 2013 10:28 |
emag beta feature: charge density | charlotte | CFX | 4 | March 22, 2011 10:14 |
error in COMSOL:'ERROR:6164 Duplicate Variable' | bhushas | COMSOL | 1 | May 30, 2008 05:35 |
UDF reading species data of pdf simulations | Jamiro | FLUENT | 0 | June 20, 2001 18:15 |