|
[Sponsors] |
May 29, 2013, 11:29 |
Counting non-zero values in a volScalarField
|
#1 |
New Member
Javier Motta
Join Date: May 2013
Posts: 4
Rep Power: 13 |
Hi all,
I'm running a custom pisoFoam solver in parallel (16 processors) and I'm having some issues with what I think should be a simple task. I have a mesh of about 460k cells, and have a volScalarField with lots of zeros. I would like to use an if statement inside of a for loop that loops through all the cells in the mesh, and checks to see if the ith value in the volScalarField is zero. If its zero, than it should increment a counter; if its not than do nothing. However, every time I've tried it I only manage to loop through one processor. If I remove the if statement and just have it increase the counter, I get back the total number of cells after I use reduce(counter, sumOp<int>()). Any ideas on how to make the if statement work? The relevant part of code is below Code:
forAll(mesh.cells(),celli) { if (bodyForceOld[celli] == 0) { counter_one++; } } reduce(counter_one, sumOp<int>()); Thanks, Javier |
|
May 29, 2013, 11:30 |
|
#2 |
New Member
Javier Motta
Join Date: May 2013
Posts: 4
Rep Power: 13 |
That title should read counting zero values in volScalarField, my apologies for the confusion
|
|
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
[openSmoke] libOpenSMOKE | Tobi | OpenFOAM Community Contributions | 562 | January 25, 2023 10:21 |
TimeVaryingMappedFixedValue | irishdave | OpenFOAM Running, Solving & CFD | 32 | June 16, 2021 07:55 |
Retrieving boundary patch values adjacent to a given cell | brooksmoses | OpenFOAM Post-Processing | 2 | December 8, 2008 11:00 |
Plotting raw data values | Wilesco | Siemens | 0 | January 5, 2006 06:34 |
Mass Flux values and calculations | Cb | Siemens | 1 | January 22, 2005 10:21 |