CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Software User Forums > ANSYS > FLUENT

Define source

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   November 2, 2002, 19:15
Default Define source
  #1
Ridha
Guest
 
Posts: n/a
Hi every body ! i use a (Define_source) for calculing source term.To read a data extern (table_file(Meteo.txt) is denpend on the time). i use the function fscanf Where table_file is the file in which data is stored. and i use these values from the table in calculating the heat flux.every iteration at every time step i read the data file (Meteo.txt) and calcul the heat source , so i use the soubroutine (by Greg Perkins ftp://ftp.cfd-online.com/fluent/udf_scalar_dos.c ) My problom is that Fluent open and read the table_file on every cells because the define_Source is teh function typically loops overs cells in a cell thread and computes cell,(example if for 15000 cell the file meteo is open 15000) what i do ? can i use define adjust to read and store teh data ? please help me ************************************************** ************************************************** ********** File meteo time 0 3 .... Tamb 280 300 vent 280 300 Humid0.5 Ra Tambiante vent Humid 0 10 300 0.5 0.8 3 10 301 3 0.86 6 20 305 4 0.8 9 0 280 0.5 0.9

******************************************* ****************************************** #include"udf.h" # define elements 46 # define elementp 47 #define mu 0.8 /* coefficient d'extinction*/ #define Print printf static real f_s=0.0,dS_s=0.0,Ra=0.0,Tamb=0.0,vent=0.0,Humid=0. 0; /* STATIC version of f and dS Tamb,vent,Humid*/ static int control_t=0 ; /* We use STATIC 'cause we want Fluent to */ static int first_iter ; /* remember these values from iteration */ static real Temp;

**************************** **************************** UDF SOURCE

DEFINE_SOURCE(cell_Source, cell, thread, ds, eqn) {

face_t f;

double temp,source,y,time[elementp],Hs[elementp],Ta[elementp],wind[elementp],Humidt[elementp];

real x[ND_ND];

int i,n,time_step, iter,current_iter;

FILE *fichier;

FILE *fp;

FILE *fd;

fichier= fopen("Meteo.txt","r");

fp=fopen ("out1","w");

fd=fopen ("out2","w");

time_step = RP_Get_Integer("time-step");

temp=((RP_Get_Real("flow-time"))/3600.); current_iter = (nres == 0) ? (0) : ((int) count2[nres - 1]); /* C_CENTROID(x, cell, thread);

y=x[1];*/

/* and iteration */

if(control_t != time_step)

first_iter = current_iter; /* If there's a change */

/* in TIME STEP number, we use it as a cue to flag the iteration as first */

if(first_iter == current_iter) /* Execute for first iteration of each t_step */

{

/* for (i = 0; i< elements ;i++)

{

fscanf(fichier,"%f %f %f %f %f",&time[i],&Hs[i],&Ta[i],&wind[i],&Humidt[i]);

/*read table_file*/ }*/

}

fclose(fichier); for(n = 0; n < elements; n++)

{

if ( (time[n] <= temp) && (temp < time[n+1]) )

{

/* C_CENTROID(x, cell, thread);

y=x[1];

source =f_s =0.6 * Hs[n]* y ;

ds[eqn]=dS_s =0.0;*/

Tamb=Ta[n];

vent=wind[n];

Humid=Humidt[n];

Ra=Hs[n];

} }

C_CENTROID(x, cell, thread);

y=x[1];

ds[eqn]=dS_s =0.0;

control_t = time_step;

}

else

{

C_CENTROID(x, cell, thread);

y=x[1];

source = f_s; /* We don't recalculate, but we need to keep */

ds[eqn] = dS_s; /* returning these values, for the UDF to be effective */

}

return source; }

************************************************** ************************************************** **********

  Reply With Quote

Reply


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 Off
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
HELP! adding a mass source to VOF eqn. by UDF??? ROOZBEH FLUENT 5 December 3, 2016 18:53
OpenFOAM on MinGW crosscompiler hosted on Linux allenzhao OpenFOAM Installation 127 January 30, 2009 20:08
Define a source term Chen Fangzhi FLUENT 0 July 2, 2003 08:41
How to define momentum source? Bogesz CFX 3 July 23, 2002 04:25
how 2 define mom. source 2. ? Bogesz CFX 0 May 5, 2002 13:58


All times are GMT -4. The time now is 14:06.