CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   FLUENT (https://www.cfd-online.com/Forums/fluent/)
-   -   Fluent UDF for calculate boundary zone centroid and the mass flow (https://www.cfd-online.com/Forums/fluent/253005-fluent-udf-calculate-boundary-zone-centroid-mass-flow.html)

sunilpatil November 19, 2023 21:41

Fluent UDF for calculate boundary zone centroid and the mass flow
 
Hi All,
My geometry consist of >600 boundary surfaces (>30 fluid zones) and I want fluent to extract each boundary centroid so that I can use this information for post-processing.

Code:

#include "udf.h"

FILE *fout;

void Print_Thread_Face_Centroids(Domain *domain, int id)
{
    real FC[3];
    face_t f;
    int n_faces,j;
    Thread *t = Lookup_Thread(domain, id);
   
    n_faces=THREAD_N_ELEMENTS_INT(t);
    fprintf(fout,"%d\n", n_faces); /* prints number of cell faces */
    begin_f_loop(f,t)
        {
                F_CENTROID(FC,f,t);
                fprintf(fout, "f%d %g %g %g\n", f, FC[0], FC[1], FC[2]);
        }
    end_f_loop(f,t)
    fprintf(fout, "\n");
}

DEFINE_ON_DEMAND(get_coord)
{
    Domain *domain; /* domain is declared as a variable */
    domain = Get_Domain(1); /* returns fluid domain pointer */
    fout = fopen("BCData.txt", "w");
    Print_Thread_Face_Centroids(domain, 16);
    fclose(fout);
}

I was able to interpret and run the above code, it is writing face centroid of each element on the boundary but I want the centroid of the boundary or else the min and max values in X and Y direction.

Please help me in resolving this issue.


All times are GMT -4. The time now is 23:58.