CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   OpenFOAM Programming & Development (https://www.cfd-online.com/Forums/openfoam-programming-development/)
-   -   loop over cells in parallel processing (https://www.cfd-online.com/Forums/openfoam-programming-development/147198-loop-over-cells-parallel-processing.html)

Mat_fr January 15, 2015 05:18

loop over cells in parallel processing
 
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 :

Code:

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

    forAll(mesh.C(), cellI)
    {
        Mask2[cellI]=0;
        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;
                    }
                    else{
                        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

Mat_fr February 11, 2015 11:16

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 ?

Best,
Mat


All times are GMT -4. The time now is 09:52.