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

Parallel Average Volume Temperature Calculation

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   July 11, 2022, 06:03
Default Parallel Average Volume Temperature Calculation
  #1
New Member
 
Anas Nur Fauzan
Join Date: Oct 2019
Posts: 18
Rep Power: 7
luzikato is on a distinguished road
Greetings all,

I'm trying to compute average volume temperature of a region. This is my code.

Code:
/* Calculate Volume-weighted Average of Module Temperature. */
real volume;
real T_AVG_TEMP;

#if !RP_HOST
	thread = Lookup_Thread(domain, TEM_ID);
	begin_c_loop(c, thread)
	{
		volume += C_VOLUME(c, thread);
		T_AVG_TEM += C_T(c, thread)*C_VOLUME(c, thread);
	}
	end_c_loop(c, thread)

#if RP_NODE
	volume = PRF_GRSUM1(volume);
	T_AVG_TEM = PRF_GRSUM1(T_AVG_TEM);
#endif /* RP_NODE */

#endif /* RP_HOST */
I insert this into a DEFINE_ADJUST macro so the volume this will run at the start of every iterations. I am also using DEFINE_AT_END macro to print total volume calculated every iteration in console to check the value.
After running the simulation, I compared the total volume I calculated with UDF and using Volume Integral with Reports feature.

I found that by using UDF, I got the amount of total volume.
Code:
Total volume: 6.18199e-05
But then, using Reports I got.
Code:
                    Total Volume                 (m3)
-------------------------------- --------------------
                       tem_solid        5.9999975e-05
                ---------------- --------------------
                             Net        5.9999975e-05
I know I could just ignore it. However, in this case, unfortunately, I really can't tolerate any value error.
Is there something I need to fix in my code that could results difference in total volume? Any insight, would be highly appreciated.

Thanks in advance.
Regards,

A.

Last edited by luzikato; July 14, 2022 at 08:22. Reason: Added more details to the problem
luzikato is offline   Reply With Quote

Old   July 14, 2022, 22:43
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
define volume = 0 explicitly before summation as well as T_AVG_TEMP = 0
__________________
best regards


******************************
press LIKE if this message was helpful
AlexanderZ 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
[openSmoke] libOpenSMOKE Tobi OpenFOAM Community Contributions 562 January 25, 2023 10:21
Calculating source term total cell-zone volume parallel computation RobV Fluent UDF and Scheme Programming 2 May 30, 2022 04:46
[snappyHexMesh] snappyHexMesh does not detect highly skewed faces? ptpacheco OpenFOAM Meshing & Mesh Conversion 1 January 4, 2022 13:37
how to set periodic boundary conditions Ganesh FLUENT 15 November 18, 2020 07:09
Converging Diverging Nozzle with dbnsTurbFoam Saleh Abuhanieh OpenFOAM Running, Solving & CFD 4 December 13, 2019 11:26


All times are GMT -4. The time now is 15:57.