% *======================================================================*
%  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/Lean/NPScalars/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}

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

% The author of the documentation
\author{Miguel~Zilhão and Helvi~Witek}

% The title of the document (not necessarily the name of the Thorn)
\title{\texttt{NPScalars}}

% the date your document was last changed, if your document is in CVS,
% please use:
%    \date{$ $Date$ $}
% when using git instead record the commit ID:
%    \date{\gitrevision{<path-to-your-.git-directory>}}
\date{June 30, 2023}

\maketitle

% Do not delete next line
% START CACTUS THORNGUIDE

% Add all definitions used in this documentation here
%   \def\mydef etc

% Add an abstract for this thorn's documentation
\begin{abstract}
\texttt{NPScalars} computes the Newman-Penrose scalar $\Psi_{4}$  with up
to 6th order accurate finite-difference stencils.
\end{abstract}

\section{\texttt{NPScalars}}

\texttt{NPScalars} was introduced in~\cite{Sperhake:2006cy} (cf.~Appendix C therein for the detailed description) as part of the \texttt{Lean} code, to compute the Newman-Penrose scalar $\Psi_{4}$ and perform its decomposition into spherical harmonics.
%
It has since been modified to interface instead with the \texttt{Multipole} thorn for this decomposition.

The thorn was made publicly available through the \texttt{Canuda} numerical relativity library~\cite{Canuda}, and has since been distributed also as a part of the Einstein Toolkit.

The bulk of the code is written in Fortran~90 and should be simple to follow -- emphasis has been given to readability.

\section{Obtaining this thorn}

\texttt{NPScalars} is included with the Einstein Toolkit and can also be obtained through the \texttt{Canuda} numerical relativity library~\cite{Canuda}.


\begin{thebibliography}{9}

%\cite{Sperhake:2006cy}
\bibitem{Sperhake:2006cy}
U.~Sperhake,
``Binary black-hole evolutions of excision and puncture data,''
Phys. Rev. D \textbf{76} (2007), 104015
doi:10.1103/PhysRevD.76.104015
[arXiv:gr-qc/0606079 [gr-qc]].

\bibitem{Canuda}
H.~Witek, M.~Zilhao, G.~Bozzola, C.-H.~Cheng, A.~Dima, M.~Elley, G.~Ficarra, T.~Ikeda, R.~Luna, C.~Richards, N.~Sanchis-Gual, H.~Okada~da~Silva.
``Canuda: a public numerical relativity library to probe fundamental physics,''
Zenodo (2023)
doi: 10.5281/zenodo.3565474

\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}{calculate\_np\_every}

\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}}{calculate\_np\_every} & {\bf Scope:} private & INT \\\hline
\multicolumn{3}{|p{\descWidth}|}{{\bf Description:}   {\em Calculate NP scalars every N iterations}} \\
\hline{\bf Range} & &  {\bf Default:} 1 \\\multicolumn{1}{|p{\maxVarWidth}|}{\centering *:*} & \multicolumn{2}{p{\paraWidth}|}{0 or negative is never} \\\hline
\end{tabular*}

\vspace{0.5cm}\noindent \begin{tabular*}{\tableWidth}{|c|l@{\extracolsep{\fill}}r|}
\hline
\multicolumn{1}{|p{\maxVarWidth}}{np\_order} & {\bf Scope:} private & INT \\\hline
\multicolumn{3}{|p{\descWidth}|}{{\bf Description:}   {\em Second or fourth order accuracy?}} \\
\hline{\bf Range} & &  {\bf Default:} 4 \\\multicolumn{1}{|p{\maxVarWidth}|}{\centering 2} & \multicolumn{2}{p{\paraWidth}|}{Second order} \\\multicolumn{1}{|p{\maxVarWidth}|}{\centering 4} & \multicolumn{2}{p{\paraWidth}|}{Fourth order} \\\multicolumn{1}{|p{\maxVarWidth}|}{\centering 6} & \multicolumn{2}{p{\paraWidth}|}{Sixth  order} \\\hline
\end{tabular*}

\vspace{0.5cm}\parskip = 10pt 

\section{Interfaces} 


\parskip = 0pt

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

\noindent {\bf Implements}: 

npscalars
\vspace{2mm}

\noindent {\bf Inherits}: 

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 
nppsi4r\_group &  & compact & 0 \\ 
 & psi4re & dimensions & 3 \\ 
 &  & distribution & DEFAULT \\ 
 &  & group type & GF \\ 
 &  & tags & tensortypealias="Scalar" tensorweight=0 tensorparity=1 \\ 
 &  & timelevels & 3 \\ 
 &  & variable type & REAL \\ 
