SHELL OUTPUT

When running cartesian simulations, often you want to analyze quantities on spherical shells, e.g. to measure the accretion rate through the horizon or energy fluxes through some surface across a jet. The shell module provides this functionality by interpolating data onto a regularly gridded 2D sphere (or in case of 2D simulations a 1D circle). The module can output either to *.vtu or *.csv files.
Also, you can analyze the data during run-time as described briefly below.
This page: [Setup in par file] [Processing existing output] [Runtime usage] [Usage with Paraview]

Setup in par file

D-1 dimensional shells are the sixth file format with output intervals that can be specified in the savelist section of the par file. To give an example, here we specify two shells (nshells = 2), where the first has radial coordinate 1 (shellcoord(1) = 1.0d0) and the second shell has radial coordinate 50 (shellcoord(2) = 50.0d0). The resolution of the shell is 256x256 cells.
 &savelist
        itsave(1,6)     = 0
        dtsave(6)       = 0.1d0
 
        nshells         = 2
        shellcoord(1)   = 1.0d0
        shellcoord(2)   = 50.0d0
 
        nxShell2        = 256
        nxShell3        = 256
/

By default, BHAC will output these to *.vtu files that can directly be read into Paraview. You can however select ascii output controlled via shell_type in the filelist:

 &filelist
        shell_type      = 'vtu' | 'csv'
/
The output filename is composed of the direction and offset values. For example, the first shell output name reads filenameout_r+0.100D+01_nXXXX.[vtu|csv].

Creating shells from existing output

To get shells in post-processing from snapshot *.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 done just like for the slices: its best to create a new *.par file (e.g. shells.par) and clear the savelist from any output to filetypes other than 6. We use itsave to demand a slice output for the zero-iteration.
 &savelist
        itsave(1,6)=0

        nshells         = 2
        shellcoord(1)   = 1.0d0
        shellcoord(2)   = 50.0d0
 
        nxShell2        = 256
        nxShell3        = 256
/
The stoplist should look like the following,
 &stoplist
        itreset=.true.
        itmax=0
/
where we reset the iteration counter (so that itsave(1,6)=0 will output shell data) and stop the code immediately after the IO (itmax=0).

The code can then be started with

./bhac -restart 10 -i shells.par -shell 10 -if output/data
which will take the output output/data0010.dat (-restart 10, -if output/data) to create new shells with index 10 (-shell 10). The par-file is the newly created shells.par (-i shells.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 shells.par -shell $i -if output/data; done

Runtime usage

To see how to analyze data during runtime on the shell, have a look at src/amrvacio/mod_shell.t. Basically you have to do something similar to
  use mod_shell

  call init_gridvars(...)
  call alloc_shell(...)
  call fill_shell(...)
  ... do something with the shell data ...
  call dealloc_shell(...)
  call finish_gridvars(...)
Though take care: the full shell data is communicated only to rank 0.

Usage with Paraview

This is trivial, just load the .vtu files, the coordinates have been converted into a cartesian system for your convenience.