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

Issue with begin_c_loop when more than one cell zone

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   March 1, 2018, 14:14
Question Issue with begin_c_loop when more than one cell zone
  #1
New Member
 
Brian
Join Date: Feb 2018
Posts: 4
Rep Power: 8
Brian_ is on a distinguished road
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
Attached Files
File Type: c mass_working_correctly_3.c (3.3 KB, 25 views)
Brian_ is offline   Reply With Quote

Old   March 1, 2018, 21:10
Default
  #2
Senior Member
 
Alexander
Join Date: Apr 2013
Posts: 2,363
Rep Power: 34
AlexanderZ will become famous soon enoughAlexanderZ will become famous soon enough
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*/
	  }
try this
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*/
best regards
AlexanderZ is offline   Reply With Quote

Old   March 2, 2018, 07:17
Thumbs up 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
Brian_ is on a distinguished road
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;
Brian_ is offline   Reply With Quote

Old   March 2, 2018, 12:32
Default
  #4
Senior Member
 
Join Date: Sep 2017
Posts: 246
Rep Power: 12
obscureed is on a distinguished road
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
obscureed is offline   Reply With Quote

Old   March 2, 2018, 12:44
Thumbs up 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
Brian_ is on a distinguished road
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
Brian_ is offline   Reply With Quote

Reply

Tags
begin_c_loop, tread_loop_c, udf


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
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


All times are GMT -4. The time now is 00:48.