% *======================================================================*
%  Cactus Thorn template for ThornGuide documentation
%  Author: Ian Kelley
%  Date: Sun Jun 02, 2002
%  $Header$
%
%  Thorn documentation in the latex file doc/documentation.tex
%  will be included in ThornGuides built with the Cactus make system.
%  The scripts employed by the make system automatically include
%  pages about variables, parameters and scheduling parsed from the
%  relevant thorn CCL files.
%
%  This template contains guidelines which help to assure that your
%  documentation will be correctly added to ThornGuides. More
%  information is available in the Cactus UsersGuide.
%
%  Guidelines:
%   - Do not change anything before the line
%       % START CACTUS THORNGUIDE",
%     except for filling in the title, author, date, etc. fields.
%        - Each of these fields should only be on ONE line.
%        - Author names should be separated with a \\ or a comma.
%   - You can define your own macros, but they must appear after
%     the START CACTUS THORNGUIDE line, and must not redefine standard
%     latex commands.
%   - To avoid name clashes with other thorns, 'labels', 'citations',
%     'references', and 'image' names should conform to the following
%     convention:
%       ARRANGEMENT_THORN_LABEL
%     For example, an image wave.eps in the arrangement CactusWave and
%     thorn WaveToyC should be renamed to CactusWave_WaveToyC_wave.eps
%   - Graphics should only be included using the graphicx package.
%     More specifically, with the "\includegraphics" command.  Do
%     not specify any graphic file extensions in your .tex file. This
%     will allow us to create a PDF version of the ThornGuide
%     via pdflatex.
%   - References should be included with the latex "\bibitem" command.
%   - Use \begin{abstract}...\end{abstract} instead of \abstract{...}
%   - Do not use \appendix, instead include any appendices you need as
%     standard sections.
%   - For the benefit of our Perl scripts, and for future extensions,
%     please use simple latex.
%
% *======================================================================*
%
% Example of including a graphic image:
%    \begin{figure}[ht]
% 	\begin{center}
%    	   \includegraphics[width=6cm]{/home/runner/work/tests/tests/arrangements/WVUThorns_Diagnostics/VolumeIntegrals_GRMHD/doc/MyArrangement_MyThorn_MyFigure}
% 	\end{center}
% 	\caption{Illustration of this and that}
% 	\label{MyArrangement_MyThorn_MyLabel}
%    \end{figure}
%
% Example of using a label:
%   \label{MyArrangement_MyThorn_MyLabel}
%
% Example of a citation:
%    \cite{MyArrangement_MyThorn_Author99}
%
% Example of including a reference
%   \bibitem{MyArrangement_MyThorn_Author99}
%   {J. Author, {\em The Title of the Book, Journal, or periodical}, 1 (1999),
%   1--16. {\tt http://www.nowhere.com/}}
%
% *======================================================================*

% If you are using CVS use this line to give version information
% $Header$

\documentclass{article}

% Use the Cactus ThornGuide style file
% (Automatically used from Cactus distribution, if you have a
%  thorn without the Cactus Flesh download this from the Cactus
%  homepage at www.cactuscode.org)
\usepackage{../../../../../doc/latex/cactus}
%% \usepackage{cactus}

\newlength{\tableWidth} \newlength{\maxVarWidth} \newlength{\paraWidth} \newlength{\descWidth} \begin{document}

% The author of the documentation
\author{Zachariah B.~Etienne \textless zachetie *at* gmail *dot* com \textgreater\\
  Documentation by Leonardo R.~Werneck \textless wernecklr *at* gmail *dot* com \textgreater
}

% The title of the document (not necessarily the name of the Thorn)
\title{\texttt{VolumeIntegrals\_GRMHD}: An Einstein Toolkit thorn for GRMHD volume integrations}

% the date your document was last changed, if your document is in CVS,
% please use:
\date{July 24, 2023}

\maketitle

\linespread{1.0}

% Add an abstract for this thorn's documentation
\begin{abstract}
  \texttt{VolumeIntegrals\_GRMHD} is a thorn for integration of
  spacetime quantities, accepting integration volumes consisting of
  spherical shells, regions with hollowed balls, and simple spheres.
  Results from of integrals, such as the center of mass, can be used
  to track e.g.\ neutron stars.
\end{abstract}

%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%% Volume Integrals %%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%
\section{Volume integrals}
\label{sec:volume_integrals}

We now briefly describe the volume integrals that can be performed
using the \texttt{VolumeIntegrals\_GRMHD} thorn.


%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%% Rest mass %%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%
\subsection{Rest mass}
\label{sec:rest_mass}
We start by defining the ``densitised density'' (see e.g.~\cite{duez2005relativistic})
%%
\begin{equation}
\rho_{\star} \equiv \alpha\sqrt{\gamma}\rho_{\rm b} u^{0} = W\rho_{\rm b}\sqrt{\gamma},
\end{equation}
%%
where $\alpha$ is the lapse function, $\gamma$ is the determinant of
the physical spatial metric $\gamma_{ij}$, $\rho_{\rm b}$ is the baryonic
density, $u^{\mu}$ is the fluid four-velocity, and $W\equiv\alpha u^{0}$
is the Lorentz factor. The rest mass integral is then given by
%%
\begin{equation}
\boxed{ M_{0} = \int \rho_{\star} dV = \int \left(W\rho_{\rm b}\sqrt{\gamma}\right)dV }\; .
\end{equation}
%%
The volume $V$ can be specified using spherical shells, regions with hollowed balls,
and simple spheres. It can also be set to the entire computational domain.

%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%% Center of mass %%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%
\subsection{Center of mass}
\label{sec:com}

The coordinates of center of mass $X^{i}$ are computed from the integral
%%
\begin{equation}
\boxed{ X^{i} = \frac{\int \rho_{\star} x^{i}dV}{\int \rho_{\star} dV} }\; ,
\end{equation}
%%
where $x^{i}$ is the position vector. The volume $V$ can be specified using spherical shells,
regions with hollowed balls, and simple spheres. It can also be set to the entire domain size.

%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%% Unit integral %%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%
\subsection{Unit (for debugging)}
\label{sec:unit}

This thorn also provides the functionality of performing a volume
integral with a unit integrand, which should just yield the volume
of the integrated region, i.e.
%%
\begin{equation}
\boxed{ V = \int dV }\; .
\end{equation}
%%

%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%% Basic usage %%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%
\section{Basic usage}
\label{sec:basic_usage}

Except for the definition of the integrands, the behavior of this thorn
is almost completely driver by the configuration of the parameter file.
We present here an example of such a parameter file, which performs the
following tasks:

\begin{enumerate}
  \setlength{\itemsep}{0.0pt}
  \setlength{\parskip}{0.0pt}
  \setlength{\parsep}{ 0.0pt}
  \item Integrate the entire volume with an integrand of 1.
  (used for testing/validation purposes only).
  \label{item1}

  \item Perform all four integrals required to compute the
  center of mass (numerator=3, denominator=1 integral),
  in an integration volume originally centered at
  $(x,y,z)=(-15.2,0,0)$ with a coordinate radius of 13.5
  Also use the center of mass integral result to SET
  the ZEROTH AMR center. In this way, the AMR grids
  will track the center of mass as computed by this
  integration.
  \label{item2}

  \item Same as \ref{item2}, except use the integrand=1 (for validation
  purposes, to ensure the integration volume is
  approximately $(4/3)\pi13.5^3$). Also disable tracking of
  this integration volume.
  \label{item3}

  \item Same as \ref{item2}, except for the neutron star originally
  centered at $(x,y,z)=(+15.2,0,0)$.
  \label{item4}

  \item Same as \ref{item4}, except use the integrand=1 (for validation
  purposes, to ensure the integration volume is
  approximately $(4/3)\pi13.5^3$). Also disable tracking of
  this integration volume.
  \label{item5}

  \item Perform rest-mass integrals over entire volume.
  \label{item6}
\end{enumerate}
%%
To achieve this, add the following configuration to your parameter file:
%%
\begin{verbatim}
ActiveThorns = "VolumeIntegrals_GRMHD"

# Set number of integrals
VolumeIntegrals_GRMHD::NumIntegrals = 6

# Set frequency of integration. If tracking AMR centres this should
# match the regridding frequency of the thorn CactusRegrid2
VolumeIntegrals_GRMHD::VolIntegral_out_every = 32

# Enable file output
VolumeIntegrals_GRMHD::enable_file_output = 1

# Set output directory
VolumeIntegrals_GRMHD::outVolIntegral_dir = "volume_integration"

# Set verbose level. 0 disables it, 1 provides useful
# information, and 2 is very verbose.
VolumeIntegrals_GRMHD::verbose = 1

# The AMR centre will only track the first referenced
# integration quantities that track said centre.

# Integral #1: unit integrand
VolumeIntegrals_GRMHD::Integration_quantity_keyword[1] = "one"
# Integral #2: CoM
VolumeIntegrals_GRMHD::Integration_quantity_keyword[2] = "centerofmass"
# Integral #3: unit integrand
VolumeIntegrals_GRMHD::Integration_quantity_keyword[3] = "one"
# Integral #4: CoM
VolumeIntegrals_GRMHD::Integration_quantity_keyword[4] = "centerofmass"
# Integral #5: unit integrand
VolumeIntegrals_GRMHD::Integration_quantity_keyword[5] = "one"
# Integral #6: rest mass
VolumeIntegrals_GRMHD::Integration_quantity_keyword[6] = "restmass"

# Set radius of integration for integral #2
VolumeIntegrals_GRMHD::volintegral_sphere__center_x_initial         [2] = -15.2
VolumeIntegrals_GRMHD::volintegral_inside_sphere__radius            [2] =  13.5
# Let the result of integral #2 track the grid centre 0
VolumeIntegrals_GRMHD::amr_centre__tracks__volintegral_inside_sphere[2] =  0

# Set radius of integrattion for integral #3
VolumeIntegrals_GRMHD::volintegral_sphere__center_x_initial         [3] = -15.2
VolumeIntegrals_GRMHD::volintegral_inside_sphere__radius            [3] =  13.5

# Set radius of integration for integral #4
VolumeIntegrals_GRMHD::volintegral_sphere__center_x_initial         [4] =  15.2
VolumeIntegrals_GRMHD::volintegral_inside_sphere__radius            [4] =  13.5
# Let the result of integral #4 track the grid centre 1
VolumeIntegrals_GRMHD::amr_centre__tracks__volintegral_inside_sphere[4] =  1

# Set radius of integrattion for integral #5
VolumeIntegrals_GRMHD::volintegral_sphere__center_x_initial         [5] =  15.2
VolumeIntegrals_GRMHD::volintegral_inside_sphere__radius            [5] =  13.5
\end{verbatim}
%%


%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%% References %%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{thebibliography}{1}

\bibitem{duez2005relativistic}
  M.D. Duez, Y.T. Liu, S.L. Shapiro, and B.C. Stephens,
  \newblock {\em Relativistic magnetohydrodynamics in dynamical spacetimes: Numerical methods and tests},
  Physical Review D, 72, 2, 024028 (2005).

\end{thebibliography}

% Do not delete next line
% END CACTUS THORNGUIDE



\section{Parameters} 


\parskip = 0pt

\setlength{\tableWidth}{160mm}

\setlength{\paraWidth}{\tableWidth}
\setlength{\descWidth}{\tableWidth}
\settowidth{\maxVarWidth}{volintegral\_usepreviousintegrands\_num\_integrands}

\addtolength{\paraWidth}{-\maxVarWidth}
\addtolength{\paraWidth}{-\columnsep}
\addtolength{\paraWidth}{-\columnsep}
\addtolength{\paraWidth}{-\columnsep}

\addtolength{\descWidth}{-\columnsep}
\addtolength{\descWidth}{-\columnsep}
\addtolength{\descWidth}{-\columnsep}
\noindent \begin{tabular*}{\tableWidth}{|c|l@{\extracolsep{\fill}}r|}
\hline
\multicolumn{1}{|p{\maxVarWidth}}{amr\_centre\_\_tracks\_\_volintegral\_inside\_sphere} & {\bf Scope:} private & INT \\\hline
\multicolumn{3}{|p{\descWidth}|}{{\bf Description:}   {\em Use output from volume integral to move AMR box centre N.}} \\
\hline{\bf Range} & &  {\bf Default:} -1 \\\multicolumn{1}{|p{\maxVarWidth}|}{\centering -1:100} & \multicolumn{2}{p{\paraWidth}|}{-1 = do not track an AMR box centre. Otherwise track AMR box centre number N = [0,100]} \\\hline
\end{tabular*}

\vspace{0.5cm}\noindent \begin{tabular*}{\tableWidth}{|c|l@{\extracolsep{\fill}}r|}
\hline
\multicolumn{1}{|p{\maxVarWidth}}{com\_integrand\_gamma\_speed\_limit} & {\bf Scope:} private & REAL \\\hline
\multicolumn{3}{|p{\descWidth}|}{{\bf Description:}   {\em }} \\
\hline{\bf Range} & &  {\bf Default:} 1e4 \\\multicolumn{1}{|p{\maxVarWidth}|}{\centering 0:*} & \multicolumn{2}{p{\paraWidth}|}{Any positive number} \\\hline
\end{tabular*}

\vspace{0.5cm}\noindent \begin{tabular*}{\tableWidth}{|c|l@{\extracolsep{\fill}}r|}
\hline
\multicolumn{1}{|p{\maxVarWidth}}{enable\_file\_output} & {\bf Scope:} private & INT \\\hline
\multicolumn{3}{|p{\descWidth}|}{{\bf Description:}   {\em Enable output file}} \\
\hline{\bf Range} & &  {\bf Default:} 1 \\\multicolumn{1}{|p{\maxVarWidth}|}{\centering 0:1} & \multicolumn{2}{p{\paraWidth}|}{0 = no output; 1 = yes, output to file} \\\hline
\end{tabular*}

\vspace{0.5cm}\noindent \begin{tabular*}{\tableWidth}{|c|l@{\extracolsep{\fill}}r|}
\hline
\multicolumn{1}{|p{\maxVarWidth}}{enable\_time\_reparameterization} & {\bf Scope:} private & BOOLEAN \\\hline
\multicolumn{3}{|p{\descWidth}|}{{\bf Description:}   {\em Enable time reparameterization a la http://arxiv.org/abs/1404.6523}} \\
\hline & & {\bf Default:} no \\\hline
\end{tabular*}

\vspace{0.5cm}\noindent \begin{tabular*}{\tableWidth}{|c|l@{\extracolsep{\fill}}r|}
\hline
\multicolumn{1}{|p{\maxVarWidth}}{integration\_quantity\_keyword} & {\bf Scope:} private & KEYWORD \\\hline
\multicolumn{3}{|p{\descWidth}|}{{\bf Description:}   {\em Which quantity to integrate}} \\
\hline{\bf Range} & &  {\bf Default:} nothing \\\multicolumn{1}{|p{\maxVarWidth}|}{\centering nothing} & \multicolumn{2}{p{\paraWidth}|}{Default, null parameter} \\\multicolumn{1}{|p{\maxVarWidth}|}{see [1] below} & \multicolumn{2}{p{\paraWidth}|}{Use integrands from step(s) immediately preceeding. Useful for Swiss-cheese-type volume integrations.} \\\multicolumn{1}{|p{\maxVarWidth}|}{\centering centerofmass} & \multicolumn{2}{p{\paraWidth}|}{Center of Mass} \\\multicolumn{1}{|p{\maxVarWidth}|}{\centering restmass} & \multicolumn{2}{p{\paraWidth}|}{Rest Mass} \\\multicolumn{1}{|p{\maxVarWidth}|}{\centering one} & \multicolumn{2}{p{\paraWidth}|}{Integrand = 1. Useful for debugging} \\\hline
\end{tabular*}

\vspace{0.5cm}\noindent {\bf [1]} \noindent \begin{verbatim}usepreviousintegrands\end{verbatim}\noindent \begin{tabular*}{\tableWidth}{|c|l@{\extracolsep{\fill}}r|}
\hline
\multicolumn{1}{|p{\maxVarWidth}}{numintegrals} & {\bf Scope:} private & INT \\\hline
\multicolumn{3}{|p{\descWidth}|}{{\bf Description:}   {\em Number of volume integrals to perform}} \\
\hline{\bf Range} & &  {\bf Default:} (none) \\\multicolumn{1}{|p{\maxVarWidth}|}{\centering 0:1000} & \multicolumn{2}{p{\paraWidth}|}{zero (disable integration) or some other number} \\\hline
\end{tabular*}

\vspace{0.5cm}\noindent \begin{tabular*}{\tableWidth}{|c|l@{\extracolsep{\fill}}r|}
\hline
\multicolumn{1}{|p{\maxVarWidth}}{outvolintegral\_dir} & {\bf Scope:} private & STRING \\\hline
\multicolumn{3}{|p{\descWidth}|}{{\bf Description:}   {\em Output directory for volume integration output files, overrides IO::out\_dir}} \\
\hline{\bf Range} & &  {\bf Default:} (none) \\\multicolumn{1}{|p{\maxVarWidth}|}{\centering .+} & \multicolumn{2}{p{\paraWidth}|}{A valid directory name} \\\multicolumn{1}{|p{\maxVarWidth}|}{\centering \^\$} & \multicolumn{2}{p{\paraWidth}|}{An empty string to choose the default from IO::out\_dir} \\\hline
\end{tabular*}

\vspace{0.5cm}\noindent \begin{tabular*}{\tableWidth}{|c|l@{\extracolsep{\fill}}r|}
\hline
\multicolumn{1}{|p{\maxVarWidth}}{verbose} & {\bf Scope:} private & INT \\\hline
\multicolumn{3}{|p{\descWidth}|}{{\bf Description:}   {\em Set verbosity level: 1=useful info; 2=moderately annoying (though useful for debugging)}} \\
\hline{\bf Range} & &  {\bf Default:} 1 \\\multicolumn{1}{|p{\maxVarWidth}|}{\centering 0:2} & \multicolumn{2}{p{\paraWidth}|}{0 = no output; 1=useful info; 2=moderately annoying (though useful for debugging)} \\\hline
\end{tabular*}

\vspace{0.5cm}\noindent \begin{tabular*}{\tableWidth}{|c|l@{\extracolsep{\fill}}r|}
\hline
\multicolumn{1}{|p{\maxVarWidth}}{viv\_time\_reparam\_t0} & {\bf Scope:} private & REAL \\\hline
\multicolumn{3}{|p{\descWidth}|}{{\bf Description:}   {\em Time reparameterization parameter t\_0: Center of time reparameterization curve. SET TO BE SAME AS IN ImprovedPunctureGauge thorn}} \\
\hline{\bf Range} & &  {\bf Default:} 10.0 \\\multicolumn{1}{|p{\maxVarWidth}|}{\centering 0:*} & \multicolumn{2}{p{\paraWidth}|}{Probably don't want to set this {\textless}0, so {\textgreater}=0 enforced} \\\hline
\end{tabular*}

\vspace{0.5cm}\noindent \begin{tabular*}{\tableWidth}{|c|l@{\extracolsep{\fill}}r|}
\hline
\multicolumn{1}{|p{\maxVarWidth}}{viv\_time\_reparam\_w} & {\bf Scope:} private & REAL \\\hline
\multicolumn{3}{|p{\descWidth}|}{{\bf Description:}   {\em Time reparameterization parameter w: Width of time reparameterization curve. SET TO BE SAME AS IN ImprovedPunctureGauge thorn}} \\
\hline{\bf Range} & &  {\bf Default:} 5.0 \\\multicolumn{1}{|p{\maxVarWidth}|}{\centering 0:*} & \multicolumn{2}{p{\paraWidth}|}{Probably don't want to set this {\textless}0, so {\textgreater}=0 enforced} \\\hline
\end{tabular*}

\vspace{0.5cm}\noindent \begin{tabular*}{\tableWidth}{|c|l@{\extracolsep{\fill}}r|}
\hline
\multicolumn{1}{|p{\maxVarWidth}}{volintegral\_inside\_sphere\_\_radius} & {\bf Scope:} private & REAL \\\hline
\multicolumn{3}{|p{\descWidth}|}{{\bf Description:}   {\em Volume integral in a spherical region: radius of spherical region}} \\
\hline{\bf Range} & &  {\bf Default:} (none) \\\multicolumn{1}{|p{\maxVarWidth}|}{\centering *:*} & \multicolumn{2}{p{\paraWidth}|}{Any number} \\\hline
\end{tabular*}

\vspace{0.5cm}\noindent \begin{tabular*}{\tableWidth}{|c|l@{\extracolsep{\fill}}r|}
\hline
\multicolumn{1}{|p{\maxVarWidth}}{volintegral\_out\_every} & {\bf Scope:} private & INT \\\hline
\multicolumn{3}{|p{\descWidth}|}{{\bf Description:}   {\em How often to compute volume integrals?}} \\
\hline{\bf Range} & &  {\bf Default:} (none) \\\multicolumn{1}{|p{\maxVarWidth}|}{\centering 0:1000} & \multicolumn{2}{p{\paraWidth}|}{zero (disable integration) or some other number} \\\hline
\end{tabular*}

\vspace{0.5cm}\noindent \begin{tabular*}{\tableWidth}{|c|l@{\extracolsep{\fill}}r|}
\hline
\multicolumn{1}{|p{\maxVarWidth}}{volintegral\_outside\_sphere\_\_radius} & {\bf Scope:} private & REAL \\\hline
\multicolumn{3}{|p{\descWidth}|}{{\bf Description:}   {\em Volume integral outside a spherical region: radius of spherical region}} \\
\hline{\bf Range} & &  {\bf Default:} (none) \\\multicolumn{1}{|p{\maxVarWidth}|}{\centering *:*} & \multicolumn{2}{p{\paraWidth}|}{Any number} \\\hline
\end{tabular*}

\vspace{0.5cm}\noindent \begin{tabular*}{\tableWidth}{|c|l@{\extracolsep{\fill}}r|}
\hline
\multicolumn{1}{|p{\maxVarWidth}}{volintegral\_sphere\_\_center\_x\_initial} & {\bf Scope:} private & REAL \\\hline
\multicolumn{3}{|p{\descWidth}|}{{\bf Description:}   {\em Volume integral in a spherical region: x-coord of center(s)}} \\
\hline{\bf Range} & &  {\bf Default:} (none) \\\multicolumn{1}{|p{\maxVarWidth}|}{\centering *:*} & \multicolumn{2}{p{\paraWidth}|}{Any number} \\\hline
\end{tabular*}

\vspace{0.5cm}\noindent \begin{tabular*}{\tableWidth}{|c|l@{\extracolsep{\fill}}r|}
\hline
\multicolumn{1}{|p{\maxVarWidth}}{volintegral\_sphere\_\_center\_y\_initial} & {\bf Scope:} private & REAL \\\hline
\multicolumn{3}{|p{\descWidth}|}{{\bf Description:}   {\em Volume integral in a spherical region: y-coord of center(s)}} \\
\hline{\bf Range} & &  {\bf Default:} (none) \\\multicolumn{1}{|p{\maxVarWidth}|}{\centering *:*} & \multicolumn{2}{p{\paraWidth}|}{Any number} \\\hline
\end{tabular*}

\vspace{0.5cm}\noindent \begin{tabular*}{\tableWidth}{|c|l@{\extracolsep{\fill}}r|}
\hline
\multicolumn{1}{|p{\maxVarWidth}}{volintegral\_sphere\_\_center\_z\_initial} & {\bf Scope:} private & REAL \\\hline
\multicolumn{3}{|p{\descWidth}|}{{\bf Description:}   {\em Volume integral in a spherical region: z-coord of center(s)}} \\
\hline{\bf Range} & &  {\bf Default:} (none) \\\multicolumn{1}{|p{\maxVarWidth}|}{\centering *:*} & \multicolumn{2}{p{\paraWidth}|}{Any number} \\\hline
\end{tabular*}

\vspace{0.5cm}\noindent \begin{tabular*}{\tableWidth}{|c|l@{\extracolsep{\fill}}r|}
\hline
\multicolumn{1}{|p{\maxVarWidth}}{volintegral\_sphere\_\_tracks\_\_amr\_centre} & {\bf Scope:} private & INT \\\hline
\multicolumn{3}{|p{\descWidth}|}{{\bf Description:}   {\em Volume integral tracks AMR box centre N.}} \\
\hline{\bf Range} & &  {\bf Default:} -1 \\\multicolumn{1}{|p{\maxVarWidth}|}{\centering -1:100} & \multicolumn{2}{p{\paraWidth}|}{-1 = do not track an AMR box centre. Otherwise track AMR box centre number N = [0,100]} \\\hline
\end{tabular*}

\vspace{0.5cm}\noindent \begin{tabular*}{\tableWidth}{|c|l@{\extracolsep{\fill}}r|}
\hline
\multicolumn{1}{|p{\maxVarWidth}}{volintegral\_usepreviousintegrands\_num\_integrands} & {\bf Scope:} private & INT \\\hline
\multicolumn{3}{|p{\descWidth}|}{{\bf Description:}   {\em Number of integrands for usepreviousintegrands, must be specified explicitly as information from previous integrand is not passed.}} \\
\hline{\bf Range} & &  {\bf Default:} 4 \\\multicolumn{1}{|p{\maxVarWidth}|}{\centering 0:100} & \multicolumn{2}{p{\paraWidth}|}{Default is set to the maximum, 4.} \\\hline
\end{tabular*}

\vspace{0.5cm}\noindent \begin{tabular*}{\tableWidth}{|c|l@{\extracolsep{\fill}}r|}
\hline
\multicolumn{1}{|p{\maxVarWidth}}{out\_dir} & {\bf Scope:} shared from IO & STRING \\\hline
\end{tabular*}

\vspace{0.5cm}\parskip = 10pt 

\section{Interfaces} 


\parskip = 0pt

\vspace{3mm} \subsection*{General}

\noindent {\bf Implements}: 

volumeintegrals\_grmhd
\vspace{2mm}

\noindent {\bf Inherits}: 

grid

admbase

carpetregrid2

hydrobase

admbase
\vspace{2mm}
\subsection*{Grid Variables}
\vspace{5mm}\subsubsection{PRIVATE GROUPS}

\vspace{5mm}

\begin{tabular*}{150mm}{|c|c@{\extracolsep{\fill}}|rl|} \hline 
~ {\bf Group Names} ~ & ~ {\bf Variable Names} ~  &{\bf Details} ~ & ~\\ 
\hline 
volintegrands &  & compact & 0 \\ 
 & VolIntegrand1 & dimensions & 3 \\ 
 & VolIntegrand2 & distribution & DEFAULT \\ 
 & VolIntegrand3 & group type & GF \\ 
 & VolIntegrand4 & tags & InterpNumTimelevels=1 prolongation="none" Checkpoint="no" \\ 
 &  & timelevels & 1 \\ 
 &  & variable type & REAL \\ 
\hline 
volintegrals &  & compact & 0 \\ 
 & VolIntegral & description & Volume integrals \\ 
& ~ & description &  post-sum. The first dimension denotes which integral(s) \\ 
 & VolIntegral & description &  and the second denotes the values of the integral(s). E.g. \\ 
 & VolIntegral & description &  a center of mass volume integral will have 3 outputs. \\ 
 &  & dimensions & 2 \\ 
 &  & distribution & CONSTANT \\ 
 &  & group type & ARRAY \\ 
 &  & size & 101 \\ 
& ~ & size & 4 \\ 
 &  & timelevels & 1 \\ 
 &  & variable type & REAL \\ 
\hline 
movingsphregionintegrals &  & compact & 0 \\ 
 & volintegral\_inside\_sphere\_\_center\_x & description & Specify regions for volume integrals inside/outside spheres THAT MOVE. \\ 
 & volintegral\_inside\_sphere\_\_center\_y & dimensions & 1 \\ 
 & volintegral\_inside\_sphere\_\_center\_z & distribution & CONSTANT \\ 
 & volintegral\_outside\_sphere\_\_center\_x & group type & ARRAY \\ 
 & volintegral\_outside\_sphere\_\_center\_y & size & 101 \\ 
 & volintegral\_outside\_sphere\_\_center\_z & timelevels & 1 \\ 
 &  & variable type & REAL \\ 
\hline 
integralcountervar &  & compact & 0 \\ 
 & IntegralCounter & description & Counter that keeps track of which integral we are calculating. \\ 
 &  & dimensions & 0 \\ 
 &  & distribution & CONSTANT \\ 
 &  & group type & SCALAR \\ 
 &  & tags & checkpoint="no" \\ 
 &  & timelevels & 1 \\ 
 &  & variable type & INT \\ 
\hline 
volintegrals\_vacuum\_time &  & compact & 0 \\ 
 & physical\_time & description & keeps track of the physical time \\ 
& ~ & description &  in case time coordinate is reparameterized \\ 
 & physical\_time & description &  a la http://arxiv.org/abs/1404.6523 \\ 
 &  & dimensions & 0 \\ 
 &  & distribution & CONSTANT \\ 
 &  & group type & SCALAR \\ 
 &  & tags & checkpoint="no" \\ 
 &  & timelevels & 1 \\ 
 &  & variable type & REAL \\ 
\hline 
\end{tabular*} 



\vspace{5mm}\parskip = 10pt 

\section{Schedule} 


\parskip = 0pt


\noindent This section lists all the variables which are assigned storage by thorn WVUThorns\_Diagnostics/VolumeIntegrals\_GRMHD.  Storage can either last for the duration of the run ({\bf Always} means that if this thorn is activated storage will be assigned, {\bf Conditional} means that if this thorn is activated storage will be assigned for the duration of the run if some condition is met), or can be turned on for the duration of a schedule function.


\subsection*{Storage}

\hspace{5mm}

 \begin{tabular*}{160mm}{ll} 

{\bf Always:}&  ~ \\ 
 VolIntegrands VolIntegrals MovingSphRegionIntegrals IntegralCounterVar VolIntegrals\_vacuum\_time & ~\\ 
~ & ~\\ 
\end{tabular*} 


\subsection*{Scheduled Functions}
\vspace{5mm}

\noindent {\bf CCTK\_INITIAL}   (conditional) 

\hspace{5mm} vi\_grmhd\_file\_output\_routine\_startup 

\hspace{5mm}{\it create directory for vi grmhd file output. } 


\hspace{5mm}

 \begin{tabular*}{160mm}{cll} 
~ & Language:  & c \\ 
~ & Type:  & function \\ 
\end{tabular*} 


\vspace{5mm}

\noindent {\bf CCTK\_POST\_RECOVER\_VARIABLES}   (conditional) 

\hspace{5mm} vi\_grmhd\_file\_output\_routine\_startup 

\hspace{5mm}{\it create directory for vi grmhd file output. } 


\hspace{5mm}

 \begin{tabular*}{160mm}{cll} 
~ & Language:  & c \\ 
~ & Type:  & function \\ 
\end{tabular*} 


\vspace{5mm}

\noindent {\bf CCTK\_INITIAL} 

\hspace{5mm} vi\_grmhd\_initializeintegralcountertozero 

\hspace{5mm}{\it initialize integralcounter variable to zero } 


\hspace{5mm}

 \begin{tabular*}{160mm}{cll} 
~ & Language:  & c \\ 
~ & Options:  & global \\ 
~ & Type:  & function \\ 
\end{tabular*} 


\vspace{5mm}

\noindent {\bf CCTK\_POST\_RECOVER\_VARIABLES} 

\hspace{5mm} vi\_grmhd\_initializeintegralcountertozero 

\hspace{5mm}{\it initialize integralcounter variable to zero } 


\hspace{5mm}

 \begin{tabular*}{160mm}{cll} 
~ & Language:  & c \\ 
~ & Options:  & global \\ 
~ & Type:  & function \\ 
\end{tabular*} 


\vspace{5mm}

\noindent {\bf CCTK\_ANALYSIS} 

\hspace{5mm} vi\_grmhd\_initializeintegralcounter 

\hspace{5mm}{\it initialize integralcounter variable } 


\hspace{5mm}

 \begin{tabular*}{160mm}{cll} 
~ & Before:  & vi\_grmhd\_volumeintegralgroup \\ 
~ & Language:  & c \\ 
~ & Options:  & global \\ 
~ & Type:  & function \\ 
\end{tabular*} 


\vspace{5mm}

\noindent {\bf CCTK\_ANALYSIS} 

\hspace{5mm} vi\_grmhd\_volumeintegralgroup 

\hspace{5mm}{\it evaluate all volume integrals } 


\hspace{5mm}

 \begin{tabular*}{160mm}{cll} 
~ & Before:  & carpetlib\_printtimestats \\ 
~& ~ &carpetlib\_printmemstats\\ 
~ & Type:  & group \\ 
~ & While:  & volumeintegrals\_grmhd::integralcounter \\ 
\end{tabular*} 


\vspace{5mm}

\noindent {\bf VI\_GRMHD\_VolumeIntegralGroup} 

\hspace{5mm} vi\_grmhd\_computeintegrand 

\hspace{5mm}{\it compute integrand } 


\hspace{5mm}

 \begin{tabular*}{160mm}{cll} 
~ & Before:  & dosum \\ 
~ & Language:  & c \\ 
~ & Options:  & global \\ 
~& ~ &loop-local\\ 
~ & Storage:  & volintegrands \\ 
~& ~ &volintegrals\\ 
~& ~ &movingsphregionintegrals\\ 
~ & Type:  & function \\ 
\end{tabular*} 


\vspace{5mm}

\noindent {\bf VI\_GRMHD\_VolumeIntegralGroup} 

\hspace{5mm} vi\_grmhd\_dosum 

\hspace{5mm}{\it do sum } 


\hspace{5mm}

 \begin{tabular*}{160mm}{cll} 
~ & After:  & computeintegrand \\ 
~ & Language:  & c \\ 
~ & Options:  & global \\ 
~ & Type:  & function \\ 
\end{tabular*} 


\vspace{5mm}

\noindent {\bf VI\_GRMHD\_VolumeIntegralGroup} 

\hspace{5mm} vi\_grmhd\_decrementintegralcounter 

\hspace{5mm}{\it decrement integralcounter variable } 


\hspace{5mm}

 \begin{tabular*}{160mm}{cll} 
~ & After:  & dosum \\ 
~ & Language:  & c \\ 
~ & Options:  & global \\ 
~ & Type:  & function \\ 
\end{tabular*} 


\vspace{5mm}

\noindent {\bf CCTK\_ANALYSIS} 

\hspace{5mm} vi\_grmhd\_file\_output 

\hspace{5mm}{\it output volumeintegral results to disk } 


\hspace{5mm}

 \begin{tabular*}{160mm}{cll} 
~ & After:  & vi\_grmhd\_volumeintegralgroup \\ 
~ & Language:  & c \\ 
~ & Options:  & global \\ 
~ & Type:  & function \\ 
\end{tabular*} 



\vspace{5mm}\parskip = 10pt 
\end{document}
