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

RP_variable from UDF: unable to find rpvar

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   March 14, 2018, 12:13
Default RP_variable from UDF: unable to find rpvar
  #1
New Member
 
DS
Join Date: May 2016
Posts: 28
Rep Power: 10
denis.sanga@hotmail.it is on a distinguished road
Goodmorning,
I'm sorry for disturb but I've a problem to read rp_variable list in my UDF (ADJUST function).
In particular I initialize the following scheme:
Code:
(define (make-new-rpvar name default type)
(if (not (rp-var-object name))
(rp-var-define name default type #f)))

(make-new-rpvar 'a '() 'list) 
(rpsetvar 'a ()) 
(for-each (lambda (t) (rpsetvar 'a (list-add (rpgetvar 'a) (thread-id t)))) (get-all-threads)) 
(rpgetvar 'a) 
(make-new-rpvar  'b '() 'list)
(rpsetvar 'b ()) 
(rpsetvar 'b (list-add(rpgetvar 'b) "fluid-1 fluid-2"))
(rpgetvar 'b)
and in the UDF the following extract of code:
Code:
int l_a= RP_Get_List_Length("a");
printf("l_a=%d\n",l_a);
int r_a=RP_Get_List_Ref_Int("a",1);
printf("a=%d\n",r_a);
int l_b= RP_Get_List_Length("b");
printf("lunghezza_b=%d\n",l_b);
char* r_b=RP_Get_List_Ref_String("b",1);
printf("b=%s\n",r_b);
but always appear errors as follow:
6: unable to find rpvar 'a'
3: unable to find rpvar 'b'

or
7: RP_Get_List_Length: Unable to get length of a.l_a=-1:

But when in the console I write
(rpgetvar 'a) the vector of integer or strings is printed.

Can someone help me please.
Thank you very much
Best regards
Denis
denis.sanga@hotmail.it is offline   Reply With Quote

Old   March 14, 2018, 21:16
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
I've tried to compile our code and got these erros:
Code:
..\..\src\temp.c(7) : error C2143: syntax error : missing ';' before 'type'
..\..\src\temp.c(8) : error C2065: 'r_a' : undeclared identifier
..\..\src\temp.c(9) : error C2143: syntax error : missing ';' before 'type'
..\..\src\temp.c(10) : error C2065: 'l_b' : undeclared identifier
..\..\src\temp.c(11) : error C2143: syntax error : missing ';' before 'type'
..\..\src\temp.c(12) : error C2065: 'r_b' : undeclared identifier
You may use this code
Code:
#include "udf.h"

DEFINE_ADJUST(temp_adjust, d)
{
int l_a,r_a,l_b;
char* r_b;
l_a = RP_Get_List_Length("a");
Message("l_a=%d\n",l_a);
r_a=RP_Get_List_Ref_Int("a",0);
Message("a=%d\n",r_a);
l_b= RP_Get_List_Length("b");
Message("lunghezza_b=%d\n",l_b);
r_b=RP_Get_List_Ref_String("b",1);
Message("b=%s\n",r_b);
}

DEFINE_ON_DEMAND(temp_demand)
{
int l_a,r_a,l_b;
char* r_b;
l_a = RP_Get_List_Length("a");
Message("l_a=%d\n",l_a);
r_a=RP_Get_List_Ref_Int("a",0);
Message("a=%d\n",r_a);
l_b= RP_Get_List_Length("b");
Message("lunghezza_b=%d\n",l_b);
r_b=RP_Get_List_Ref_String("b",1);
Message("b=%s\n",r_b);
}
However, our variable b is defined the way, I didn't expect.
Looks like you have a list with only one element, but that element is a list of "fluid-1 fluid-2"
But you expect to have a list with two elements "fluid-1" "fluid-2"

You need to fix it in scheme, before using
Code:
r_b=RP_Get_List_Ref_String("b",1);
This is what I got in console
Code:
> (list-ref (rpgetvar 'b) 1)

Error: CAR: invalid argument [1]: wrong type [not a pair]
Error Object: ()

> (list-ref (rpgetvar 'b) 0)
fluid-1 fluid-2
best regards
AlexanderZ is offline   Reply With Quote

Old   March 16, 2018, 05:32
Default differences between C_P and F_P
  #3
New Member
 
DS
Join Date: May 2016
Posts: 28
Rep Power: 10
denis.sanga@hotmail.it is on a distinguished road
Thank you really much for your answer. Now the code works but I desire to add another question.

I would read the pressure on some walls and boundary and I post following the part of the code with which I do that in two different ways as I found online using C_P and F_P:
Code:
thread_loop_f(t,d)
{
begin_f_loop(f,t)
{
c0=F_C0(f,t);
t0=THREAD_T0(t);							
C_UDMI(c0,t0,0)=C_P(c0,t0);

F_UDMI(f,t,0)=F_P(f,t)	
}
end_f_loop(f,t)
While on the walls the value C_P(c0,t0) are the same on the inlet boundy or outlet the two quantities are different but I don't understand why (maybe for interpolation calculations).

For this reason if I interested to store the static pressure is better to write
Code:
C_UDMI(c0,t0,0)=C_P(c0,t0)
or
Code:
C_UDMI(c0,t0,0)=F_P(f,t)
?

Another question is on F_UDMI memory. I understood that C_UDMI and F_UDMI are different and they don't comunicate each other. But I don't understand how to postprocess F_UDMI quantities in Fluent or Tecplot.


Thank you really really much
Best Regards
Denis
denis.sanga@hotmail.it is offline   Reply With Quote

Reply

Tags
udf rp variables


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
mpirun unable to find SU2_PRT Apollinaris SU2 Installation 1 May 10, 2017 05:31
Unable to find solver in Compressible case rhoDyMCentralFoam openFOAM 2.3.1 Version amolkumar OpenFOAM 0 March 3, 2015 05:27
Unable to find solver sonicDyMFoam in OpenFoam2.3.1 ashisha OpenFOAM 0 March 3, 2015 05:00
Help! where to find full UDF Macros and functions kim FLUENT 6 March 5, 2014 09:01
OpenFOAM 1.6-ext git installation on Ubuntu 11.10 x64 Attesz OpenFOAM Installation 45 January 13, 2012 12:38


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