CFD Online URL
[Sponsors]
Home > Forums > FLUENT

someon who ever used DEFINE_SOURCE

Register Blogs Members List Search Today's Posts Mark Forums Read

Reply
 
LinkBack Thread Tools Display Modes
Old   August 4, 2004, 05:00
Default someon who ever used DEFINE_SOURCE
  #1
bowling
Guest
 
Posts: n/a
I have problem about add source term in turbulent model. If you ever done it, please tell me. Thank you.
  Reply With Quote

Old   August 4, 2004, 15:05
Default Re: someon who ever used DEFINE_SOURCE
  #2
Alex Chirokov
Guest
 
Posts: n/a
it works fairly simple, below is the example from one of my codes. use c, c_thread to extract information about cells.

Alex-

DEFINE_SOURCE(FunctionName, c, c_thread, dS, i) { double dSource return dSource; }

DEFINE_SOURCE(energy_ConstantHeat, c, c_thread, dS, i) {

real source; // Watt/m3

real T;

real x[ND_ND], y;

C_CENTROID(x,c,c_thread);

T = C_T(c,c_thread); // Kelvins

y = x[1];

if( x[0]>0.095 && x[0]<0.215 &&

y<0.025 && y>0.015 )

{

// energy source and radiation in all zones

source=5000000;//-6.8*(1e-09)*pow(T,4)*pow(10,(T-13400)/16000-6.58); //

}else

{

source=0;

}

return source; }

DEFINE_SOURCE(Loretz_ForceR, c, c_thread, dS, i) {

double dXCoord;

double dYCoord;

double dE;

real x[ND_ND];

real T;

C_CENTROID(x, c, c_thread)

dXCoord = x[0];

dYCoord = x[1];

return GetArrayEx(dXCoord, dYCoord, 8); } DEFINE_SOURCE(Loretz_ForceZ, c, c_thread, dS, i) {

double dXCoord;

double dYCoord;

double dE;

real x[ND_ND];

real T;

C_CENTROID(x, c, c_thread)

dXCoord = x[0];

dYCoord = x[1];

return GetArrayEx(dXCoord, dYCoord,9); }

DEFINE_SOURCE(energy_GlobalTemp, c, c_thread, dS, i) {

double dXCoord;

double dYCoord;

double dE;

real x[ND_ND];

real T;

C_CENTROID(x, c, c_thread)

dXCoord = x[0];

dYCoord = x[1];

T = C_T(c, c_thread);

/*conductivity*/

C_UDMI(c, c_thread, 0) = GetArrayEx(dXCoord, dYCoord, 1);

/*conductivity*/

C_UDMI(c, c_thread, 1) = econd(T);

/*Ai*/

C_UDMI(c, c_thread, 2) = GetArrayEx(dXCoord, dYCoord, 2);

/*Ar*/

C_UDMI(c, c_thread, 3) = GetArrayEx(dXCoord, dYCoord, 3);

/*Ei*/

C_UDMI(c, c_thread, 4) = GetArrayEx(dXCoord, dYCoord, 4);

/*Er*/

C_UDMI(c, c_thread, 5) = GetArrayEx(dXCoord, dYCoord, 5);

/*Ac coil contribution*/

C_UDMI(c, c_thread, 6) = GetArrayEx(dXCoord, dYCoord, 15);

/*Temperature*/

C_UDMI(c, c_thread, 7) = GetArray(dXCoord, dYCoord, 0);

/*Temperature*/

C_UDMI(c, c_thread, 8) = GetArrayEx(dXCoord, dYCoord, 0);

/*Source term - Pw*/

C_UDMI(c, c_thread, 9) = GetArrayEx(dXCoord, dYCoord, 7);

/*Fr*/

C_UDMI(c, c_thread, 10) = GetArrayEx(dXCoord, dYCoord, 8);

/*Fz*/

C_UDMI(c, c_thread, 11) = GetArrayEx(dXCoord, dYCoord, 9);

/*Brr*/

C_UDMI(c, c_thread, 12) = GetArrayEx(dXCoord, dYCoord, 10);

/*Bri*/

C_UDMI(c, c_thread, 13) = GetArrayEx(dXCoord, dYCoord, 11);

/*Bzr*/

C_UDMI(c, c_thread, 14) = GetArrayEx(dXCoord, dYCoord, 12);

/*Bzi*/

C_UDMI(c, c_thread, 15) = GetArrayEx(dXCoord, dYCoord, 13);

/*|E|*/

C_UDMI(c, c_thread, 16) = GetArrayEx(dXCoord, dYCoord, 14);

/*J electric current*/

C_UDMI(c, c_thread, 17) = GetArrayEx(dXCoord, dYCoord, 1)*GetArrayEx(dXCoord, dYCoord, 14);

/*Radiation source (sink)*/

C_UDMI(c, c_thread, 18) = -radiation(T);

/*real absolute residuals*/

C_UDMI(c, c_thread, 19) = GetArrayEx(dXCoord, dYCoord, 16);

/*image absolute residuals*/

C_UDMI(c, c_thread, 20) = GetArrayEx(dXCoord, dYCoord, 17);

/*Change in Power*/

C_UDMI(c, c_thread, 21) = GetArrayEx(dXCoord, dYCoord, 18);

return (C_UDMI(c, c_thread, 9)+C_UDMI(c, c_thread, 18)); }
  Reply With Quote

Old   August 13, 2004, 05:27
Default Re: someon who ever used DEFINE_SOURCE
  #3
kevin
Guest
 
Posts: n/a
hi, Alex, what's the syntax of GetArrayEx()? Is it inherent with Fluent or you defined it in your own head file?
  Reply With Quote

Old   August 13, 2004, 14:04
Default Re: someon who ever used DEFINE_SOURCE
  #4
Alex Chirokov
Guest
 
Posts: n/a
it is just and example from my working code on how to process input perameters i DEFINE_SOURCE and supply an output , GetArrayEx() not fluent function.
  Reply With Quote

Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT -4. The time now is 01:17.