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

Counting non-zero values in a volScalarField

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

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   May 29, 2013, 11:29
Default Counting non-zero values in a volScalarField
  #1
New Member
 
Javier Motta
Join Date: May 2013
Posts: 4
Rep Power: 12
javier_motta is on a distinguished road
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
javier_motta is offline   Reply With Quote

Old   May 29, 2013, 11:30
Default
  #2
New Member
 
Javier Motta
Join Date: May 2013
Posts: 4
Rep Power: 12
javier_motta is on a distinguished road
That title should read counting zero values in volScalarField, my apologies for the confusion
javier_motta is offline   Reply With Quote

Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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
[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


All times are GMT -4. The time now is 00:59.