If you are a scientific programmer who writes code related to computational fluid dynamics, you really should rethink your whole stack. I am not trying to push my ideas on you / endorsing any commercial products. I have no interest in doing that unless some company is willing to pay to me do it. But i would simply like to shed light on something really basic yet very important in computational fluid dynamics.
I will start with data in general that goes in and comes out of CFD codes. There are a whole bunch of data formats used by cfd code developers. Some of them are as follows.
- .txt or .dat files (the good old write data in columns)
- .csv files (relatively good option)
- tecplot output files (meh.. never in a million years would i care for tecplot or take it seriously)
- .npy (you would know this if you are a numpy guy)
When you are young and starting out, you might find tecplot or the good old dat/csv to be very comfortable and that is okay. But when it comes to learning anything, it is always better if you learn to do things the correct way from the very beginning. Let us say you start writing an two dimensional unstructured cfd code and for meshing you use your own code. It would be really fun to write that for the purposes of learning. When you are done validating your code for a couple of cases say a wedge and a cylinder as follows.
The above meshes can be generated using a program and then used for the sake of learning. But if you wanted to study some other complex geometry in future, you would have to go through the trouble of doing things all over again and it would cost you more time than developing the actual algorithms. This causes a danger of you wasting almost twice as much time simply because you were too stubborn to adopt a new standard for your code. That standard is a library called Cfd General Notation System or shortly called CGNS. CGNS is a set of standards developed by NASA based on one of the best scientific data formats known as hdf5. I will not go into detail about hdf5 because that is coming seperately in yet another big blog post. But the above graphic gives a bunch of reasons on what draws people to their platform (yes! i stole the graphic from there) and i strongly encourage you to read online if you are interested in learning more about hdf5.
So we have established that CGNS is a set of fancy standards that sits on top of hdf5 yet i haven't explained how it could be actually useful for you. The great thing about CGNS is that almost every commercial and opensource mesh generator supports it. This means that you can use complex, multiblock, unstructured meshes with easy in your own CFD programs with a simple modification in the code. Even stanford's $SU^2$ supports cgns format. Hence it is very easily setup complex simulations based on their aerodynamic optimization tools and benefit at ease. At the end, your time is important than anything. Apart from meshing, you can write the output files in CGNS format too and that is supported by almost every single commercial and post processing software available out there.
Now the million dollar question is if the idea is sold yet? I have a simple example for you to understand things a little better.
c READ X, Y, Z GRID POINTS FROM CGNS FILE include 'cgnslib_f.h' c open CGNS file for read-only call cg_open_f('grid.cgns',CG_MODE_READ,index_file,ier) if (ier .ne. CG_OK) call cg_error_exit_f c we know there is only one base (real working code would check!) index_base=1 c we know there is only one zone (real working code would check!) index_zone=1 c get zone size (and name - although not needed here) call cg_zone_read_f(index_file,index_base,index_zone,zonename, + isize,ier) c lower range index irmin(1)=1 irmin(2)=1 irmin(3)=1 c upper range index of vertices irmax(1)=isize(1,1) irmax(2)=isize(2,1) irmax(3)=isize(3,1) c read grid coordinates call cg_coord_read_f(index_file,index_base,index_zone, + 'CoordinateX',RealSingle,irmin,irmax,x,ier) call cg_coord_read_f(index_file,index_base,index_zone, + 'CoordinateY',RealSingle,irmin,irmax,y,ier) call cg_coord_read_f(index_file,index_base,index_zone, + 'CoordinateZ',RealSingle,irmin,irmax,z,ier) c close CGNS file call cg_close_f(index_file,ier)
The above code reads a CGNS mesh into a fortran program. Once you have the grid data in your arrays, you can concentrate more on your algorithms and not worry about developing codes for mesh generation (unless your research work is on grid generation). The same goes for solution too. You need not spend a lot of time getting things write for your commercial plotting software. Since all post processors support CGNS, you could simply call the CGNS API and have it write them as CGNS files using the HDF5 data format.
I will definitely post some useful and real world examples in a week or so. So please check back on this post after some time and keep an eye on my github. It is vijaiaeroastro