- **FLUENT**
(*http://www.cfd-online.com/Forums/fluent/*)

- - **UDF - source terms
**
(*http://www.cfd-online.com/Forums/fluent/38162-udf-source-terms.html*)

UDF - source terms
Dear fluent users, My problem is application of source terms to a zone(s) inside a fluid domain.Here i want to know how to extract the nodal coordinates of the domain and using this x,y,z values of the complete domain, few no.of cells need to be selected to apply source terms. I have tried the following way but could not get it.
#include <"udf.h"> DEFINE_SOURCE(mom_source,c,t,dS,eqn) { Node *node; x = NODE_X(node); y = NODE_Y(node); real source,x,y; if (x<=0 && x>=10 ..........) */to pick the cells in the domain for the application of source terms*/ { source = 100; dS[eqn]= 0; } else source = 0; dS[eqn]= 0; } return source; } How to solve this problem of extracting the coordinates of the domain.Any suggestions are appreciated. In STAR-cd directly you can access the nodal cordinates by X,Y and Z varaibles through user coding.In fluent i find UDFs are not that user friendly as other softwares. Thanks in Advance. Fred |

Re: UDF - source terms
To access node values you will first have to loop over all cell nodes using c_node_loop macro. You could also use the cell center coordinates instead of all those node values wich is imho the better option.
RoM #include "udf.h" DEFINE_SOURCE(mom_source,c,t,dS,eqn) { real source,x,y; int n; Node *node; c_node_loop(c,t,n) /* loop over all cell nodes */ { node=C_NODE(c,t,n); x = NODE_X(node); y = NODE_Y(node); if (x<=0 && x>=10) /*to pick the cells in the domain for the application of source terms*/ { source = 100.0; dS[eqn]= 0.0; } else { source = 0.0; dS[eqn]= 0.0; } } return source; } /* better */ DEFINE_SOURCE(mom_source,c,t,dS,eqn) { real source,x[2]; C_CENTROID(x,c,t); /* store cell center coordinates in vector x : x[0]=x , x[1]=y */ if (x[0]<=0 && x[0]>=10) /*to pick the cells in the domain for the application of source terms*/ { source = 100.0; dS[eqn]= 0.0; } else { source = 0.0; dS[eqn]= 0.0; } return source; } |

Re: UDF - source terms
Fred
For instance, you can make the procedure following: If your equation is S = - 0.5 * A * B * u * u * ui Where A and B are constants, u is the velocity vector and ui is the velocity component. You can write the following UDF: DEFINE_SOURCE(x_mom, c, t, dS, eqn) { real con, source; real x; real y; con =0.5 * A*B; source = - con*fabs(sqrt(pow(C_U(c,t),2)+pow(C_V(c,t),2)))*C_ U(c,t); dS[eqn]= -2*con*fabs(sqrt(pow(C_U(c,t),2)+pow(C_V(c,t),2))); return source; } In GAMBIT you define the boundary of the FLUID REGION. After the compilation or interpretation of UDF source term in FLUENT, do: Define - Boundary Conditions â€" Fluid … Open Fluid Painel. Thus, set source term option, and introduce your UDF in the X-Momentum list(or Y and Z) list. |

All times are GMT -4. The time now is 13:21. |