# owner neighbour 网格寻址

•     const labelUList& owner = mesh_.owner();
const labelUList& neighbour = mesh_.neighbour();

forAll(weis_, kth)
{
forAll(sumWeisF[kth], cellI)
{

Info << "Current cell index is " << cellI << nl;

//- Loop the faces of cellI
forAll(mesh_.cells()[cellI], faceI)
{
//- Check if it is an internal face
if (mesh_.isInternalFace(mesh_.cells()[cellI][faceI]))
{
label faceIndex = mesh_.cells()[cellI][faceI];
Info << " its faceIndex is " << faceIndex;
Info << ", and this face's owner is "
<< owner[faceIndex] << ", its neighbour is "
<< neighbour[faceIndex] << nl;
}
}

Info << nl;
}
}


输出如下：

Current cell index is 851
its faceIndex is 1684, and this face's owner is 851, its neighbour is 852
its faceIndex is 1685, and this face's owner is 851, its neighbour is 896
its faceIndex is 1596, and this face's owner is 806, its neighbour is 851
its faceIndex is 1682, and this face's owner is 850, its neighbour is 851

Current cell index is 852
its faceIndex is 1686, and this face's owner is 852, its neighbour is 853
its faceIndex is 1687, and this face's owner is 852, its neighbour is 897
its faceIndex is 1598, and this face's owner is 807, its neighbour is 852
its faceIndex is 1684, and this face's owner is 851, its neighbour is 852



希望有用 :confused:

• 注意在变量赋值的时候要使用faceIndex而不是faceI，因为p[faceI]只是一直在1 2 3 4 5…中循环，p[faceIndex]是真正的面址

• @东岳 东岳老师，求问faceIndex 遍历的顺序是 右、上、下、左，这样固定的吗？

• 这个还没看，应该不是。如果你的网格不是正方体，是多面体，就没有上下左右了？