|
[Sponsors] |
Issue with begin_c_loop when more than one cell zone |
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
March 1, 2018, 14:14 |
Issue with begin_c_loop when more than one cell zone
|
#1 |
New Member
Brian
Join Date: Feb 2018
Posts: 4
Rep Power: 8 |
Hi,
I wrote a UDF (see attached) to compute the total mass in an axisymmetrc energy equation only model. I use this information to adjust boundary conditions. The UDF works correctly for a simple one cell zone model (if I multiple by 2*pi). UDF results agree exactly with Fluent's result volume mass integral. But the UDF produces nonsensical results when I have more than 2 cell zones. Result of UDF=3.88563e-07 kg, while Fluent's volume mass integral=8.1350377e-08 kg (which is correct). In addition, I also need to limit the mass summation to certain cell zones. When I try to limit the tread_loop_c to a specific cell zone IDs it gives the same nonsensical result as above (3.88563e-07 kg). Any help with either the incorrect mass issue or how to limit tread_loop_c to specific cell zone IDs would be greatly appreciated. Best Regards, Brian |
|
March 1, 2018, 21:10 |
|
#2 |
Senior Member
Alexander
Join Date: Apr 2013
Posts: 2,363
Rep Power: 34 |
was
Code:
thread_loop_c(t, d) { begin_c_loop(c, t) { mass_total += C_R(c, t) * C_VOLUME(c, t); } end_c_loop(c, t); mass_total = 2 * pi*mass_total; /*axisymmetric requires mult by 2pi to get total mass*/ } Code:
thread_loop_c(t, d) { begin_c_loop(c, t) { mass_total += C_R(c, t) * C_VOLUME(c, t); } end_c_loop(c, t); } mass_total = 2 * pi*mass_total; /*axisymmetric requires mult by 2pi to get total mass*/ |
|
March 2, 2018, 07:17 |
Re:Issue with begin_c_loop when more than one cell zone
|
#3 |
New Member
Brian
Join Date: Feb 2018
Posts: 4
Rep Power: 8 |
AlexanderZ,
Thanks for finding my error! That solved the total mass issue. I've been looking at this for the better part of a day. Limiting the cell zones used in the mass summation is still an issue. In my test model I have two cell zones, id=3 and id=4. If I try to limit thread_loop_c(t, d) with the commands below, the UDF still sums mass over both threads. Thanks again for your help. Best Regards, Brian int id_1 = 4; Thread *t; t = Lookup_Thread(d, id_1); thread_loop_c(t, d) { begin_c_loop(c, t) { mass_total += C_R(c, t) * C_VOLUME(c, t); } end_c_loop(c, t); } mass_total = 2 * pi*mass_total; |
|
March 2, 2018, 12:32 |
|
#4 |
Senior Member
Join Date: Sep 2017
Posts: 246
Rep Power: 12 |
The command "thread_loop_c(t, d){ ... }" is doing what it is meant to do: it is meant to loop over all threads in the domain. So, the first iteration over-writes the value of t that you have set up with Lookup_Thread. Delete the thread_loop_c line (and the corresponding closing brace) and you should be fine.
Ed |
|
March 2, 2018, 12:44 |
Re:Issue with begin_c_loop when more than one cell zone
|
#5 |
New Member
Brian
Join Date: Feb 2018
Posts: 4
Rep Power: 8 |
Ed,
Thank you! Works just like I need. There is a bit of a learning curve with UDFs You probably saved me several days of debugging. Best Regards, Brian |
|
Tags |
begin_c_loop, tread_loop_c, udf |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Cluster ID's not contiguous in compute-nodes domain. ??? | Shogan | FLUENT | 1 | May 28, 2014 16:03 |
UDF for heat source on surface instead of the whole cell zone?? | benson621 | Fluent UDF and Scheme Programming | 4 | December 8, 2011 12:54 |
[Other] cgnsToFoam problems with "QUAD_4" cells | lentschi | OpenFOAM Meshing & Mesh Conversion | 1 | March 9, 2011 05:49 |
Change cell zone index/thread during simulation | neilduffy1024 | FLUENT | 0 | January 17, 2011 10:40 |
Sliding mesh error | Karl Kevala | FLUENT | 4 | February 21, 2001 16:52 |