Ansys Employee
All UDFs can be called as standard functions.nJust use the name, which is always the first parameter, as the function name.nDEFINE_ON_DEMAND(my_on_demand)n{n ...n}nnDEFINE_ADJUST(my_adjust, domain)n{n my_on_demand(); /* Call ON_DEMAND from inside ADJUST */n}nnSource UDFs may be tricky if you are using the ds[eqn] for linearisation but if not, could be called the same way.nDEFINE_SOURCE(my_mass_src,c,ct,ds,eqn)n{n ...n return mass_source;n}nnDEFINE_SOURCE(my_heat_src,c,ct,ds,eqn)n{n return my_mass_src(c,ct,ds,0)*temp*Cp; /* Note eqn is not the same so don't use it */n}nnBut using an ADJUST UDF to set sources into UDMs is usually neater and often saves computational time, especially in transient flows where the sources may be constant over the timestep.nnThen use:n/* Define constant for UDMs this way : */nn#define MASS_SRC 0n#define HEAT_SRC 1nn/* or with an enumeration: */nenumn{n MASS_SRC,n HEAT_SRCn};?nnDEFINE_SOURCE(my_mass_src,c,ct,ds,eqn)?n{n return C_UDMI(c,ct,MASS_SRC); /* C_UDMI(c,ct,MASS_SRC) is set in an ADJUST UDF */n}nn