CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   OpenFOAM Running, Solving & CFD (https://www.cfd-online.com/Forums/openfoam-solving/)
-   -   Problems accessing neighbour cells (https://www.cfd-online.com/Forums/openfoam-solving/127139-problems-accessing-neighbour-cells.html)

styleworker December 4, 2013 08:30

Problems accessing owner cells
 
3 Attachment(s)
Hello foamers,

I want to access the owner cells of a partical face. Sorry for the wrong topic title.

My mesh (see attached pictures) consists 72 nfaces with 24 nInternalFaces. With the following code, I'm gathering informations about points and faces for some other calculation.

Code:

forAll(mesh.cells(), cellI)
{
    cell faces = mesh.cells()[cellI]; // contains face indices of cellI: cellI=0: 6(0 1 24 36 40 41))

    forAll(faces, j)
    {
        label faceI = faces[j];
        face points = mesh.faces()[faceI];
        Info << mesh.owner().size() << endl; // size for this mesh is 24
        label ownCell = mesh.owner()[faceI]; //this line causes an error during calculation
    }
}

The error occurs during the first outer loop, when label ownCell tries to get access to mesh.owner()[24]. It is obvious, because the owner index ranges from 0 to 23 and the faceI index ranges from 0 to 71.

I'm a bit confused about the ordering. If I have a look at the constant/polyMesh/owner file (attached), I can see 72 entries which actually corresponds to the faceI range?!

Can anybody help?

P.S. I don't know if it's important, but the mesh was generated with Gmsh and converted via gmshToFoam.

Kind regards
Willy

styleworker December 4, 2013 11:08

I've found out, that the first 24 entries in constant/polyMesh/owner are identical to the values stored in mesh.owner(). As far as I know the first entries in a faceList are internal faces. This means, that mesh.owner() just stores internalFaces. Since mesh.cells()[faceI] includes boundary faces it won't work accessing boundary faces in mesh.owner().

I guess, I have to include an additional condition, which checks whether the face is an internalFace or not. Something like this

Code:

if(!mesh.isInternalFace(faceI)) continue;
But I actually need the owner of the boundary cells, too.

styleworker December 4, 2013 11:39

I've used the wrong function!

mesh.owner(): returns nInternalFaces (24)
mesh.faceOwner(): returns nFaces (72)


All times are GMT -4. The time now is 03:35.