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

RP_Set_List_of_Integer

Register Blogs Members List Search Today's Posts Mark Forums Read

Reply
 
LinkBack Thread Tools Display Modes
Old   December 2, 2009, 11:41
Exclamation RP_Set_List_of_Integer
  #1
Senior Member
 
Illya Shevchuk
Join Date: Aug 2009
Location: Darmstadt, Germany
Posts: 174
Rep Power: 8
linch is on a distinguished road
Hi everyone,

I have a problem with using RP_Set_List_of_Integer macro. Does somebody know how does it work?

For example I define a global variable <testlist> in the Fluent text interface or in a scheme file first:
(rp-var-define 'testlist '() 'integer-list #f)

Next I write a simple UDF to test the macro:

Code:
DEFINE_ON_DEMAND(demand_test_list_set)
{
int a=10, b=20, c=30;

    RP_Set_List_of_Integer("testlist", &a, 1);
    RP_Set_List_of_Integer("testlist", &b, 2);
    RP_Set_List_of_Integer("testlist", &c, 3);

    Message("Length of the list: %i\n",RP_Get_List_Length("testlist"));
    Message("1st element of the list: %i\n",RP_Get_List_Ref_Int("testlist",0));
    Message("2nd element of the list: %i\n",RP_Get_List_Ref_Int("testlist",1));
    Message("3rd element of the list: %i\n",RP_Get_List_Ref_Int("testlist",2));
}
It works almost perfectly, with an only exception, that fluent returns the elements in an inverse order:
Code:
Length of the list: 3
1st element of the list: 30
2nd element of the list: 20
3rd element of the list: 10
It's a kind of strange, but I can live with it.

But if I pass the &a-pointer twice (a.e. if I want the third element of the list to be the same as the 1st):
Code:
    RP_Set_List_of_Integer("testlist", &a, 1);
    RP_Set_List_of_Integer("testlist", &b, 2);
    RP_Set_List_of_Integer("testlist", &a, 3);
it doesn't work properly. What I get is:
Code:
1st element of the list: 10
2nd element of the list: -1213829304
3rd element of the list: -1214887304
Why? What's the problem?

I went on trying and it seems not to work with arrays also:
Code:
int d[3];
    d[0]=10;
    d[1]=20;
    d[2]=30;

    RP_Set_List_of_Integer("testlist", d, 1);
    RP_Set_List_of_Integer("testlist", (d+1), 2);
    RP_Set_List_of_Integer("testlist", (d+2), 3);
The result looks similar to the previous example.

Can somebody please help me and tell me, how to use the RP_Set_List_of_Integer macro properly?

I need to store some arrays globally and as I want to do it anytime I want, I can not use the DEFINE_RW_FILE macro. So, the only way I see is to store them as RP-variables.

I would be grateful if you had some advices for me.
linch is offline   Reply With Quote

Reply

Thread Tools
Display Modes

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 On
Pingbacks are On
Refbacks are On



All times are GMT -4. The time now is 09:11.