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/)
-   -   Access processor patches in parallel run (https://www.cfd-online.com/Forums/openfoam-programming-development/166541-access-processor-patches-parallel-run.html)

mheinz February 11, 2016 10:03

Access processor patches in parallel run
 
Hello together,

I am currently working with the wallDist functionality to compute the distance of each cell to its nearest wall. After that I want to cut the data regarding some criterions. Everything works fine, when I calculate on one processor. However, when performing a parallel run, I need to access the patches that connect the seperated meshes of each processor. That's where I need help.
Here is some of the code, that needs fixing:

Code:

cellDist = wallDist(mesh).y();

const fvPatchList& patches = mesh.boundary();
forAll (patches, iPatch)
{
    const fvPatch& singlePatch = patches[iPatch];
    forAll (singlePatch, iFace)
    {
        label iFaceCell = singlePatch.faceCell()[iFace];
        cellDist[iFaceCell] = 0.0;
    }
}

This way, I tried to access all boundary patches (mesh.boundary()), but the "processor patches" are not recognized as such.

I'm thankful for any advice.

Michael

chriss85 February 12, 2016 03:54

You can combine lists from separate processors using the following function. This can be used for face positions, areas, field values etc..
Code:

template<class Type>
    void combineFields(Field<Type>& field)
    {
        List<Field<Type> > allValues(Pstream::nProcs());

        allValues[Pstream::myProcNo()] = field;

        Pstream::gatherList(allValues);
        Pstream::scatterList(allValues);

        field =
        ListListOps::combine<Field<Type> >
        (
            allValues,
            accessOp<Field<Type> >()
        );
    }



All times are GMT -4. The time now is 12:23.