Parsing SLCF file

483 views
Skip to first unread message

Simon Ben Arous

unread,
Dec 7, 2020, 6:21:55 AM12/7/20
to FDS and Smokeview Discussions
Hello there,

I'm working with python, and I'm trying to automatically read the .sf file. Unfortunately I cannot read fortran, so reverse engineering fds2ascii is impossible for me.

Working from the slread.py as a basis, my guess as to how the .sf file is structured is the following:

4 header bytes (no data)
30 bytes corresponding to the quantity (utf-8)
8 intermediate bytes (no data)
30 bytes corresponding to the short name (utf-8)
8 intermediate bytes (no data)
30 bytes corresponding to the units (utf-8)
8 intermediate bytes (no data)
24 bytes for 6 integers, representing the bounds
 8 intermediate bytes (no data)

Followed by data entries, with the format:
one time entry, 4 bytes float
8 intermediate bytes (no data)
IxJxK floats for the values in each grid cells, all represented by 4 bytes floats (I, J and K being the number of cells in each directions, read in the first part of the code)
8 intermediate bytes (no data)

repeating over all simulation times.

First of all, am I right ?

Second, when parsing the file like this I don't get as many data entries as expected: especially, it seems that I only get one time slice, while I expect ten (see the tattached input file) because I did not specify any time-averaging.
What am I missing here ?

