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

DEFINE_EXECUTE_AT_END --> loop on boundary with the use of Lookup_Thread ???

Register Blogs Community New Posts Updated Threads Search

Like Tree4Likes
  • 4 Post By macfly

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   August 7, 2013, 01:33
Default DEFINE_EXECUTE_AT_END --> loop on boundary with the use of Lookup_Thread ???
  #1
Senior Member
 
François Grégoire
Join Date: Jan 2010
Location: Canada
Posts: 392
Rep Power: 17
macfly is on a distinguished road
Hi,

Here is a simple UDF that calculates and prints the volume integral of temperature at the end of each time step:

Code:
#include "udf.h"
DEFINE_EXECUTE_AT_END(execute_at_end)
{
Domain *d;
Thread *t;
real sum_T=0.;
cell_t c;
d = Get_Domain(1);
thread_loop_c(t,d)
	begin_c_loop(c,t)
		sum_T += C_T(c,t) * C_VOLUME(c,t);  /* Integrate temperature */
	end_c_loop(c,t)
printf("Volume integral of temperature = %g K*m^3\n", sum_T);
}
Now, I would like to do a similar operation but on a boundary, with the use of the Lookup_Thread function. The UDF manual only has an example for the calculation of something in a domain (Get_Domain), not on a boundary (Lookup_Thread). I tried to modify my code with no success. I can make it work with DEFINE_ADJUST at each iteration, but it's not what I want: I want to perform some calculation on a boundary at each time step, not at each iteration.

Any idea how I can tell DEFINE_EXECUTE_AT_END to loop on a boundary?

Last edited by macfly; September 4, 2013 at 14:51.
macfly is offline   Reply With Quote

Old   August 7, 2013, 03:12
Default
  #2
Senior Member
 
Join Date: Aug 2011
Posts: 421
Blog Entries: 1
Rep Power: 21
blackmask will become famous soon enough
As you mentioned, use "Look_Thread" to find the specific thread.

Code:
#include "udf.h" DEFINE_EXECUTE_AT_END(execute_at_end) { Domain *d; Thread *t; real sum_T=0.; cell_t c;
real A_vec[ND_ND], A_scl;
d = Get_Domain(1); t = Lookup_Thread(12, d); /*change "12" to the actual id of your b.c. */ 	begin_c_loop(c,t)
F_AREA(A_vec, c, t);
A_scl = NV_MAG(A_vec);
sum_T += C_T(c,t) * A_scl;  /* Integrate temperature */ 	end_c_loop(c,t) printf("Surface integral of temperature = %g K\n", sum_T); }
blackmask is offline   Reply With Quote

Old   August 7, 2013, 13:20
Default
  #3
Senior Member
 
François Grégoire
Join Date: Jan 2010
Location: Canada
Posts: 392
Rep Power: 17
macfly is on a distinguished road
Thanks blackmask, I got it. Your example had little errors: it loops over cells instead of faces, and you inverted d and 12 in Lookup_Thread(d, 12). I guess you wrote it quick.

Here is my code for calculating area averaged T on outlet at the end of each time step:
Code:
DEFINE_EXECUTE_AT_END(execute_at_end)
{
Domain *domain;
Thread *thread;
face_t face;
real area[ND_ND];
real total_area = 0.0;
real total_area_ave_temp = 0.0;
int ID = 18; /* outlet ID displayed in Fluent boundary conditions panel */
domain = Get_Domain(1);
thread = Lookup_Thread(domain, ID); 
	begin_f_loop(face, thread)
		F_AREA(area, face, thread);
		total_area += NV_MAG(area);
		total_area_ave_temp += NV_MAG(area)*F_T(face, thread);
	end_f_loop(face, thread)
T_mean = total_area_ave_temp/total_area;
printf("Area averaged T on boundary %d = %f K\n", ID, T_mean);
}
The code for averaging is inspired by the example in the UDF Manual 14.5 entitled Global Summation of Pressure on a Face Zone and its Area Average Computation.
macfly is offline   Reply With Quote

Old   August 7, 2013, 20:12
Default
  #4
Senior Member
 
Join Date: Aug 2011
Posts: 421
Blog Entries: 1
Rep Power: 21
blackmask will become famous soon enough
You are right, I misplaced the domain pointer and thread id. However "begin_c_loop" and "begin_f_loop" are equivalent macros. I clicked "reply", copied your original code, added several lines and manually adjust the indentation. For some reason the format of the code is mangled.
blackmask is offline   Reply With Quote

Reply


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
1.7.x -> buoyantPimpleFoam -> hRhoThermo -> incompressible and icoPoly3ThermoPhysics? will.logie OpenFOAM Programming & Development 1 February 16, 2011 20:52
1.7.x -> buoyantPimpleFoam -> hRhoThermo -> incompressible and icoPoly3ThermoPhysics? will.logie OpenFOAM 0 December 16, 2010 07:08
CAD -> gMsh -> enGrid -> OpenFOAM Problem AlGates OpenFOAM 7 August 6, 2010 12:46
[Netgen] Geometry > Netgen > OpenFOAM ericnutsch OpenFOAM Meshing & Mesh Conversion 9 February 22, 2010 07:39
Point Data -> Spline -> Iges Tim Franke Main CFD Forum 1 July 6, 2000 12:14


All times are GMT -4. The time now is 04:13.