CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Software User Forums > OpenFOAM > OpenFOAM Programming & Development

question about pallarel calculation.

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   August 8, 2018, 12:20
Default question about pallarel calculation.
  #1
New Member
 
Join Date: Aug 2018
Posts: 18
Rep Power: 8
nago is on a distinguished road
hi,

i use OF 2.3.1.
i want to get average pressure of all cell in calculation region.
so i try to get it using "forAll(mesh.cells(),cid)" method .
At single core calcuation, i can get average pressure.
but in pallarel calc, forAll statement only return one-processor cell.

・for example, simplefoam pitzDaily model,
i only add following term in simplefoam.C (named my_simpleFoam.C).

---------------------------------------------
:
:
laminarTransport.correct();
turbulence->correct();

forAll(mesh.cells()){
Info << "cellID : " << cid <<endl;
}


runTime.write();
:
:
------------------------------------------

when calculate pitzDaily using my_simpleFoam in single core, output messege has 12225 cell IDs(All cells).
but in pallarel ( 2cores ), output has only 6113 cell IDs(half number of all cells !).

i thougtr forAll(mesh.cells) can look all cells.
what is this behaiver?
and how can i get all-cell averaged pressure?


regard.
nago is offline   Reply With Quote

Old   August 8, 2018, 15:24
Default
  #2
Senior Member
 
Join Date: Aug 2015
Posts: 494
Rep Power: 15
clapointe is on a distinguished road
I think you can do it an easier way -- try adding this :

Code:
Info << "Average Pressure : " << gSum(p)/mesh.C().size() << endl;
gSum should take care of the parallel/ multi processor issue.

Caelan
clapointe is offline   Reply With Quote

Old   August 8, 2018, 23:02
Default
  #3
Senior Member
 
zhangyan's Avatar
 
Yan Zhang
Join Date: May 2014
Posts: 120
Rep Power: 12
zhangyan is on a distinguished road
Code:
Info<< "Mean pressure:" << p.weightedAverage(mesh.V()).value() << endl;
Ref: https://github.com/OpenFOAM/OpenFOAM...m/logSummary.H
__________________
https://openfoam.top
zhangyan is offline   Reply With Quote

Old   August 8, 2018, 23:24
Default
  #4
New Member
 
Join Date: Aug 2018
Posts: 18
Rep Power: 8
nago is on a distinguished road
hi clapointe,
thank you for your quick reply.

i add gSum(p) in my_simpleFoam to check the behavior in pitzDaily.
---------------------------------------------------------------
turbulence->correct();
runTime.write();

forAll(mesh.cells(),ci)
{
const cell &c = mesh.cells()[ci];
p_total += p.internalField()[ci];
}
Info << "p_total : " << p_total << endl;
Info << "gsum Pressure : " << gSum(p) << endl;

Info << "Average Pressure : " << gSum(p)/mesh.C().size() << endl;

Info<< "ExecutionTime = " << runTime.elapsedCpuTime() << " s"
---------------------------------------------------------------

and I add following functionObject in controlDict.
------------------------------------------------------
press_sum
{
type cellSource;
functionObjectLibs ("libfieldFunctionObjects.so");
fields (p);
valueOutput false;
source all;
operation sum;
outputControl timeStep;
outputInterval 1;
}

press_aveg
{
type cellSource;
functionObjectLibs ("libfieldFunctionObjects.so");
fields (p);
valueOutput false;
source all;
operation average;
outputControl timeStep;
outputInterval 1;
}

------------------------------------------------------

after running 1step calculation,result is following.

(single)
p_total : 1.7186e+07
gsum Pressure : 1.7186e+07
Average Pressure : 1405.81
cellSource press_sum output:
sum(sampledSurface) for p = 1.7186e+07
cellSource press_aveg output:
average(sampledSurface) for p = 1405.81

(2 core)
p_total : 5.69918e+06
gsum Pressure : 1.72788e+07
Average Pressure : 2839.57
cellSource press_sum output:
sum(sampledSurface) for p = 1.72788e+07
cellSource press_aveg output:
average(sampledSurface) for p = 1413.4

in single calc , p_total and gsumPressure is same Value.
in 2 parallel, as expected,two value differs.

but in parallel calc, result looks like bad, especially in Average Pressure.
and i mind difference gsum Pressure between single and parallel.
in parallel calc, it looks "mesh.C().size()" picking up only one-processor cells.
why this happen?
nago is offline   Reply With Quote

Old   August 8, 2018, 23:34
Default
  #5
New Member
 
Join Date: Aug 2018
Posts: 18
Rep Power: 8
nago is on a distinguished road
thanks zhangyan.

your advice is very useful for me.
i wanna use it.

BTW, for my interest, do you know why the problem in my previous post happen ?
nago is offline   Reply With Quote

Old   August 8, 2018, 23:46
Default
  #6
Senior Member
 
Join Date: Aug 2015
Posts: 494
Rep Power: 15
clapointe is on a distinguished road
That's a good catch -- I'd tested it briefly and received something that looked reasonable -- sorry. Try this instead : gSum(p)/mesh.nCells(). This came directly from the aforementioned field average function object, so it should replicate it now.

Caelan
clapointe is offline   Reply With Quote

Old   August 9, 2018, 00:06
Default
  #7
New Member
 
Join Date: Aug 2018
Posts: 18
Rep Power: 8
nago is on a distinguished road
hi clapointe,

i try "gSum(p)/mesh.nCells()" insted of "gSum(p)/mesh.C().size()".
but result does'nt change.


And now, i consulted OF information, i found "Reduce()" statment.
in parallel calculation, we have to use Reduce for all Regions.
I should have consulted more and found it but I could not ...

Thanks.
nago is offline   Reply With Quote

Old   August 9, 2018, 00:16
Default
  #8
Senior Member
 
Join Date: Aug 2015
Posts: 494
Rep Power: 15
clapointe is on a distinguished road
Ok, with that hint lets try one more thing :

Code:
 label n = returnReduce(mesh.cells().size(), sumOp<label>());
 Info << "Average Pressure : " << gSum(p)/n << endl;
Caelan
clapointe is offline   Reply With Quote

Old   August 9, 2018, 01:22
Default
  #9
New Member
 
Join Date: Aug 2018
Posts: 18
Rep Power: 8
nago is on a distinguished road
hi,

i try the code clapointe suggested.
finally i get AveragePressure, same as one from functionObject cellSource- average.

thank you for giving advice to my crude question.

Regard.
nago is offline   Reply With Quote

Reply

Tags
openfoam2.3.1


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
Lagrangian library: Edit particle properties within force calculation oswald OpenFOAM Programming & Development 8 April 5, 2018 12:47
Quick Question on Calculation Time Davitt COMSOL 0 January 14, 2016 15:16
Unanswered question niklas OpenFOAM 2 July 31, 2013 17:03
Solver and geometry choose for drag coefficient calculation around circular cylinder at large Re lin OpenFOAM Running, Solving & CFD 3 April 16, 2009 11:50
question K.L.Huang Siemens 1 March 29, 2000 05:57


All times are GMT -4. The time now is 22:45.