Mesh information like points, faces and cells is to be stored into separate files:

e.g. for points file:

# points data: x y z

N_Points 100

x1 y1 z1

x2 y2 z2


cell file:

# cells data: cell type and points index - clockwise (6: tri; 9:quad)

N_Cells 20

9 3 1 2 0

9 2 5 6 1

6 2 3 5


here # is comment, and N_Points is the size of vector used to store these information.

I used to store these information directly to ascII files with just numbers, in which each line has same format.

For AscII file with comments, name-value pair and numbers, it is more readable, but I have no idea how to read different type of lines from txt file properly. I appreciate any tips to get this simple job done.

  • 2
    $\begingroup$ This seems to be a purely programming question and not related (directly) to computational science. $\endgroup$
    – nicoguaro
    Jul 10, 2019 at 18:51
  • $\begingroup$ it is certainly a borderline question for this community. Do you have a data format you envision already? Example? Do you want to look at some existing formats (say, VTU), which would be more general that you need? I think I would be able to give an answer relevant to the community (and possibly helpful to you) if you are more specific. $\endgroup$
    – Anton Menshov
    Jul 10, 2019 at 20:01
  • $\begingroup$ @AntonMenshov The mesh geometry information, as well as boundary faces and internal faces (and the neighbor cells) are used for finite volume method (CFD). Some general mesh file format like VTK, STL is not appropriate for this task. Rather than saving all the information in a single ascii file, storing each type of data (e.g. points) in an individual file is easier and more readable. $\endgroup$
    – KOF
    Jul 11, 2019 at 6:17
  • $\begingroup$ @KOF so, do I understand it right, that data excerpts in the questions are samples of what you want to read correctly? Where do comments can appear in the datafile? A representative sample is needed if the current cases in the question do not cover all. $\endgroup$
    – Anton Menshov
    Jul 11, 2019 at 14:52
  • $\begingroup$ I guess there are many scientific, open-source codes out there, that do exactly that. One example would be OpenFOAM. It stores its mesh information in several files, see the user guide. However, the way this is actually done -- meaning the C++ code -- is buried deep within its sources. $\endgroup$
    – Dohn Joe
    Jul 12, 2019 at 8:07


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.