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

Reading a udf variable value in TUI

Register Blogs Community New Posts Updated Threads Search

Like Tree1Likes
  • 1 Post By AlexanderZ

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   January 2, 2023, 11:38
Question Reading a udf variable value in TUI
  #1
Member
 
Nick
Join Date: Feb 2012
Posts: 33
Rep Power: 14
valahian1 is on a distinguished road
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!
valahian1 is offline   Reply With Quote

Old   January 19, 2023, 04:10
Default
  #2
Senior Member
 
Alexander
Join Date: Apr 2013
Posts: 2,363
Rep Power: 34
AlexanderZ will become famous soon enoughAlexanderZ will become famous soon enough
Code:
(%rpgetvar 'test_demand)
you will recieve updated value of tx variable

howver, tx would contain the temperature value of the LAST cell in the loop
__________________
best regards


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

Old   January 21, 2023, 08:54
Default
  #3
Member
 
Nick
Join Date: Feb 2012
Posts: 33
Rep Power: 14
valahian1 is on a distinguished road
Quote:
Originally Posted by AlexanderZ View Post
Code:
(%rpgetvar 'test_demand)
you will recieve updated value of tx variable

howver, tx would contain the temperature value of the LAST cell in the loop
Hello Alexander and thank you for your response!

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.
valahian1 is offline   Reply With Quote

Old   February 4, 2023, 11:55
Default
  #4
Senior Member
 
Alexander
Join Date: Apr 2013
Posts: 2,363
Rep Power: 34
AlexanderZ will become famous soon enoughAlexanderZ will become famous soon enough
you should send rpvar from host
Code:
RP_Set_Real("test_demand",tx);
that could be a problem

read ansys fluent customization manual to check how to define rpvar in scheme code in other way
valahian1 likes this.
__________________
best regards


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

Old   February 5, 2023, 08:41
Default
  #5
Member
 
Nick
Join Date: Feb 2012
Posts: 33
Rep Power: 14
valahian1 is on a distinguished road
Thank you, Alexander!
valahian1 is offline   Reply With Quote

Reply

Tags
exchange variable, scheme, tui, 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
[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


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