CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   FLUENT (https://www.cfd-online.com/Forums/fluent/)
-   -   Editing a UDF for a velocity boundary in a multiphase (https://www.cfd-online.com/Forums/fluent/64342-editing-udf-velocity-boundary-multiphase.html)

rubenk May 7, 2009 15:48

Editing a UDF for a velocity boundary in a multiphase
 
Hello,

Does someone have an example of how to specify velocity as function of time for a multiphase mixture at a velocity inflow boundary condition? I am using a VOF scheme.

I know I'll get a RTFM but I did read the manual and other posts in this forum related to my question. I am confused as to if I should use both domain and subdomain pointers. I started by trying to augment the following code that works for a single phase situation but maybe that is not the way to go:

/************************************************** ********************
unsteady.c
UDF for specifying a transient velocity profile boundary condition
************************/
#include"udf.h"
#include"unsteady.h"
float *vel_data, vel; //velocity will be redefined as mass flow for the purposes of this problem
DEFINE_PROFILE(unsteady_velocity, thread, position)
{
face_t f;
int t = N_TIME;
begin_f_loop(f, thread)
{
F_PROFILE(f, thread, position) = vel_data[t];
}
end_f_loop(f, thread)
}

DEFINE_ON_DEMAND(read_velocity)
{
int i = 0;
int *time_data, filelength, time;
FILE* fp;
#if !RP_NODE
Message(
"Beginning Read File Routine \n");
#endif
fp = fopen("velocity.dat","r");
if ( fp!=NULL )
{
#if !RP_NODE
Message(
" \n");
Message(
"Reading file velocity.dat \n");
Message(
" \n");
#endif
}
else
{
#if !RP_NODE
Message(
" \n");
Message(
"Error opening file \n");
Message(
" \n");
#endif
}
fscanf(fp,
"%i \n",&filelength);
#if !RP_NODE
Message(
"The file length is: %i \n",filelength);
#endif
//time_data = (int *) malloc(filelength*sizeof(int));
vel_data = (float *) malloc(filelength*sizeof(float));
if ( (vel_data==NULL) )
{
#if !RP_NODE
Message(
"Memory allocation error \n");
#endif
}
for(i=0; i<filelength; i++)
{
fscanf(fp,
"%f \n",&vel);
//time_data[i] = time;
vel_data[i] = vel;
//#if DISPLAY_TABLES
#if !RP_NODE
Message(
"%.3f \n", vel_data[i]);
#endif
}
//#else
#if !RP_NODE
Message(
" \n");
#endif
//#endif
fclose(fp);
}


All times are GMT -4. The time now is 15:56.