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

Counting non-zero values in a volScalarField

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

Reply
 
LinkBack Thread Tools Display Modes
Old   May 29, 2013, 10:29
Default Counting non-zero values in a volScalarField
  #1
New Member
 
Javier Motta
Join Date: May 2013
Posts: 4
Rep Power: 5
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, 10:30
Default
  #2
New Member
 
Javier Motta
Join Date: May 2013
Posts: 4
Rep Power: 5
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
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 On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
libOpenSMOKE Tobi OpenFOAM Programming & Development 507 March 4, 2016 05:30
TimeVaryingMappedFixedValue irishdave OpenFOAM Running, Solving & CFD 28 May 28, 2015 13:37
Retrieving boundary patch values adjacent to a given cell brooksmoses OpenFOAM Post-Processing 2 December 8, 2008 11:00
Plotting raw data values Wilesco CD-adapco 0 January 5, 2006 06:34
Mass Flux values and calculations Cb CD-adapco 1 January 22, 2005 10:21


All times are GMT -4. The time now is 02:49.