CFD Online Logo CFD Online URL
Home > Forums > OpenFOAM Programming & Development

loop over cells in parallel processing

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

LinkBack Thread Tools Display Modes
Old   January 15, 2015, 06:18
Default loop over cells in parallel processing
Join Date: Jan 2012
Posts: 41
Rep Power: 7
Mat_fr is on a distinguished road
Dear Foamers,

For my computations, I'm using a VolScalarField representing a mask, which is either 0 or 1. This mask was obtained previously with triSurface functions, and gives a representation of a volume geometry. This was done perfectly in parallel.

Now, I want to define a new mask, named mask2, which defines the layer of cells surrounding the previous volume. Practically, for all the cells where mask = 0, and which have at least one neighbor where mask=1, then mask2=1.
I've implemented it like that :

const unallocLabelList & nei = mesh.neighbour();
    const unallocLabelList & own = mesh.owner();

    forAll(mesh.C(), cellI)
        if (Mask[cellI]==0){
            const cell& faces = mesh.cells()[cellI];
            forAll(faces, faceI){
                if (mesh.isInternalFace(faces[faceI]))
                    label owner = own[faces[faceI]];
                    label neigh = nei[faces[faceI]];
                    if (owner==cellI){
                        if (Mask[neigh]==1) Mask2[cellI]=1;
                        if (Mask[owner]==1) Mask2[cellI]=1;

Unfortunately, its not working in parallel, when the separation between two processors matches the volume interface. Some cells which must be in the surrounding layer are missing. I suppose it is because the owner proc is not finding the true value of the mask for the neighbors which are in another proc.

How can I handle that ? Do I have to write the parallel communication by myself ?

Thanks for your help.
Mat_fr is offline   Reply With Quote

Old   February 11, 2015, 12:16
Join Date: Jan 2012
Posts: 41
Rep Power: 7
Mat_fr is on a distinguished road
Hi Foamers,

My error was that the condition "if (mesh.isInternalFace(faces[faceI]))" excludes all the faces between two processors in parallel. They are not internal faces in this case.

By the way, I think it is not possible to define such a scalar field by looping over the cells in parallel, without implementing ourself the communications between processors.

Another way to do so, its by using the gradient of the masks. However, I've realized that I do not obtain the same results for fvc:grad() in sequential and in parallel !! Why ?

Mat_fr is offline   Reply With Quote


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
Parallel processing of OpenFOAM cases on multicore processor??? g.akbari OpenFOAM Running, Solving & CFD 31 November 1, 2017 10:25
Foam::error::PrintStack almir OpenFOAM Running, Solving & CFD 83 July 22, 2017 08:26
simpleFoam parallel AndrewMortimer OpenFOAM Running, Solving & CFD 12 August 7, 2015 18:45
external flow with snappyHexMesh chelvistero OpenFOAM 11 January 15, 2010 20:43
couple cells from different meshes in parallel sylvester OpenFOAM Programming & Development 8 September 29, 2009 04:04

All times are GMT -4. The time now is 08:16.