CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
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 Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   February 27, 2011, 13:55
Default UDF for Species Mass Fraction Gradient *IN SPECIFIC ZONE * -- e.g. along axis of sym.
  #1
New Member
 
Kate S
Join Date: Nov 2010
Posts: 5
Rep Power: 16
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
DEFINE_ON_DEMAND(h2_grad_to_file)
{
/* 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;
#else
int i;
#endif
#if !RP_NODE
FILE *fp = NULL;
char filename[]="h2_grad_axis.txt";
#endif
#if PARALLEL
int size; /* data passing variables */
real *array;
int pe;
#endif
/* Only Serial and Compute Nodes have data on threads */
#if !RP_HOST
thread=Lookup_Thread(domain,FLUID_ID);
#endif
#if !RP_NODE /* SERIAL or HOST */
if ((fp = fopen(filename, "w"))==NULL)
Message("\n Warning: Unable to open %s for writing\n",filename);
else
Message("\nWriting H2 Mass Fraction Gradient in X-Direction to %s...",filename);
#endif
/* UDF Now does 3 different things depending on SERIAL, NODE or HOST */
#if !PARALLEL /* SERIAL */
Message("(Serial version running...)");
begin_c_loop(c,thread)
fprintf(fp, "%g\n", C_YI_G(c,thread,2));/* Simply write out h2 mass fraction x-direction gradient data*/
end_c_loop(c,thread)
#endif /* !PARALLEL */
#if RP_NODE
/* Each Node loads up its data passing array */
size=THREAD_N_ELEMENTS_INT(thread);
array = (real *)malloc(size * sizeof(real));
begin_c_loop_int(c,thread)
array[c]= C_YI_G(c,thread,2);
end_c_loop_int(c,thread)
/* 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 */
if (I_AM_NODE_ZERO_P)
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 */
#if RP_HOST
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]);
free(array);
}
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 */
Message("Done\n");
#endif
}

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

Reply

Tags
axisymmetric problem, output file, udf, zone specific


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 06:21
Simulation of a single bubble with a VOF-method Suzzn CFX 21 January 29, 2018 01:58
Constant velocity of the material Sas CFX 15 July 13, 2010 09: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 17:01
Two-Phase Buoyant Flow Issue Miguel Baritto CFX 4 August 31, 2006 13:02


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