CFD Online Discussion Forums

CFD Online Discussion Forums (
-   Main CFD Forum (
-   -   CGNS unstructured in own solver (

nico May 13, 2006 13:34

CGNS unstructured in own solver

I am currently adding CGNS to a unstructured solver. CGNS seems to be cell based (vertices are defined for the cell) and not face based as other format (like fluent). This cause several problems, since the solver is obviously face based. Basicly i need the to be able to get indices of left and right cell to a face. Unfortunately in this cell based format, this would require to check for same faces: *go through all cells and store cell faces *go through all faces, and see if the face has been defined before so that it can be deleted.

This last operation is approximately a loop of nf*nf*0.5 (where nf is number of faces) this is obviously very time consuming for large grids.

I expect that i have something missing, since Fluent seems to be able to load the mesh quite quickly.

I have also seen that CGNS group is looking at face-based support for the future.



Hrvoje Jasak May 14, 2006 08:19

Re: CGNS unstructured in own solver
You can do much better than that - there is absolutely no need for a n-squared search.

First, create a point-cell connectivity, listing all cells around a point. Second, make a list of indices for each cell where you will record the faces that vave already been created. Third, loop through all cells and for each cell visit all faces. If the face has already been detected, skip it. Fourth, for each new face, grab point zero and get a list of cells around that point (call it cpf). Then, take the second point of the face, go through the small list (cpf) and ask each cell if it's got the second point. Repeat for the third point etc. This will give you the cell you need. Now, check the other cell to find the identical face, add the face to the face list with its owner and neighbour cell and record the new face in both cells.

If the mesh is full-regular, 3 points is enough to eliminate all but one cell, but you can easily keep going until there is only one. If you get more than one, this would indicate that 3 cells are sharing a face, which is an error in the mesh (the algorithm does not really care).



nico May 14, 2006 13:25

Re: CGNS unstructured in own solver
Yep, much better, much faster :) and nice way to do it. Thanks a lot.

Chris May 18, 2006 16:31

Re: CGNS unstructured in own solver
Alternatively, just run through the cells and look up each face of the current cell using a face hash table, where the hash key is the (order independent) list of face vertices. If the face is not in the table, create the face. If it is already there, add this cell as the second cell for the face.

With a decent hash function (fast and well-distributed) this will be faster and use less memory than the vertex connectivity approach.

All times are GMT -4. The time now is 02:41.