I am trying to write an Energy source term UDF code to attach to a part of my model. Is there any method to specify the location of this zone in my UDF using the rectangular coordinates?
Maybe you would like to consider using the newly introduced expression language in Fluent for the formulation of your energy source term? In that case you could use step() functions in order to constrain the energy source term from being zero/non-zero just based on spatial coordinates.
Thomas Frank , I kind of found the FLUENT expression thing really impressive. I have also been wondering if it is ever possible to write more expansive expressions like the one attached below?
Victor S. Olawoore Depends on the overall range of variable i. In expression language there are no DO or FOR Loops available. But IF-THEN-ELSE is possible. So for a limited number range of it should be possible to write this as an expression. If is ranging in the order of 10-100 or more, than better to write this as an UDF.
1) Use user defined memory to distinguish this zone from other zones (for example, every cells in this zone would have UDMI(c,t,0) = 1). You can mark and patch this value in FLUENT easily. Then write a UDF for the source term:
if (C_UDMI(c,t,0) == 1) source = ;
else source = 0.;
2) Use coordinates as the condition for if-else . You use C_CENTROID(c,t) to get x,y,z coordinates of a cell.
DEFINE_SOURCE(name,c,t,dS,eqn)
{
real xc[ND_ND];
real source;
C_CENTROID(xc,c,t); /* xc[0] is x-coordinate, [1] y-coordinate, [2] z-coordinate