Auxiliary variables in BHAC: nwflux, nwaux, nwextra, nwauxio, nw
This document describes the differences and the intended use of the nwaux, nwextra parameters.
These global parameters are dependent on the physics module, and defined in the corresponding
file, where physics in the public version is currently rmhd.
This global parameter sets the total number of variables, determining the (last dimension-independent) size of the w(ixG^T,1:nw) array, and is always
nw = nwflux+nwaux+nwextra
The idea is that there are nwflux conservative variables for which corresponding fluxes are defined in the physics/amrvacphys.t
module, and that we have in addition a set of nwaux auxiliary variables, together with some extra nwextra variables. For these latter two types of variables, one does not have a corresponding flux definition in getflux, gefluxforhllc subroutines, and they also have no boundary conditions imposed on them.
The first 1:nwflux variables should be the conservative variables of the physics module at hand, and these are the ones that are updated
by means of fluxes across cell boundaries, and are influenced by source terms (geometric or real physical source terms).
Also, those variables change their
meaning/content in the subroutines primitive, conserve. These latter subroutines are thus switching from conservative to primitive and vice versa atappropriate places in the code, and in this switching procedure, handy use can be made of the possible auxiliary variables.
Auxiliary variables are then in the slots nwflux+1:nwflux+nwaux. For all 1:nwflux+nwaux variables, the boundary conditions are to be imposed and existing boundary types have to be provided (like symm, asymm, special, cont, periodic, ...) in the par-file.
For steady-state computations, the residual is based on only the temporal variation of these 1:nwflux variables.
When for the physics module at hand, one has nwaux>0, the slots in the w-array corresponding to nwflux+1:nwflux+nwaux contain so-called auxiliary variables.
In the physics module for rmhd these local auxiliaries are useful to store enthalpy and Lorentz factor values, which in principle are computable from the set of conservative variables at any time. As a costly non-linear iterative (Newton-Raphson) procedure is involved, it pays off in computing time to have corresponding auxiliary variables available when e.g. fluxes have to be defined/added in getflux and so on. These local auxiliary variables
are all to be computed in the getaux subroutine in the physics module.
The local auxiliaries can in fact also be used to trigger refinement or coarsening, so that the corresponding flags integer array may use them.
An extra set of nwextra variables can be defined by setting nwextra>0. Like auxiliaries, they are not advanced, not communicated and there are no boundary conditions imposed on them. They can be used to store additional temporal physical variables or debugging information though.
Only for post-processing purposes on saved snapshots from the code, one may want to compute additional auxiliary variables for visualization.
Hence, only at the convert-stage (from amrvac .dat data file to any of the available formats in the convert subroutine) do we need to
enlarge the data size from nw to nw+nwauxio, and their calculation is to be done in the specialvar_output subroutine,
for which the default interface is given in the amrvacnul/speciallog.t module. Correspondingly, the names have to be given in the
specialvarnames_output as strings to be concatenated with the wnames/primnames strings. This means that normally nwauxio=0, but it can be set to a nonzero value in the filelist part of the par-file.