How to execute scheme commands by UDF

Options
Valérie Gelbgras
Valérie Gelbgras Member, Employee Posts: 157
Name Dropper First Comment Photogenic First Anniversary
edited June 2023 in Fluids

How to execute scheme commands by UDF

Tagged:

Answers

  • Valérie Gelbgras
    Valérie Gelbgras Member, Employee Posts: 157
    Name Dropper First Comment Photogenic First Anniversary
    Answer ✓
    Options

    In the Fluent console, we can define a variable which contains the scheme command to execute. The value of this variable can be updated by UDF. Then the command can be applied with a calculation activity.

    To define the variable, type the following command in the Fluent console. In the example below, the variable is called 'mycommand'.

    (rp-var-define 'mycommand "" 'string #f)

    The value of the variable can be updated by UDF with the macro RP_Set_String. In the example below, the value of the variable is set to "/solve/set/time-step 2.5".

    #include "udf.h"
    DEFINE_ON_DEMAND(update_mycommand)
    {
        RP_Set_String("mycommand", "/solve/set/time-step 2.5");
        Message0("\n\n UDF DONE \n\n");
    }
    

    In the calculation activities, we can define an execute command with the command below.

    (ti-menu-load-string (%rpgetvar 'mycommand))