# Averaging a field in parallel during the simulation

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

 July 23, 2013, 11:07 Averaging a field in parallel during the simulation #1 Member   Saba Saeb Join Date: Dec 2010 Location: Erlangen, Germany Posts: 32 Rep Power: 8 Hi, I need to take the average of a field on a boundary during the simulation. I am doing that using the normal approach: scalar tmp= average(frictionvelocity); where frictionvelocity is a scalar field. Everything is running like a charm in serial, but the simulation would stop if I run it in parallel. I tried to tackle the problem using this approach: scalar tmp= average(frictionVelocity); scalar tauw = returnReduce(tmp, sumOp()); But the output is not correct since the calculated averages on every processors are being added together which make tauw that seems incorrect. Any idea would be appreciated. Tnx, Saba

 July 23, 2013, 11:31 #2 Senior Member     Anton Kidess Join Date: May 2009 Location: Germany Posts: 1,261 Rep Power: 23 Something along these lines might work: Code: ```int numprocs; MPI_Comm_size(MPI_COMM_WORLD, &numprocs); tauw /= numprocs; Info<< tauw << endl;``` Ninja edit - this is better: Code: ```label numprocs=Pstream::nProcs(); tauw /= numprocs;``` __________________ *On twitter @akidTwit *Spend as much time formulating your questions as you expect people to spend on their answer. Last edited by akidess; July 23, 2013 at 11:34. Reason: Better version

July 23, 2013, 11:39
#3
Member

Saba Saeb
Join Date: Dec 2010
Location: Erlangen, Germany
Posts: 32
Rep Power: 8
Quote:
 Originally Posted by akidess Something along these lines might work: Code: ```int numprocs; MPI_Comm_size(MPI_COMM_WORLD, &numprocs); tauw /= numprocs; Info<< tauw << endl;``` Ninja edit - this is better: Code: ```label numprocs=Pstream::nProcs(); tauw /= numprocs;```
Hi Anton,

That was the first idea that came to my mind, not however division by the total number of processors, but, division by no. of processors in x direction time no. of processors in z direction since friction velocity is just being calculated on the boundary located at the bottom of a channel, in my case. However, this is not still giving me the expected results since friction velocity is not being spread uniformly along the wall!
If anything seems unclear to me, please let me know.

Cheers,
Saba

 July 23, 2013, 11:40 #4 Senior Member   Alexey Matveichev Join Date: Aug 2011 Location: Nancy, France Posts: 1,691 Rep Power: 28 There is gAverage function. Explanation and examples can be found for example at - http://www.cfd-online.com/Forums/ope...tml#post202817.

July 23, 2013, 12:13
#5
Member

Saba Saeb
Join Date: Dec 2010
Location: Erlangen, Germany
Posts: 32
Rep Power: 8
Quote:
 Originally Posted by alexeym There is gAverage function. Explanation and examples can be found for example at - http://www.cfd-online.com/Forums/ope...tml#post202817.
Hi Alexey,

gAverage is apparently solving the problem. Tnx for your hint.

Cheers,
Saba

 Thread Tools Display Modes Linear Mode

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

 Similar Threads Thread Thread Starter Forum Replies Last Post saba_saeb OpenFOAM Programming & Development 0 July 17, 2013 13:07 ernest STAR-CCM+ 8 August 17, 2011 05:02 satum FLUENT 0 October 21, 2008 05:38 Jimmy FLUENT 1 July 14, 2008 00:46 J.Gimbun FLUENT 9 May 24, 2006 05:47

All times are GMT -4. The time now is 03:25.