# wrong Mass flow rate calc in parallel

 Register Blogs Members List Search Today's Posts Mark Forums Read

 August 18, 2015, 03:53 wrong Mass flow rate calc in parallel #1 New Member   Engr. Shah Jahan Join Date: Aug 2015 Posts: 11 Rep Power: 8 Hi All in parallel code of flow at boundary zone , UDf gives wrong value of F_Flux(f,t) in thousands. is there any looping modification for parallel to measure mass flow rate.? Need help.... while in serial code works well.

 August 18, 2015, 05:43 #2 Senior Member   Join Date: Mar 2015 Posts: 892 Rep Power: 15 Have a read of the "Parallel Considerations" chapter in the UDF manual. If you're using the begin_f_loop macro then the partition boundary faces would be called twice (once on each compute node). A simple solution to this problem is to check if the current node is this face's principal compute node, using: Code: `if PRINCIPAL_FACE_P(f,tf)` shahjehan13 likes this.

August 18, 2015, 15:17
#3
New Member

Engr. Shah Jahan
Join Date: Aug 2015
Posts: 11
Rep Power: 8
Quote:
 Originally Posted by `e` Have a read of the "Parallel Considerations" chapter in the UDF manual. If you're using the begin_f_loop macro then the partition boundary faces would be called twice (once on each compute node). A simple solution to this problem is to check if the current node is this face's principal compute node, using: Code: `if PRINCIPAL_FACE_P(f,tf)`
Thanks for guide. I have considered principal node modification.

Here is my code
Code:
```include "udf.h"
#define zone_id 10015
DEFINE_ON_DEMAND(flowrate)
{
Domain *d=Get_Domain(1);
face_t f;
real m_flow=0;
int ncount=0;
#if !RP_HOST /*node or serial*/

begin_f_loop(f,t)
{
if(PRINCIPAL_FACE_P(f,t)) /*also works in serial and parallel.*/
{
ncount+=1;
m_flow+=F_FLUX(f,t);

}

}
end_f_loop(f,t) /*works same way in serial and parallel*/
#endif /*!RP_HOST*/

#if RP_NODE
m_flow=PRF_GRSUM1(m_flow);
#endif

node_to_host_real_1(m_flow); /*this does nothing in serial and should never
/*be inside a compiler directive*/

Message("faces are  %d\n",ncount);
Message("flow is  %d\n",m_flow);

}```
this returns value of m_flow very large something 1223666 -34444

any idea what is wrong with loop to calculate f_flux(f,t) loop

 August 18, 2015, 19:36 #4 Senior Member   Join Date: Mar 2015 Posts: 892 Rep Power: 15 Assign a real number (e.g. "0.") instead of an integer (e.g. "0") when initialising real variables such as m_flow: Code: `real m_flow=0.;` shahjehan13 likes this.

August 19, 2015, 05:31
#5
New Member

Engr. Shah Jahan
Join Date: Aug 2015
Posts: 11
Rep Power: 8
Quote:
 Originally Posted by `e` Assign a real number (e.g. "0.") instead of an integer (e.g. "0") when initialising real variables such as m_flow: Code: `real m_flow=0.;`
Thanks for helping in it. actually problem i m facing is that f_flux(f,t) when i print out its value is a large number.
is there any other method to get mass flow other than f_flux(f,t) i think it is problematic in parallel.

another question is that should I declare variables and threads before !RP_HOST or in general.

 August 19, 2015, 07:29 #6 Senior Member   Join Date: Mar 2015 Posts: 892 Rep Power: 15 You're still confusing data types. %d is a format specifier for integers whereas the mass flux is a real number; use %e or similar instead for printing this value. Variables should be declared on the relevant serial, host or compute nodes where they are used. For example, your ncount variable is used on all three cases with the Message function and therefore ncount should be declared outside of the compiler directives (which is currently done). shahjehan13 likes this.

August 19, 2015, 13:22
#7
New Member

Engr. Shah Jahan
Join Date: Aug 2015
Posts: 11
Rep Power: 8
Quote:
 Originally Posted by `e` You're still confusing data types. %d is a format specifier for integers whereas the mass flux is a real number; use %e or similar instead for printing this value. Variables should be declared on the relevant serial, host or compute nodes where they are used. For example, your ncount variable is used on all three cases with the Message function and therefore ncount should be declared outside of the compiler directives (which is currently done).

Yupee!!!!! finally this worked right.Sir! Thank you for your quick and right response . Error was due to data type format.

Another thing i am confused about. when I check flow rate via reports--> surface integral--> flow rate with volume fraction liquid phase on that surface it gives different value other than calculated by udf and there is also a difference in values if I chose surface integral report of mass flow rate.
Can you please explain why this is so..??

 August 19, 2015, 17:43 #8 Senior Member   Join Date: Mar 2015 Posts: 892 Rep Power: 15 Are you summing over the correct zone ID? You've defined zone_id at the start of the UDF but you're looking up zone 8. Try using your UDF with a simple case (not VOF) and if those results are correct, then is F_FLUX the total mass flow rate of all phases in VOF?

 August 29, 2015, 15:06 #9 New Member   Engr. Shah Jahan Join Date: Aug 2015 Posts: 11 Rep Power: 8 I tested that UDF with correct zone id and it worked. Thank you Now a days I am working for syamlal drag model in previous versions , we have to adjust C1 and D1 through UDF but in version 15 manual it is mentioned that they introduced this as Syamlal O'brien-para model in which it calculate and adjust these parameters automatically. but I did not find this in drag law panel list..may be it should be activated first to make it visible in list ... Sir..!! have you any idea about this thing???

 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 OffTrackbacks are Off Pingbacks are On Refbacks are On Forum Rules

 Similar Threads Thread Thread Starter Forum Replies Last Post beguxa FLUENT 5 December 2, 2018 21:02 muth OpenFOAM Running, Solving & CFD 3 August 27, 2018 04:18 KalleT CFX 4 May 17, 2017 18:48 destgir448 CFX 5 December 11, 2010 05:55 Masood FLUENT 0 May 22, 2005 00:32

All times are GMT -4. The time now is 18:58.