CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   Fluent UDF and Scheme Programming (https://www.cfd-online.com/Forums/fluent-udf/)
-   -   RP_Set_Integer does not work in parallel (https://www.cfd-online.com/Forums/fluent-udf/138390-rp_set_integer-does-not-work-parallel.html)

86lolo July 3, 2014 06:14

RP_Set_Integer does not work in parallel
 
Hello everyone.
I have some code where I need to change a RP variable from an UDF ON_DEMAND. I need the macro RP_Set_Integer. Well, it does not work in parallel, even protecting it with the #if !RP directives. I have tried it on Fluent 14.5.0, both in Windows and in Linux.

What I say can be tried without a mesh or case files. Just start Fluent, compile and load the following UDF:
Code:

#include "udf.h"
#include "prf.h"
#include "para.h"

DEFINE_ON_DEMAND(actualize_rp)
{
        #if !RP_NODE
        RP_Set_Integer("myrpvar",30);
        #endif
}

This on_demand will set a RP variable to 30. Now, you can run these simple commands and see the output:
Code:

(rp-var-define 'myrpvar -10 'integer #f)
(rpgetvar 'myrpvar)
/define/ud/eod  "actualize_rp::libudf"
(rpgetvar 'myrpvar)

I obtained the following console outputs:
Code:

[Output in serial]
> (rp-var-define 'myrpvar -10 'integer #f)
myrpvar
> (rpgetvar 'myrpvar)
-10
> /define/ud/eod  "actualize_rp::libudf"
> (rpgetvar 'myrpvar)
-30

[Output in parallel]
> (rp-var-define 'myrpvar -10 'integer #f)
myrpvar
> (rpgetvar 'myrpvar)
-10
> /define/ud/eod  "actualize_rp::libudf"
> (rpgetvar 'myrpvar)
-10

Clearly, in parallel the RP_Set_Integer does not do its work. I have tried multiple combinations of #if !RP directives (even not including them at all) with no result. Has anyone here worked with this macro in parallel? Hot to make it work? I am quite puzzled since I think I am using right the #if !RP_NODE.
In other thread similar problem has been reported:http://www.cfd-online.com/Forums/flu...able-name.html; but I think that this does not help me because I am struggling just with the host, the nodes do not play at all.

The ultimate target of this is that I need to perform time-step iterations until the flow reaches a certain condition. For that, I have an scheme do-loop in which:
-iterate 25 more time steps
-execute an on_demand function, which will check if the condition I need is met: if so, it will set variable rp_end_loop to 1
-if rp_end_loop is 1, end loop; else, repeat steps.
My on_demand function evaluates properly the conditions to be met (with function Message, information is displayed in console and it is stated when the loop should end), but this loop will never end because it fails to actualize the rp variable!!!

I comment this in case someone can think of any other way of passing information from an UDF to scheme console (in any form which could be evaluated as a boolean, rp variable, scheme variable, whatever). If someone does not know how to make this RP_Set_Integer work, but knows some another workaround for my problem, I'd be extremely grateful.

Help please!!! I really need this, I can't continue my work until I solve this... and serial calculation is not affordable.

Thanks in advance

coglione July 3, 2014 08:07

Hello Manuel,

welcome into the strange world of Fluent's scheme environment.
Don't ask me why, but using
(%rpgetvar 'myrpvar) will do the trick.

cheers

86lolo July 3, 2014 11:37

Enormous thanks, coglione.

I could continue. That trick solved the issue in the UDF I have posted. However, I realized that in my code it wasn't working. I then realize that apparently, every fluent/scheme command in a "do loop" should be introduced as (ti-load-menu-string "command"). Sounds ridiculous. I really find lisp/scheme so unfriendly and tedious...

But, I repeat again, thanks a lot! I could continue thanks to you :D


All times are GMT -4. The time now is 00:16.