|
[Sponsors] |
DEFINE_EXECUTE_AT_END --> loop on boundary with the use of Lookup_Thread ??? |
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
August 7, 2013, 02:33 |
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 |
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); } Any idea how I can tell DEFINE_EXECUTE_AT_END to loop on a boundary? Last edited by macfly; September 4, 2013 at 15:51. |
|
August 7, 2013, 04:12 |
|
#2 |
Senior Member
|
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); } |
|
August 7, 2013, 14:20 |
|
#3 |
Senior Member
François Grégoire
Join Date: Jan 2010
Location: Canada
Posts: 392
Rep Power: 17 |
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); } |
|
August 7, 2013, 21:12 |
|
#4 |
Senior Member
|
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.
|
|
|
|
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 21:52 |
1.7.x -> buoyantPimpleFoam -> hRhoThermo -> incompressible and icoPoly3ThermoPhysics? | will.logie | OpenFOAM | 0 | December 16, 2010 08:08 |
CAD -> gMsh -> enGrid -> OpenFOAM Problem | AlGates | OpenFOAM | 7 | August 6, 2010 13:46 |
[Netgen] Geometry > Netgen > OpenFOAM | ericnutsch | OpenFOAM Meshing & Mesh Conversion | 9 | February 22, 2010 08:39 |
Point Data -> Spline -> Iges | Tim Franke | Main CFD Forum | 1 | July 6, 2000 13:14 |