Hooking UDS to the model

    • Vassili BRIODEAU

      Hello everyone,

      I have been interpreting some User-defined functions, and now I would like to use User defined scalars. Quite a lot of people use them, yet the documentation is not that clear about the steps to follow. Basically, after interpreting, when I launch the calculation, Fluent crashes and closes. I don't have time to see what kind of error it is, but I think it is written: MPI error.

      I will describe the steps I use, hoping it would help others.

      Step 1: Writing the UDF in a .c file

      /* Defining the adsoprtion of the system */ /********************************************/

      #include "udf.h"

      int ads;

      Thread*t; cell_t c; real E,A,P;
      begin_c_loop (c,t){
      real tem=C_T(c,t);

                  real e_source;
                  return e_source;

       Step 2: Interpreting the UDF

      Step 3: Adding a User Defined Scalar (UDS)

      In Flux function, I chose Adsorption, corresponding to the UDF using the UDS

      Step 4: Hooking the UDF

      I hooked adsorption as an adjust function

      Step 5: In Cell Zone condition>cross Source>Source>Energy source> Choose UDF energy_source.

      Step 6: Initializing. Everything ok (hybrid initialization)

      Step 7: Running calculation. When it comes to the first iteration, Fluent crashes. Infortunately, I don't have time to take a screenshot.

      Where does it come from? Did I forget a step or something in the programme?


    • Vassili BRIODEAU


      Small update: I compiled the function instead of interpreting it. Then while compiling, I got the following error messages

      udf_names.c(6) : error C2449: trouv? '{' au niveau de la port?e du fichier (en-t?te de fonction manquantÿ?)

      udf_names.c(18) : fatal error C1004: fin de fichier inattendue rencontr?e


      Translation to English:

      found '{' at file scope (missing function header?)

      unexpected end of file found


      I looked on the internet, the first error means I could have a semicolon after an opening bracket, the second means the end semicolon is missing, however, I see neither one nor the other error in the programme.



    • marinak


      1. Have you tried running any example from User Guide?

      2. How do you compile/attach your UDF? This is how it works for me:



      3. Why do you define ads variable outside DEFINE_ADJUST?

      4. I would try to remove almost everything and leave simple code smth like result = 1; and try to compile it.

      5. Also remove all the comments, sometimes compilator does not understand that /* initiates comment and gives errors. (In fact,i think it might be the case here)

Viewing 2 reply threads
  • You must be logged in to reply to this topic.