CFD Online Logo CFD Online URL
Home > Forums > Software User Forums > ANSYS > FLUENT > Fluent UDF and Scheme Programming

UDF for Species Mass Fraction Gradient *IN SPECIFIC ZONE * -- e.g. along axis of sym.

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

LinkBack Thread Tools Search this Thread Display Modes
Old   February 27, 2011, 12:55
Default UDF for Species Mass Fraction Gradient *IN SPECIFIC ZONE * -- e.g. along axis of sym.
New Member
Kate S
Join Date: Nov 2010
Posts: 5
Rep Power: 15
ksiegs2 is on a distinguished road
Hello all!

I am trying to write a UDF to export data for species mass fraction concentration gradient *along the axis of symmetry* of my 2D axisymmetric model.

I can get the data to output for all of the nodes in the 2D domain, but I cannot figure out how to output data only for the specific zone I need.

Right now it exports the species mass fraction gradient vector as one long vector for all nodes, with no indication as to which data point came from which node, or even which zone.

Does anyone know how to selectively output data from just a single zone? Or how to determine where each data point is coming from?

Thank you very much.

[I created my UDF by adapting the pressures_to_file.c UDF in the Fluent V12 users guide, if that helps.]

Thanks again!

This is the code: (I tried just substituting zone_ID for FLUID_ID, but that didn't work, so it's commented out now. The code leaves the option for the serial, node or host versions to run. In this case, the serial version runs.)

/************************************************** ******************/
#include "udf.h"
# define FLUID_ID 2
/* Different variables are needed on different nodes */
/*int zone_ID = 1;*/ /*designates axis of symmetry as zone of interest */
#if !RP_HOST
Domain *domain=Get_Domain(1);
Thread *thread;
cell_t c;
int i;
#if !RP_NODE
FILE *fp = NULL;
char filename[]="h2_grad_axis.txt";
int size; /* data passing variables */
real *array;
int pe;
/* Only Serial and Compute Nodes have data on threads */
#if !RP_HOST
#if !RP_NODE /* SERIAL or HOST */
if ((fp = fopen(filename, "w"))==NULL)
Message("\n Warning: Unable to open %s for writing\n",filename);
Message("\nWriting H2 Mass Fraction Gradient in X-Direction to %s...",filename);
/* UDF Now does 3 different things depending on SERIAL, NODE or HOST */
Message("(Serial version running...)");
fprintf(fp, "%g\n", C_YI_G(c,thread,2));/* Simply write out h2 mass fraction x-direction gradient data*/
#endif /* !PARALLEL */
/* Each Node loads up its data passing array */
array = (real *)malloc(size * sizeof(real));
array[c]= C_YI_G(c,thread,2);
/* Set pe to destination node */
/* If on node_0 send data to host */
/* Else send to node_0 because */
/* compute nodes connect to node_0 & node_0 to host */
pe = (I_AM_NODE_ZERO_P) ? node_host : node_zero;
PRF_CSEND_INT(pe, &size, 1, myid);
PRF_CSEND_REAL(pe, array, size, myid);
free(array);/* free array on nodes after data sent */
/* node_0 now collect data sent by other compute nodes */
/* and sends it straight on to the host */
compute_node_loop_not_zero (pe)
PRF_CRECV_INT(pe, &size, 1, pe);
array = (real *)malloc(size * sizeof(real));
PRF_CRECV_REAL(pe, array, size, pe);
PRF_CSEND_INT(node_host, &size, 1, myid);
PRF_CSEND_REAL(node_host, array, size, myid);
free((char *)array);
#endif /* RP_NODE */
Message("(Node version running...)");
compute_node_loop (pe) /* only acts as a counter in this loop */
/* Receive data sent by each node and write it out to the file */
PRF_CRECV_INT(node_zero, &size, 1, node_zero);
array = (real *)malloc(size * sizeof(real));
PRF_CRECV_REAL(node_zero, array, size, node_zero);
for (i=0; i<size; i++)
fprintf(fp, "%g\n", array[i]);
Message("(Host version running...)");
#endif /* RP_HOST */
#if !RP_NODE /* SERIAL or HOST */
fclose(fp); /* Close the file that was only opened if on SERIAL or HOST */

Last edited by ksiegs2; February 27, 2011 at 13:18. Reason: Added code
ksiegs2 is offline   Reply With Quote


axisymmetric problem, output file, udf, zone specific

Thread Tools Search this Thread
Search this Thread:

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

Similar Threads
Thread Thread Starter Forum Replies Last Post
mass flow in is not equal to mass flow out saii CFX 12 March 19, 2018 05:21
Simulation of a single bubble with a VOF-method Suzzn CFX 21 January 29, 2018 00:58
Constant velocity of the material Sas CFX 15 July 13, 2010 08:56
How to show the properties in the specific zone ID using UDF (Define_adjust) sagga18 Fluent UDF and Scheme Programming 2 December 12, 2009 16:01
Two-Phase Buoyant Flow Issue Miguel Baritto CFX 4 August 31, 2006 12:02

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