|
[Sponsors] |
August 8, 2018, 12:20 |
question about pallarel calculation.
|
#1 |
New Member
Join Date: Aug 2018
Posts: 18
Rep Power: 8 |
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. |
|
August 8, 2018, 15:24 |
|
#2 |
Senior Member
Join Date: Aug 2015
Posts: 494
Rep Power: 15 |
I think you can do it an easier way -- try adding this :
Code:
Info << "Average Pressure : " << gSum(p)/mesh.C().size() << endl; Caelan |
|
August 8, 2018, 23:02 |
|
#3 |
Senior Member
Yan Zhang
Join Date: May 2014
Posts: 120
Rep Power: 12 |
Code:
Info<< "Mean pressure:" << p.weightedAverage(mesh.V()).value() << endl;
__________________
https://openfoam.top |
|
August 8, 2018, 23:24 |
|
#4 |
New Member
Join Date: Aug 2018
Posts: 18
Rep Power: 8 |
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? |
|
August 8, 2018, 23:34 |
|
#5 |
New Member
Join Date: Aug 2018
Posts: 18
Rep Power: 8 |
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 ? |
|
August 8, 2018, 23:46 |
|
#6 |
Senior Member
Join Date: Aug 2015
Posts: 494
Rep Power: 15 |
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 |
|
August 9, 2018, 00:06 |
|
#7 |
New Member
Join Date: Aug 2018
Posts: 18
Rep Power: 8 |
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. |
|
August 9, 2018, 00:16 |
|
#8 |
Senior Member
Join Date: Aug 2015
Posts: 494
Rep Power: 15 |
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; |
|
August 9, 2018, 01:22 |
|
#9 |
New Member
Join Date: Aug 2018
Posts: 18
Rep Power: 8 |
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. |
|
Tags |
openfoam2.3.1 |
|
|
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 |