\hline 
nppsi4i\_group &  & compact & 0 \\ 
 & psi4im & dimensions & 3 \\ 
 &  & distribution & DEFAULT \\ 
 &  & group type & GF \\ 
 &  & tags & tensortypealias="Scalar" tensorweight=0 tensorparity=-1 \\ 
 &  & timelevels & 3 \\ 
 &  & 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 Lean/NPScalars.  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:}&  ~ \\ 
 NPPsi4R\_group[3] & ~\\ 
 NPPsi4I\_group[3] & ~\\ 
~ & ~\\ 
\end{tabular*} 


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

\noindent {\bf CCTK\_PARAMCHECK} 

\hspace{5mm} npscalars\_paramcheck 

\hspace{5mm}{\it check npscalars parameters for consistency } 


\hspace{5mm}

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


\vspace{5mm}

\noindent {\bf CCTK\_BASEGRID} 

\hspace{5mm} np\_symmetries 

\hspace{5mm}{\it set symmetries for grid functions } 


\hspace{5mm}

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


\vspace{5mm}

\noindent {\bf CalcNPScalars\_BC} 

\hspace{5mm} npboundaries 

\hspace{5mm}{\it symmetry boundary conditions } 


\hspace{5mm}

 \begin{tabular*}{160mm}{cll} 
~ & Language:  & fortran \\ 
~ & Options:  & level \\ 
~ & Sync:  & nppsi4r\_group \\ 
~& ~ &nppsi4i\_group\\ 
~ & Type:  & function \\ 
\end{tabular*} 


\vspace{5mm}

\noindent {\bf CalcNPScalars\_BC} 

\hspace{5mm} applybcs 

\hspace{5mm}{\it apply boundary conditions } 


\hspace{5mm}

 \begin{tabular*}{160mm}{cll} 
~ & After:  & npboundaries \\ 
~ & Type:  & group \\ 
\end{tabular*} 


\vspace{5mm}

\noindent {\bf CCTK\_POSTINITIAL} 

\hspace{5mm} calcnpscalars 

\hspace{5mm}{\it calculate npscalars } 


\hspace{5mm}

 \begin{tabular*}{160mm}{cll} 
~ & Type:  & group \\ 
\end{tabular*} 


\vspace{5mm}

\noindent {\bf MoL\_PseudoEvolution} 

\hspace{5mm} calcnpscalars 

\hspace{5mm}{\it calculate npscalars } 


\hspace{5mm}

 \begin{tabular*}{160mm}{cll} 
~ & After:  & admbase\_setadmvars \\ 
~ & Type:  & group \\ 
\end{tabular*} 


\vspace{5mm}

\noindent {\bf CalcNPScalars} 

\hspace{5mm} np\_calcpsigf 

\hspace{5mm}{\it calculate psi4 as grid function } 


\hspace{5mm}

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


\vspace{5mm}

\noindent {\bf CalcNPScalars} 

\hspace{5mm} calcnpscalars\_bc 

\hspace{5mm}{\it boundary conditions } 


\hspace{5mm}

 \begin{tabular*}{160mm}{cll} 
~ & After:  & np\_calcpsigf \\ 
~ & Type:  & group \\ 
\end{tabular*} 


\vspace{5mm}

\noindent {\bf CCTK\_POSTREGRIDINITIAL} 

\hspace{5mm} calcnpscalars\_bc 

\hspace{5mm}{\it boundary conditions } 


\hspace{5mm}

 \begin{tabular*}{160mm}{cll} 
~ & After:  & mol\_poststep \\ 
~ & Type:  & group \\ 
\end{tabular*} 


\vspace{5mm}

\noindent {\bf CCTK\_POSTREGRID} 

\hspace{5mm} calcnpscalars\_bc 

\hspace{5mm}{\it boundary conditions } 


\hspace{5mm}

 \begin{tabular*}{160mm}{cll} 
~ & After:  & mol\_poststep \\ 
~ & Type:  & group \\ 
\end{tabular*} 


\vspace{5mm}

\noindent {\bf CCTK\_POSTRESTRICTINITIAL} 

\hspace{5mm} calcnpscalars\_bc 

\hspace{5mm}{\it boundary conditions } 


\hspace{5mm}

 \begin{tabular*}{160mm}{cll} 
~ & After:  & mol\_poststep \\ 
~ & Type:  & group \\ 
\end{tabular*} 


\vspace{5mm}

\noindent {\bf CCTK\_POSTRESTRICT} 

\hspace{5mm} calcnpscalars\_bc 

\hspace{5mm}{\it boundary conditions } 


\hspace{5mm}

 \begin{tabular*}{160mm}{cll} 
~ & After:  & mol\_poststep \\ 
~ & Type:  & group \\ 
\end{tabular*} 


\subsection*{Aliased Functions}

\hspace{5mm}

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

{\bf Alias Name:} ~~~~~~~ & {\bf Function Name:} \\ 
ApplyBCs & ApplyBCs\_NP \\ 
\end{tabular*} 



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