[vtkusers] Weird behaviour for GetCellNeighbours

nzdexter peter.franz at mightyriver.co.nz
Thu Feb 14 20:32:07 EST 2013


My apologies if this is a double post - I have already posted this question
but after posting it got the reply that I needed to subscribe to the list
first. If this is a double post I would like to ask the moderator to delete
one of them.

So here's my problem: I have found a strange behaviour when looking up cell
neighbours, and if somebody can help me with what I am doing wrong here I'd
be eternally thankful.

The problem:

I am creating an earth model - a geothermal reservoir. My test model is a
structured grid, i.e. it has I=17, J=17, K=10 blocks which are linked to
form a large box (cube with undulated surface). Looking up neighbours in
such a grid would be quite simple, however I am planning to to more complex
models later on and I need an algorithm to look up neighbouring cells.

I tried using VTK's unstructured grid to do this for me. In the code below,
self.Grid.Grid is a vtkUnstructuredGrid object:


            cell = self.Grid.Grid.GetCell(block.CellID)
            neighbours = []
            Nfaces = cell.GetNumberOfFaces()
            for j in range(0,Nfaces):
                face = cell.GetFace(j)
                ptid = face.GetPointIds()
                cid = vtk.vtkIdList()
                self.Grid.Grid.GetCellNeighbors(block.CellID,ptid,cid)
                N = cid.GetNumberOfIds()
                for k in range(0,N):
                    if cid.GetId(k) != block.CellID:
                        neighbours.append(cid.GetId(k))


Now, using that code on my simple model I would expect a quite regular
behaviour. The corners should have 3 neighbous, the faces 5, the edges 4,
blocks in the centre should have 6.

However, what I get is the following:

2 Neighbours:
<http://vtk.1045678.n5.nabble.com/file/n5718558/Neighbours_2.png> 

3 Neighbours:
<http://vtk.1045678.n5.nabble.com/file/n5718558/Neighbours_3.png> 

4 Neighbours:
<http://vtk.1045678.n5.nabble.com/file/n5718558/Neighbours_4.png> 

5 Neighbours:
<http://vtk.1045678.n5.nabble.com/file/n5718558/Neighbours_5.png> 

6 Neighbours:
<http://vtk.1045678.n5.nabble.com/file/n5718558/Neighbours_6.png> 

All screenshots were taken from roughly the same angle.

I should also mention that the vertices are shared between the cells, i.e.
there are a total of (I+1)*(J+1)*(K+1) points in the model, and blocks
sharing a same vertex id.

Anybody got an idea? 



--
View this message in context: http://vtk.1045678.n5.nabble.com/Weird-behaviour-for-GetCellNeighbours-tp5718558.html
Sent from the VTK - Users mailing list archive at Nabble.com.



More information about the vtkusers mailing list