CFD Online Discussion Forums

CFD Online Discussion Forums (
-   OpenFOAM Running, Solving & CFD (
-   -   Access to face neighbours (

irishdave July 25, 2007 05:54

Hello, I am sure this shoul

I am sure this should be elementary but I'm really struggling with finding a straightforward way to take a cell and find its neighbours?

I have set up the mesh in my script and I've been looking through the documentation for the fvMesh, polyMesh and primitiveMesh yet I am unable to find something that seems to be what I need.

What I want to be able to do is take a for loop running through each cell in the mesh (which I can create no problem) and then obtain the cells neighbouring it (either by function or obtaining it from a list initialized outside the loop) and also obtain the face between them.


hjasak July 25, 2007 06:27

mesh.cellCells(). Could it be
mesh.cellCells(). Could it be easier?


hjasak July 25, 2007 06:31

Forgot: for faces, you can ask
Forgot: for faces, you can ask for mesh.owner() and mesh.neighbour(). For the owner, the face area vector points outwards.

Keep in mind that you are now working with a face-addressed code and that the number of faces (or indeed cell neighbours) varies. You may wish to re-consider the organisation of your algorithms to reflect the face addressing.



grtabor July 25, 2007 06:34

> mesh.cellCells(). Could it b
> mesh.cellCells(). Could it be easier?

> Hrv

I suppose it could write the code for you! Must talk to the guys around here who are working on Evolutionary Computing about that one - a CFD code that self-evolves to get the modelling correct.


irishdave July 26, 2007 09:17

Hey, Thanks for the help, i

Thanks for the help, it's working perfectly for me. My mind was stuck on cell addressed code instead of face addressed and now it makes sense and seems to be working so far. Thanks for the offer Gavin but I think I'm getting there ok now.


All times are GMT -4. The time now is 17:19.