If that may help, I can provide the binary .sf file that resulted from the simulation. (Note that it's a mock-up simulation, it runs really fast)

Thanks in advance for your precious help !
Best,

Simon

point_source.fds

Glenn Forney

unread,
Dec 7, 2020, 7:23:41 AM12/7/20
to fds...@googlegroups.com
The slice file format is documented in the fds users guide. There is an extra 4 bytes output before and after each write listed in the guide . Load the file with smokeview, how many time steps does it see?

--
You received this message because you are subscribed to the Google Groups "FDS and Smokeview Discussions" group.
To unsubscribe from this group and stop receiving emails from it, send an email to fds-smv+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/fds-smv/6e15a03c-c5b2-4095-a400-10c9d424d48en%40googlegroups.com.

Randy McDermott

unread,
Dec 7, 2020, 8:55:22 AM12/7/20
to FDS and Smokeview Discussions
Your input file generates a large 3D slice file.  I would start with an easier case.  Attached is a revamp of your input file, plus scripts to parse the .sf using Python.  FDS_SLCF_Contour.py calls spread.py.

slread.py
FDS_SLCF_Contour.py
point_source.fds

Simon Ben Arous

unread,
Dec 7, 2020, 12:19:23 PM12/7/20
to FDS and Smokeview Discussions
@Glenn Forney Thanks a lot for your quick answer  !

I'm not sure how to get the number  of slices in smokeview, it keeps looping rapidly in between 0 and 1 (T_start and T_end) when I load the slice. Though, when in go into the setting and try to manually set the time I can only get the values for t=0.2, 0.4, 0.6, 0.8 and 1.0 (5 values). Is that what you meant ?

@Randy

Thanks for this example. With a small tweak (file names in FDS_SLCF.py) it works perfectly. It looks like you explicitly specified the slice to be at y=10 in the input fds file. If I'm correct, then slread.py works perfectly since it parses this 2D slice (dim of Qskip is nx, nz, nt).
In my case, I had it set so that the 3D file was on purpose 3-dimensional (+time). I actually planned to do the spatial slicing afterwards, on the "big file". Do you mean this is not possible ?
If it is, then I assume that slread.py is not suited for the parsing, because of the very shape of Qskip. Would you have some ressource available for me to try to achieve such parsing ? Thanks a lot for your help already !

Randy McDermott

unread,
Dec 7, 2020, 12:25:57 PM12/7/20
to FDS and Smokeview Discussions
I don't understand your question.  You simply need to use slread.py to loop through the slices 2D slices in 3D.  There is already a 3D example in Matlab you can translate.  See fds/Utilities/Matlab/scripts/



Simon Ben Arous

unread,
Dec 8, 2020, 5:23:55 AM12/8/20
to FDS and Smokeview Discussions
@Randy thanks for redirecting me to the Matlab 3D script, this is what I needed.
I don't know Matlab but it's close enough to python to do the translation. And another thing that I actually missed, and which messed up all the parsing, is that the 3D slices dump frequency is controlled with DT_SL3D.

Now everything is all right. Thanks for your help !

Randy McDermott

unread,
Dec 8, 2020, 7:59:47 AM12/8/20
to FDS and Smokeview Discussions
Glad it's working for you.  If you get something functional in 3D with Python, please consider contributing it to the repo.  Thanks

Simon Ben Arous

unread,
Dec 8, 2020, 10:36:51 AM12/8/20
to FDS and Smokeview Discussions
Will do for sure when everything is tested properly !

Jonathan Hodges

unread,
Dec 9, 2020, 9:03:58 AM12/9/20
to FDS and Smokeview Discussions
All, I wanted to share the post-processing toolbox I've developed for FDS which uses python. I am planning to publish more extensive documentation in the future, but I thought it would be useful to provide early access so we are not duplicating effort. It has the functionality to read most of the binary data files (boundary, 2-D slice, 3-D slice, plot3d) generated by FDS. The examples.py script highlights some of the functionality of the toolbox; however, there are a lot more undocumented features available. Feel free to reach out or submit an issue to the repo if you are unsure if it has a specific feature. 

You can find the repository here:


One of the examples provided in examples.py reads all the data from a 3-D slice and extracts a 2-D slice at a queried axis location. The file "extractPlot3Ddata.py" has the subroutines related to reading slice files. I've tested the routines with multiple meshes and different size meshes, and verified it is working as expected. Please let me know if you observe any issues. One issue you may run into with your current data is the 3-D slice subroutine currently reads the grid coordinates from the (.xyz) files generated by FDS. You can tell FDS to output these files by adding WRITE_XYZ=.TRUE. to the DUMP namelist in the input file. Note, if you did not generate these files at run-time, you can copy your input file to a new directory, add the line, run FDS for one time step, then copy the generated (.xyz) files to your results directory.

Thanks,

Jonathan

Randy McDermott

unread,
Dec 9, 2020, 9:14:49 AM12/9/20
to FDS and Smokeview Discussions
Jonathon,

Thanks! I'm particularly interested in your boundary file tool.  We've had a lot of requests for this over the years.  It could be very useful for coupling FDS to a structural model, for example.

Would you like me to add this to our Third Party Tools webpage?

Jonathan Hodges

unread,
Dec 9, 2020, 9:38:45 AM12/9/20
to FDS and Smokeview Discussions
Hey Randy. I agree it is a good starting point for coupling with a structural model. Let me know if you want to discuss in more detail and we can set up a call. I'll send alternate contact information in a private message since I don't always check my VT email these days.

Yes, please add it to the Third Party Tools wiki. Hopefully not too many issues are identified over the holidays!

Lukas A.

unread,
Dec 9, 2020, 10:49:58 AM12/9/20
to FDS and Smokeview Discussions
Dear all,

I would like to chime in, as we have a similar tool to read in FDS generated data (SLCF, ISOF, BNDF, PART, etc. ) as Python numpy structures. Especially including the geometrical informations and multi-mesh data. This module started as a reengineering of a collection of individual scripts we used at our institute. Currently, Jan, our new team member works on this module. So, I think it could make sense to get in touch to evaluate if it makes sense to join forces here. What do you think? 

@Simon, I have also tried to reach out to you, but probably my message did not reach you (yet).

Best
Lukas

Jonathan Hodges

unread,
Dec 9, 2020, 11:02:19 AM12/9/20
to FDS and Smokeview Discussions
Hello Lukas. I agree it makes sense for us to discuss our parallel efforts. I will send you a follow-up email for scheduling.

emanuel...@gmail.com

unread,
Dec 10, 2020, 2:31:47 AM12/10/20
to FDS and Smokeview Discussions
Hi Lukas and Jonathan,
what you are doing is very interesting.
What about joining forces with the firetools preprocessing part, too?
Our tools are written in Python as well, here is the github repo: https://github.com/firetools
The repo currently contains BlenderFDS (general purpose preprocessor), qgis2fds (importing geographic data from any source), and syntax highlighing.
Best,
Emanuele

Lukas A.

unread,
Dec 10, 2020, 12:24:14 PM12/10/20
to FDS and Smokeview Discussions
Dear Emanuele,

I have just contacted you via email. 

Best
Lukas

Reply all
Reply to author
Forward
0 new messages