Looking for a solution?

Where there's a problem there's a solution

  • How to access species index for a particular specie in the UDF based on specie name?

  • To write a generic udf that does not depend on the order in which species are specified in the mixture definition, it is needed to access the species index, i by passing the specie name as argument. How to do that in the UDF?
    There are two ways of doing this in Fluent UDF.
    1. To use mixture_specie_index macro. A snippet of code pasted below will get species index for specie co2
    Material *m = THREAD_MATERIAL(t);
    char *name = "co2";
    int i;
    i = mixture_specie_index(m,name);

    2. Alternately, following macro can also be used
    i = SV_SpeciesIndex("co2");

    With option 2, if co2 is not present in the defined meixture, Fluent will give seg violation and will cause error. With option 2, it will return -1 if co2 is not defined as part of mixture species and hence appropriate care can be taken in the udf coding to give relevent error messages etc.

  • Show Form
    No comments yet. Be the first to add a comment!