|
[Sponsors] |
March 14, 2018, 13:13 |
RP_variable from UDF: unable to find rpvar
|
#1 |
New Member
DS
Join Date: May 2016
Posts: 28
Rep Power: 10 |
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) 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); 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 |
|
March 14, 2018, 22:16 |
|
#2 |
Senior Member
Alexander
Join Date: Apr 2013
Posts: 2,363
Rep Power: 34 |
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 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); } 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); 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 |
|
March 16, 2018, 06:32 |
differences between C_P and F_P
|
#3 |
New Member
DS
Join Date: May 2016
Posts: 28
Rep Power: 10 |
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) 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) 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 |
|
Tags |
udf rp variables |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
mpirun unable to find SU2_PRT | Apollinaris | SU2 Installation | 1 | May 10, 2017 06:31 |
Unable to find solver in Compressible case rhoDyMCentralFoam openFOAM 2.3.1 Version | amolkumar | OpenFOAM | 0 | March 3, 2015 06:27 |
Unable to find solver sonicDyMFoam in OpenFoam2.3.1 | ashisha | OpenFOAM | 0 | March 3, 2015 06:00 |
Help! where to find full UDF Macros and functions | kim | FLUENT | 6 | March 5, 2014 10:01 |
OpenFOAM 1.6-ext git installation on Ubuntu 11.10 x64 | Attesz | OpenFOAM Installation | 45 | January 13, 2012 13:38 |