star4ToFoam and foamToStarMesh conversion methods

Been trying to figure out the format of the StarCD mesh (mesh.cel file) format which was quite baffling. Eventually found it easier to write a polyhedral cell directly to foam format (in the polyMesh directory - ie boundary, faces, owner, points etc) and then convert it back to star mesh using foamToStarMesh utility. Thought I would include this simple polyhedral example in case anyone else is struggling with similar issues.

Hi @garcfd ,

This is a ParaView discourse, not an OpenFOAM or StarCD discourse.


I’m not struggling with it (since I wrote the star4ToFoam utility in the first place), but if you are looking for documentation here are some good places to start (from openfoam info):

The polyhedral format is very, very much like the VTK legacy output for vtkPolyhedron, which makes sense since this was also discussed during the development of vtkPolyhedron back in the day.

The parsing of the starcd-4 format is also already in ParaView/VTK, where it is called “pro-STAR” format. If you look at the corresponding VTK proSTAR reader you will notice that the comments are almost the same as the OpenFOAM source code since the code base was essentially the same but with slightly different parsers and backends (and different licenses).

Hi Mark,

Thanks for that background information…
So now I can read Prostar files into Paraview.
and I can do foamToStar (and starToFoam)
the only thing want to be able to do now is to save in Prostar format (from Paraview)

Ideally what Id like to be able to do is clip a mesh (eg VTK5 with polyhedrals) in Paraview and then write that clipped mesh out in Foam format (the usual polyMesh directory files).

I don’t think you will have much joy with that approach. Clipping polyhedrals in paraview/vtk will often produce non-manifold faces (or a similar warning that often floods the screen).
Nonetheless, assuming it works you are of course missing the writing routine. You could write out as VTK legacy, which is fairly forgiving to parse (take a look at vtkUnstructuredReader for some methods. It does not yet have read support for polyhedral (we’ve mostly just used it for surface meshes), but it presumably not that bad to add. Alternatively (probably even easier) is to have a perl/python script to munge the vtk legacy into starcd format.

In either case the main issue that you will face is how to manage boundary patches. You need to put some thought into that before tackling the rest. BTW: I remember someone wanting to read in ensight files directly into OpenFOAM. The boundaries are again a major blocking point, the next being reordering cells from ensight (where things are sorted by element type) as well as handling duplicate points arising from face parts. All not as easier as you might hope.

Thanks again Mark - its good to have someone who knows what they are talking about,
which is more than I do at the moment. It might not be a bad idea (for me) to try and update the vtkToFoam for polyhedral cells. Regards, Giles.