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

Looping over all cells in parallel

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

Like Tree3Likes
  • 2 Post By skabilan
  • 1 Post By Zato_Ichi

Reply
 
LinkBack Thread Tools Search this Thread 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: 17
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: https://olesenm.github.io/
Posts: 1,679
Rep Power: 40
olesen has a spectacular aura aboutolesen has a spectacular aura about
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: 4,225
Rep Power: 51
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: 17
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 and hnsxmh like 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: 14
Rep Power: 15
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 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
[Netgen] Import netgen mesh to OpenFOAM hsieh OpenFOAM Meshing & Mesh Conversion 32 September 13, 2011 06:50
[snappyHexMesh] snappyHexMesh won't work - zeros everywhere! sc298 OpenFOAM Meshing & Mesh Conversion 2 March 27, 2011 22:11
[snappyHexMesh] snappyHexMesh aborting Tobi OpenFOAM Meshing & Mesh Conversion 0 November 10, 2010 04:23
[snappyHexMesh] external flow with snappyHexMesh chelvistero OpenFOAM Meshing & Mesh Conversion 11 January 15, 2010 20:43
physical boundary error!! kris Siemens 2 August 3, 2005 01:32


All times are GMT -4. The time now is 05:24.