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

Looping over all cells in parallel

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

Like Tree2Likes
  • 1 Post By skabilan
  • 1 Post By Zato_Ichi

Reply
 
LinkBack Thread Tools Display Modes
Old   May 12, 2011, 14:55
Default Looping over all cells in parallel
  #1
Senior Member
 
Senthil Kabilan
Join Date: Mar 2009
Posts: 113
Rep Power: 7
skabilan is on a distinguished road
Hi Foamers,

The following code works good on a single processor but not on multiple processors...

forAll( mesh.C(), celli)
{
.
.
.
}

How can I make this work on multiple processors?

Thanks
Senthil
skabilan is offline   Reply With Quote

Old   May 13, 2011, 04:07
Default
  #2
Senior Member
 
Mark Olesen
Join Date: Mar 2009
Location: http://olesenm.github.io/
Posts: 776
Rep Power: 17
olesen will become famous soon enough
Quote:
Originally Posted by skabilan View Post
Hi Foamers,

The following code works good on a single processor but not on multiple processors...

forAll( mesh.C(), celli)
{
.
.
.
}

How can I make this work on multiple processors?
This should work fine on every processor. Where is the issue?
olesen is offline   Reply With Quote

Old   May 13, 2011, 06:31
Default
  #3
Assistant Moderator
 
Bernhard Gschaider
Join Date: Mar 2009
Posts: 3,862
Rep Power: 38
gschaider will become famous soon enoughgschaider will become famous soon enough
Quote:
Originally Posted by olesen View Post
This should work fine on every processor. Where is the issue?
I guess his problem is what's in the loop. The answer to his problem will probably contain "reduce" or "correctBoundaryConditions"
gschaider is offline   Reply With Quote

Old   May 13, 2011, 12:57
Default
  #4
Senior Member
 
Senthil Kabilan
Join Date: Mar 2009
Posts: 113
Rep Power: 7
skabilan is on a distinguished road
Thanks for the response...Actually, I figured out what was missing...I had to use a "reduce" call to sum over all the processors and not just one processor. Like

reduce(U_flux, sumOp<scalar>());

Senthil
hua1015 likes this.
skabilan is offline   Reply With Quote

Old   May 15, 2011, 17:29
Default
  #5
New Member
 
Ivan
Join Date: Sep 2010
Location: Russia , Moscow.
Posts: 12
Rep Power: 6
Zato_Ichi is on a distinguished road
Hello everyone.

I have a problem with forAll loop in parallel too. There is a piece of my code, and i don't know how to extend it for parallel calculations. It calculates mass flux deltaM through cell faces.

Code:
scalarField& deltaMi = deltaM.internalField();    
deltaMi = 0 ;

    forAll(owner, faceI)
    {
        
        label P = owner[faceI] ;
        label N = neighbour[faceI] ;

        dir = (Ui[P]+ Ui[N]) & mesh.Sf()[faceI] ;

        if (dir >= 0)
        {
            deltaMi[faceI] = (0.5*rho[P]*(deltaT.value())*(U[P] + U[N])) & mesh.Sf()[faceI] ;
        }
        else
        {
              deltaMi[faceI] = (0.5*rho[N]*(deltaT.value())*(U[P] + U[N])) & mesh.Sf()[faceI] ;
         }
    
        
        if (mag(deltaMi[faceI]) < 1e-20) 
            
            deltaMi[faceI] = 0 ;

    } ;

    forAll(mesh.boundary(),patchI)
    {
        fvsPatchScalarField& pfdeltaM = deltaM.boundaryField()[patchI] ;
        const fvPatchVectorField& pfU = U.boundaryField()[patchI] ;
        const fvPatchScalarField& pfp = p.boundaryField()[patchI] ;
        const fvPatchScalarField& pfrho = rho.boundaryField()[patchI] ;
        const unallocLabelList& faceCells = mesh.boundary()[patchI].faceCells();
        const vectorField& pSf = mesh.Sf().boundaryField()[patchI];
        
        forAll(mesh.boundary()[patchI], faceI)
        {

        dir = (pfU[faceI] + U[faceCells[faceI]]) & pSf[faceI] ;

        if (dir >= 0)
        {
            pfdeltaM[faceI] = (rho[faceCells[faceI]]*deltaT.value()*(pfU[faceI])) & pSf[faceI] ;
        }
        else
        {
            pfdeltaM[faceI] = (pfrho[faceI]*deltaT.value()*(pfU[faceI])) & pSf[faceI] ;
        }
        } ;

    };
Any tips ?
mm.abdollahzadeh likes this.
Zato_Ichi 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
Import netgen mesh to OpenFOAM hsieh Open Source Meshers: Gmsh, Netgen, CGNS, ... 32 September 13, 2011 06:50
snappyHexMesh won't work - zeros everywhere! sc298 OpenFOAM Native Meshers: snappyHexMesh and Others 2 March 27, 2011 22:11
snappyHexMesh aborting Tobi OpenFOAM Native Meshers: snappyHexMesh and Others 0 November 10, 2010 04:23
external flow with snappyHexMesh chelvistero OpenFOAM 11 January 15, 2010 20:43
physical boundary error!! kris CD-adapco 2 August 3, 2005 01:32


All times are GMT -4. The time now is 01:15.