|
[Sponsors] |
November 2, 2010, 16:01 |
|
#2 |
Super Moderator
Philip Cardiff
Join Date: Mar 2009
Location: Dublin, Ireland
Posts: 1,093
Rep Power: 34 |
Hi,
I think that gSum() is global sum, which means that gSum() sums over all the processors in a parallel run. Philip |
|
June 1, 2018, 03:04 |
|
#3 |
New Member
javad haqqani
Join Date: Dec 2017
Posts: 16
Rep Power: 8 |
Now how can one perform a partial summation? I need to sum up half of a volScalarField.
|
|
June 1, 2018, 05:21 |
|
#4 | |
Super Moderator
Philip Cardiff
Join Date: Mar 2009
Location: Dublin, Ireland
Posts: 1,093
Rep Power: 34 |
Quote:
Code:
scalar sumVf = 0.0; forAll(vf, cellI) { // Sum up cells with a cell index less than 5 (you can use your own criteria here) if (cellI < 5) { sumVf += vf[cellI]; } } // Sync sum across processors reduce(sumVf, sumOp<scalar>()); Info<< "The global sumVf is: " << sumVf << endl; |
||
June 1, 2018, 06:23 |
|
#5 |
New Member
javad haqqani
Join Date: Dec 2017
Posts: 16
Rep Power: 8 |
I've done that; but I need Vf's dimension. Plus, i'm dealing with very small numbers and the vf[cellI] gives a very large value when the real velue is very small as 1e-100.
|
|
June 1, 2018, 07:37 |
|
#6 | |
Super Moderator
Philip Cardiff
Join Date: Mar 2009
Location: Dublin, Ireland
Posts: 1,093
Rep Power: 34 |
Quote:
Code:
vf.dimensions(); As regards "vf[cellI] gives a very large value when the real value is very small as 1e-100": this should not be the case: if vf[cellI] is equal to 1e-100 then that is what it should return; if you are getting some other large number then I suggest you check that you are not indexing outside the bounds of the array. Also, I suggest you give more details about your problem and your attempted solutions. |
||
February 4, 2023, 21:34 |
|
#7 | |
Senior Member
Farzad Faraji
Join Date: Nov 2019
Posts: 206
Rep Power: 8 |
Dear Philip
Thanks for explaining how to use "reduce" command properly. I have another question; Code:
volScalarField kineticEnergy0("kineticEnergy0", 0.5*magSqr(U)); Info << "size of-kineticEnergy0 = " << kineticEnergy0.size() << endl; Code:
scalar kineticEnergy0Ave = gAverage(kineticEnergy0); Thanks, Farzad Quote:
|
||
February 7, 2023, 06:32 |
|
#8 |
Super Moderator
Philip Cardiff
Join Date: Mar 2009
Location: Dublin, Ireland
Posts: 1,093
Rep Power: 34 |
The total energy can be calculated as
Code:
const volScalarField kineticEnergy("kineticEnergy", 0.5*magSqr(U)); const scalar totalKineticEnergy = gSum(kineticEnergy); Code:
const scalar averageKineticEnergy = gAverage(kineticEnergy); Code:
const scalar volumeWeightedAverageKineticEnergy = gAverage(kineticEnergy.primitiveField()*mesh.V())/gSum(mesh.V()); |
|
Tags |
gsum(), sum() |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Transient simulation not converging | skabilan | OpenFOAM Running, Solving & CFD | 14 | December 17, 2019 00:12 |
How to write k and epsilon before the abnormal end | xiuying | OpenFOAM Running, Solving & CFD | 8 | August 27, 2013 16:33 |
Convergence moving mesh | lr103476 | OpenFOAM Running, Solving & CFD | 30 | November 19, 2007 15:09 |
IcoFoam parallel woes | msrinath80 | OpenFOAM Running, Solving & CFD | 9 | July 22, 2007 03:58 |
Could anybody help me see this error and give help | liugx212 | OpenFOAM Running, Solving & CFD | 3 | January 4, 2006 19:07 |