CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Software User Forums > ANSYS > FLUENT

Fluent UDF for calculate boundary zone centroid and the mass flow

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

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   November 19, 2023, 21:41
Smile Fluent UDF for calculate boundary zone centroid and the mass flow
  #1
Senior Member
 
sunilpatil's Avatar
 
sunil
Join Date: Jul 2012
Location: Bangalore
Posts: 179
Rep Power: 13
sunilpatil is on a distinguished road
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.
__________________
Regards,
Sunil

Last edited by sunilpatil; November 20, 2023 at 11:56. Reason: Fount a intrim solution so updated that info
sunilpatil is offline   Reply With Quote

Reply

Tags
centroid, executeondemand, fluent - udf

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



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