CFD Online Discussion Forums

CFD Online Discussion Forums (
-   FLUENT (
-   -   information from a surface, not made from GAMBIT (

rr123 March 22, 2009 11:08

information from a surface, not made from GAMBIT
dear all,

i have a small problem which is related to the post-processing of data from a surface, which is created in the Fluent, and not from GAMBIT.

i have 2d vertical channel. i have made few horizontal surfaces (using line/rake option). let the surfaces be y = 1 m, y = 2m, etc.
Note: These surfaces are not created in GAMBIT, they are just created as a post-processing feature in the case/data file itself.

now, my main requirement is to know some of the properties (like moments) of these surfaces. these moments are population balance variables.
The entire description of this variabe in the PBM manual is:

Macro Argument Types Returns
C_PB_QMOMI cell t_c, Thread *t, int i ith moment, where i = 0;
1;2; 3; 4; 5

if some one can share me the main code snippet that i must do as a UDF, it would be very useful. my main query is what domain and the thread macros that i must use.

thanks in advance.


paka March 22, 2009 23:35

Why not simply report those moment in Fluent to file? I guess it is under Report -> Moments? Unless you've got more variables which you cannot easily access in Fluent.

rr123 March 23, 2009 04:02

yes, i know that method and i consder it as a work-around only.
but my query is why not i make a UDF which would solve this problem.
something, whcih i could have executed as a post-processing macro.

paka March 23, 2009 05:19

Maybe I'm mistaken, but there is no need to define post-processing UDF. You define UDF to do "things" during computational process. Afterwards, I would use any scripting language to get what I need from saved ASCII files with necessary output.

rr123 March 23, 2009 06:30

Indeed you are very right sir.
I am just trying to make a use of a UDF.
In theory, a UDF 'is' possible to make for this and i just want to make it.

Thanks and regards.

paka March 23, 2009 06:49

OK. Good luck ;)

panda March 23, 2009 21:37

It seems Fluent UDF cannot access the surfaces you created for post-processing. Actually, for unsteady flows sometimes we really need such a UDF to access the newly created surfaces to get the time-dependant local response.

rr123 March 25, 2009 17:20

i also understand that UDF can't access the surfaces which i made.
but why not ?
where is the problem ?
i am not interested in the work-around problem said by paka.

#define NIDS (sizeof (idmeters) / sizeof (idmeters[0])) /* #define is a macro, the division means total array size/first element of the array size */
#define NMOM 6
struct idmeter
int id;
real meter;

int i;
int j;
struct idmeter idmeters[] = { /* idmeters is a structured array with two elements */
{12, 1.0}, /* first id, then meter correspondingly for one surface */
{13, 3.9}, /* then for another surface, and so on.. */
{14, 10.0}

FILE *postprocess;
Domain *d;
real time = CURRENT_TIME;
/* getting time */
real mu;
real sigma;
postprocess = fopen (
"results.txt", "a"); /* writing with several moments at a time */

for (j = 0; j < NIDS; j++)
int id = idmeters[j].id; /* the dot operator means that for the jth element of the idmeters array, the value of the element that is id */
real meter = idmeters[j].meter;
real A[NMOM];
/* temporary data array */
real T[NMOM]; /* temporary data array */
for (i = 0; i < NMOM; i++)
T[i] = 0;
cell_t c;
d = Get_Domain (3);
/* solid phase domain */
Thread *c_thread = Lookup_Thread (d, id);
begin_c_loop (c, c_thread)
for (i = 0; i < NMOM; i++)
T[i] += A[i] = C_PB_QMOMI (c, c_thread, i);
fprintf (postprocess,
"cell %12.5e %d %12.5e", time, id, meter);

for (i = 0; i < NMOM; i++)
fprintf (postprocess,
"%12.5e", A[i]);
mu = A[1] / A[0];
sigma = A[2] / A[0];
fprintf (postprocess,
"%12.5e %12.5e\n", mu, sigma);
end_c_loop (c, c_thread);


fclose (postprocess);


am i correct in the logic ?
i checked, the code is not giving any error on compilation; but it gives
Stack backtrace generated for process id 32337 on signal 1....
with a segmentation violation

hope someone helps

best wishes


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