CFD Online Discussion Forums

CFD Online Discussion Forums (
-   FLUENT (
-   -   UDF to read data from a file for VOF model (

Pablo October 23, 2008 07:02

UDF to read data from a file for VOF model
Hi, I'm trying to build an UDF thats read the flow field variables in a VOF problem. The UDF should read the flow field stored in a file and then assign the values of the velocity, pressure and volume fraction to each cell centroid. I've tried with this one, and as it is being compiled without errors, Fluent returns a Segmentation violation message: Any help will be very welcome!!. Thanks!.

#include "udf.h" FILE *fout;

/* domain pointer that is passed by INIT function is mixture domain */ DEFINE_INIT(read_flow_field, mixture_domain) { int phase_domain_index; cell_t cell; Thread *cell_thread; Domain *subdomain; real xc[ND_ND]; real vof; real x,p,u,v; real m[41600][6];

fout= fopen("data2d.dat","r");

/* loop over all subdomains (phases) in the superdomain (mixture) */ sub_domain_loop(subdomain, mixture_domain, phase_domain_index) {

/* loop if secondary phase */

if (DOMAIN_ID(subdomain) == 3)

/* loop over all cell threads in the secondary phase domain */

thread_loop_c (cell_thread,subdomain)


/* loop over all cells in secondary phase cell threads */

begin_c_loop_all (cell,cell_thread)


fscanf(fout,"%g %g %g %g %g %g",&m[cell][0],&m[cell][1],&m[cell][2],&m[cell][3],&m[cell][4],&m[cell][5]);











end_c_loop_all (cell,cell_thread)


} fclose(fout); }

I've also tried use a counter to index the variables in the loop, unsuccessfully.

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