|
[Sponsors] |
May 12, 2011, 14:55 |
Looping over all cells in parallel
|
#1 |
Senior Member
Senthil Kabilan
Join Date: Mar 2009
Posts: 113
Rep Power: 17 |
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 |
|
May 13, 2011, 04:07 |
|
#2 |
Senior Member
Mark Olesen
Join Date: Mar 2009
Location: https://olesenm.github.io/
Posts: 1,679
Rep Power: 40 |
||
May 13, 2011, 06:31 |
|
#3 |
Assistant Moderator
Bernhard Gschaider
Join Date: Mar 2009
Posts: 4,225
Rep Power: 51 |
||
May 13, 2011, 12:57 |
|
#4 |
Senior Member
Senthil Kabilan
Join Date: Mar 2009
Posts: 113
Rep Power: 17 |
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 |
|
May 15, 2011, 17:29 |
|
#5 |
New Member
Ivan
Join Date: Sep 2010
Location: Russia , Moscow.
Posts: 14
Rep Power: 15 |
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] ; } } ; }; |
|
Thread Tools | Search this Thread |
Display Modes | |
|
|
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 |