COLLAPSED OUTPUT

Often one wishes to look at quantities integrated over one particular direction (collapsing), yielding e.g. column densities. For this purpose BHAC can output line integrals of the simulation variables (plus user-specified variables) during runtime.
The current implementation is efficient as we take advantage of the grid structure; however only collapsing along cooridnate directions is currently possible (which is often sufficient). The user can freely specify the resolution (collapseLevel) of the resulting output data. No re-gridding of the domain is required, higher levels on the output grid are filled with flat interpolation.
Note that collapsing of 1D output is not fully implemented. Collapsed output is sensitive to the switch saveprim of the filelist section, therefore primitive variable output at runtime is possible. Also the switch nwauxio affects the collapsed view to output user-defined variables.
This page: [Setup in par file] [Collapsing of existing output] [ASCII output]

Setup in par file

Collapsed views are the fourth file format with output intervals that can be specified in the savelist section of the par file. To give an example, here we ask for collapsed arrays in all three coordinate directions, where the logical collapse(1)=T specifies to output arrays integrated over the first coordinate direction. The other directions are analoguous.
 &savelist
        itsave(1,4)      = 0
        dtsave(4)        = 0.1d0
        collapse(1)      = T
        collapse(2)      = T
        collapse(3)      = T
        collapseLevel    = 3
/
In the standard configuration, BHAC will output *.vti files. In addition, you can select ascii *.csv files.

This is controlled in the filelist:

  &filelist
        collapse_type = 'vti' | 'csv'
/
The *.vti files can be visualized directly with paraview or loaded witht the Python tools using the class read.loadvti.

The output filename is composed of the direction and level. For example, the first collapsed output name reads filenameout_d1_l3_nXXXX.vti and analoge for the other two.
Note that the order of the (reduced) dimensions in the resulting output files is preserved, e.g. the first collapsed array in the example above will hold the y-direction as first coordinate and the z-direction as second coordinate. This should be kept in mind for visualization.

Collapsing of existing output

To collapse existing *.dat files, the simulation can be restarted from a given output time and the code can be brought to a halt after zero iterations. This is entirely analoguous to the method for slicing *.dat files and done in the following way: its best to create a new *.par file (e.g. collapse.par) and clear the savelist from any output to filetypes other than 4. We use itsave to demand a collapse output for the zero-iteration.
 &savelist
        itsave(1,4)      = 0
        collapse(1)      = T
        collapse(2)      = T
        collapse(3)      = T
        collapseLevel    = 3
/
The stoplist should look as follows:
 &stoplist
        itreset          = .true.
        itmax            = 0
/
where we reset the iteration counter (so that itsave(1,4)=0 will output collapsed data) and stop the code immediately after the IO (itmax=0).

The code can then be started with

./bhac -restart 10 -i collapse.par -collapse 10 -if output/data
which will take the output output/data0010.dat (-restart 10, -if output/data) to create new collapsed view with index 10 (-collapse 10). The par-file is the newly created collapse.par (-i collapse.par) so that the default used to run the code can be left untouched. It is a simple exercise in shell scripting to run along all output-files in one go. For example with the BASH:
for i in {0..10}; do ./bhac -restart $i -i collapse.par -collapse $i -if output/data; done

ASCII output

As an alternative to the cell-type *.vti file format, you can obtain comma-separated-value *.csv files of the cell-center variables. This can be useful especially for 2D simulations (ergo 1D line output) which can then be simply visualized using e.g. gnuplot. For a quick look, the *.csv files can be visualized with GNUplot using a command similar to the following:
gnuplot> p 'data_d1_l3_n0000.csv' u 2:1:9 with image