32.3. Using User-Defined Functions

The steps for implementing a UDF in Ansys Polyflow are provided here. Note that you should also perform all other steps needed to correctly define your model before running Ansys Polyflow.

  1. Write your UDF. See Writing User-Defined Functions for information on writing UDFs.

  2. Declare the dependency in Ansys Polydata.

    1. In Ansys Polydata, select the parameter or boundary condition you want to have described by your UDF. For instance, if you want density to be related to temperature in a way described by your UDF, select Density in the Material data menu. If you want to impose the normal velocity as a function of coordinates, select Normal and tangential velocities imposed or Normal velocity and tangential force imposed in the Flow boundary conditions menu.

    2. For parameters, if your UDF is a function of various fields, click the PMAT button at the top of the menu.

      For boundary conditions, if your UDF is a function of various fields, select the User-defined function option in the menu where Constant and Linear function of coordinates are located.

      For both parameters and boundary conditions, if your UDF is a function of the evolution parameter , click EVOL.

    3. Define this parameter to be a constant times the value given by your UDF. Select the appropriate menu item to modify the parameter value (for example, Modification of density) and enter the value of this constant.

    4. If you are using the PMAT option:

      1. In the Functional Dependence of... menu, select User-defined function

          User-defined function

        and then Create a new function.

          Create a new function

        You will see a function f1(...) listed in the menu.

      2. Select f1(...) and enter the appropriate information in the User-defined function menu.

        1. Enter the name of your UDF.

            Modify function name

        2. Enter the number of fields that your UDF uses.

            Modify nb. of fields

          Initially, all fields (listed X1, X2,...) are defined to be the X-coordinate value.

        3. Redefine each field by selecting it and then choosing the appropriate new field from the list of choices. Information about the choices is provided at the end of this section.

      If you are using a UDF for a boundary condition:

      1. In the menu for the appropriate component of the field (for example, normal velocity), select User-defined function.

          User-defined function

      2. In the resulting User-defined function menu, specify the name of your UDF.

          Modify function name

      3. Next, specify the number of fields that your UDF uses.

          Modify nb. of fields

        The menu will expand to show an item for each field. Initially, all fields (X1, X2, and so on) are defined to be the -coordinate value.

      4. Specify each field by selecting it and choosing the appropriate new field from the list of choices.

      If you are using the EVOL option:

      1. In the S-Dependence of ... menu, select f(S) = User-defined function.

          f(S) = User-defined function

      2. When prompted, enter the UDFid. This is an integer between 1 and 1000 that should correspond to the name of your UDF. That is, your UDF’s name should be UDF ID where ID is this integer.


      Important:  Note that at this stage, Ansys Polydata is unable to verify that this function has indeed been defined and that the number of arguments is correct; those errors, if they occur, will be reported during the execution of Ansys Polyflow.


  3. Execute Ansys Polyflow with the -f option:

    polyflow -f udf-file < data-file

    where udf-file is the file containing your UDF and data-file is the data file containing the problem definition.

    If a CLIPS error is detected in your function definition, CLIPS will report this at the start of the Ansys Polyflow execution. If the function name used in Ansys Polydata cannot be found in your UDF file, or if the number of arguments is incorrect, an error will be reported in the SOLVER section of the listing file (described in Writing an Ansys Polyflow Listing File).