\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}

\title{ADMAnalysis}
\author{Tom Goodale et al}
\date{$ $Date$ $}

\maketitle

% Do not delete next line
% START CACTUS THORNGUIDE

\begin{abstract}
Basic analysis of the metric and extrinsic curvature tensors
\end{abstract}

\section{Purpose}

This thorn provides analysis routines to calculate the following quantities:

\begin{itemize}
\item
The trace of the extrinsic curvature ($trK$).
\item
The determinant of the 3-metric ($detg$).
\item
The components of the 3-metric in spherical coordinates \\
($g_{rr},g_{r\theta},g_{r\phi},g_{\theta\theta},g_{\phi\theta},g_{\phi\phi}$).
\item
The components of the extrinsic curvature in spherical coordinates \\
($K_{rr},K_{r\theta},K_{r\phi},K_{\theta\theta},K_{\theta\phi},K_{\phi\phi}$).
\item The components of the 3-Ricci tensor in cartesian coordinates \\
(${\cal R}_{ij}$) for $i,j \in \{1,2,3\}$.
\item The Ricci scalar (${\cal R}$).
\end{itemize}

\section{Trace of Extrinsic Curvature}

The trace of the extrinsic curvature at each point on the grid is placed in
the grid function {\tt trK}. The algorithm for calculating the trace 
uses the physical metric, that is it includes any conformal factor.

\begin{equation}
{\tt trK} \equiv tr K = \frac{1}{\psi^4} g^{ij} K_{ij}
\end{equation}

\section{Determinant of 3-Metric}

The determinant of the 3-metric at each point on the grid is placed in
the grid function {\tt detg}. This is always the determinant of the 
conformal metric, that is it does not include any conformal factor.

\begin{equation}
{\tt detg} \equiv det g =
-g_{13}^2*g_{22}+2*g_{12}*g_{13}*g_{23}-g_{11}*g_{23}^2-
g_{12}^2*g_{33}+g_{11}*g_{22}*g_{33}
\end{equation}


\section{Transformation to Spherical Cooordinates}

The values of the metric and/or extrinsic curvature in a spherical
polar coordinate system $(r,\theta,\phi)$ evaluated at each point on
the computational grid are placed in the grid functions ({\tt grr},
{\tt grt}, {\tt grp}, {\tt gtt}, {\tt gtp}, {\tt gpp}) and ({\tt krr},
{\tt krt}, {\tt krp}, {\tt ktt}, {\tt ktp}, {\tt kpp}).
In the spherical transformation, the $\theta$ coordinate is referred to
as {\bf q} and the $\phi$ as {\bf p}.

The general transformation from Cartesian to Spherical for such tensors 
is

\begin{eqnarray*}
A_{rr}&=&
\sin^2\theta\cos^2\phi A_{xx}
+\sin^2\theta\sin^2\phi A_{yy}
+\cos^2\theta A_{zz}
+2\sin^2\theta\cos\phi\sin\phi A_{xy}
\\
&&
+2\sin\theta\cos\theta\cos\phi A_{xz}
+2\sin\theta\cos\theta\sin\phi A_{yz}
\\
A_{r\theta}&=&
r(\sin\theta\cos\theta\cos^2\phi A_{xx}
+2*\sin\theta\cos\theta\sin\phi\cos\phi A_{xy}
+(\cos^2\theta-\sin^2\theta)\cos\phi A_{xz}
\\
&&
+\sin\theta\cos\theta\sin^2\phi A_{yy}
+(\cos^2\theta-\sin^2\theta)\sin\phi A_{yz}
-\sin\theta\cos\theta A_{zz})
\\
A_{r\phi}&=&
r\sin\theta(-\sin\theta\sin\phi\cos\phi A_{xx}
-\sin\theta(\sin^2\phi-\cos^2\phi)A_{xy}
-\cos\theta\sin\phi A_{xz}
\\
&&
+\sin\theta\sin\phi\cos\phi A_{yy}
+\cos\theta\cos\phi A_{yz})
\\
A_{\theta\theta}&=&
r^2(\cos^2\theta\cos^2\phi A_{xx}
+2\cos^2\theta\sin\phi\cos\phi A_{xy}
-2\sin\theta\cos\theta\cos\phi A_{xz}
+\cos^2\theta\sin^2\phi A_{yy}
\\
&&
-2\sin\theta\cos\theta\sin\phi A_{yz}
+\sin^2\theta A_{zz})
\\
A_{\theta\phi}&=&
r^2\sin\theta(-\cos\theta\sin\phi\cos\phi A_{xx}
-\cos\theta(\sin^2\phi-\cos^2\phi)A_{xy}
+\sin\theta \sin\phi A_{xz}
\\
&&
+\cos\theta\sin\phi\cos\phi A_{yy}
-\sin\theta\cos\phi A_{yz})
\\
A_{\phi\phi}&=&
r^2\sin^2\theta(\sin^2\phi A_{xx}
-2\sin\phi\cos\phi A_{xy}
+\cos^2\phi A_{yy})
\end{eqnarray*}

If the parameter {\tt normalize\_dtheta\_dphi} is set to {\tt yes}, 
the angular components are projected onto the vectors $(r d\theta, r \sin\theta d \phi)$ instead of the default vector $(d \theta, d\phi)$. That is,

\begin{eqnarray*}
A_{\theta\theta} & \rightarrow & A_{\theta\theta}/r^2
\\
A_{\phi\phi}& \rightarrow & A_{\phi\phi}/(r^2\sin^2\theta)
\\
A_{r\theta} & \rightarrow & A_{r\theta}/r
\\
A_{r\phi} & \rightarrow & A_{r\phi}/(r\sin\theta)
\\
A_{\theta\phi} & \rightarrow & A_{\theta\phi}/r^2\sin\theta)
\end{eqnarray*}

\section{Computing the Ricci tensor and scalar}
\label{sec:ricci}

The computation of the Ricci tensor uses the ADMMacros thorn. The
calculation of the Ricci scalar uses the generic trace routine in this
thorn.

% Do not delete next line
% END CACTUS THORNGUIDE



\section{Parameters} 


\parskip = 0pt

\setlength{\tableWidth}{160mm}

\setlength{\paraWidth}{\tableWidth}
\setlength{\descWidth}{\tableWidth}
\settowidth{\maxVarWidth}{ricci\_prolongation\_type}

\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}}{normalize\_dtheta\_dphi} & {\bf Scope:} private & BOOLEAN \\\hline
\multicolumn{3}{|p{\descWidth}|}{{\bf Description:}   {\em Project angular components onto r*dtheta and r*sin(theta)*dphi?}} \\
\hline & & {\bf Default:} no \\\hline
\end{tabular*}

\vspace{0.5cm}\noindent \begin{tabular*}{\tableWidth}{|c|l@{\extracolsep{\fill}}r|}
\hline
\multicolumn{1}{|p{\maxVarWidth}}{ricci\_persist} & {\bf Scope:} private & BOOLEAN \\\hline
\multicolumn{3}{|p{\descWidth}|}{{\bf Description:}   {\em Keep storage of  the  Ricci tensor and scalar around?}} \\
\hline & & {\bf Default:} no \\\hline
\end{tabular*}

\vspace{0.5cm}\noindent \begin{tabular*}{\tableWidth}{|c|l@{\extracolsep{\fill}}r|}
\hline
\multicolumn{1}{|p{\maxVarWidth}}{ricci\_prolongation\_type} & {\bf Scope:} private & KEYWORD \\\hline
\multicolumn{3}{|p{\descWidth}|}{{\bf Description:}   {\em The kind of boundary prolongation for the Ricci tensor and scalar}} \\
\hline{\bf Range} & &  {\bf Default:} none \\\multicolumn{1}{|p{\maxVarWidth}|}{\centering Lagrange} & \multicolumn{2}{p{\paraWidth}|}{standard prolongation (requires several time levels)} \\\multicolumn{1}{|p{\maxVarWidth}|}{\centering copy} & \multicolumn{2}{p{\paraWidth}|}{use data from the current time level (requires only one time level)} \\\multicolumn{1}{|p{\maxVarWidth}|}{\centering none} & \multicolumn{2}{p{\paraWidth}|}{no prolongation (use this if you do not have enough time levels active)} \\\hline
\end{tabular*}

\vspace{0.5cm}\noindent \begin{tabular*}{\tableWidth}{|c|l@{\extracolsep{\fill}}r|}
\hline
\multicolumn{1}{|p{\maxVarWidth}}{ricci\_timelevels} & {\bf Scope:} private & INT \\\hline
\multicolumn{3}{|p{\descWidth}|}{{\bf Description:}   {\em Number of time levels for the Ricci tensor and scalar}} \\
\hline{\bf Range} & &  {\bf Default:} 1 \\\multicolumn{1}{|p{\maxVarWidth}|}{\centering 1:3} & \multicolumn{2}{p{\paraWidth}|}{} \\\hline
\end{tabular*}

\vspace{0.5cm}\noindent \begin{tabular*}{\tableWidth}{|c|l@{\extracolsep{\fill}}r|}
\hline
\multicolumn{1}{|p{\maxVarWidth}}{metric\_type} & {\bf Scope:} shared from ADMBASE & KEYWORD \\\hline
\end{tabular*}

\vspace{0.5cm}\parskip = 10pt 

\section{Interfaces} 


\parskip = 0pt

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

\noindent {\bf Implements}: 

admanalysis
\vspace{2mm}

\noindent {\bf Inherits}: 

admbase

staticconformal

grid

admmacros
\vspace{2mm}
\subsection*{Grid Variables}
\vspace{5mm}\subsubsection{PUBLIC GROUPS}

\vspace{5mm}

\begin{tabular*}{150mm}{|c|c@{\extracolsep{\fill}}|rl|} \hline 
~ {\bf Group Names} ~ & ~ {\bf Variable Names} ~  &{\bf Details} ~ & ~\\ 
\hline 
trace\_of\_k &  & compact & 0 \\ 
 & trK & description & trace of extrinsic curvature \\ 
 &  & dimensions & 3 \\ 
 &  & distribution & DEFAULT \\ 
 &  & group type & GF \\ 
 &  & tags & tensortypealias="scalar" Prolongation="none" \\ 
 &  & timelevels & 1 \\ 
 &  & variable type & REAL \\ 
\hline 
detofg &  & compact & 0 \\ 
 & detg & description & determinant of the conformal metric \\ 
 &  & dimensions & 3 \\ 
 &  & distribution & DEFAULT \\ 
 &  & group type & GF \\ 
 &  & tags & tensortypealias="scalar" Prolongation="none" \\ 
 &  & timelevels & 1 \\ 
 &  & variable type & REAL \\ 
\hline 
spherical\_metric &  & compact & 0 \\ 
 & grr & description & Metric in spherical coordinates \\ 
 & gqq & dimensions & 3 \\ 
 & gpp & distribution & DEFAULT \\ 
 & grq & group type & GF \\ 
 & grp & tags & Prolongation="none" \\ 
 & gqp & timelevels & 1 \\ 
 &  & variable type & REAL \\ 
\hline 
spherical\_curv &  & compact & 0 \\ 
 & krr & description & extrinsic curvature in spherical coordinates \\ 
 & kqq & dimensions & 3 \\ 
 & kpp & distribution & DEFAULT \\ 
 & krq & group type & GF \\ 
 & krp & tags & Prolongation="none" \\ 
 & kqp & timelevels & 1 \\ 
 &  & variable type & REAL \\ 
\hline 
ricci\_tensor &  & compact & 0 \\ 
 & Ricci11 & description & Components of the Ricci tensor \\ 
 & Ricci12 & dimensions & 3 \\ 
 & Ricci13 & distribution & DEFAULT \\ 
 & Ricci22 & group type & GF \\ 
 & Ricci23 & tags & tensortypealias="dd\_sym" ProlongationParameter="ADMAnalysis::ricci\_prolongation\_type" \\ 
 & Ricci33 & timelevels & 3 \\ 
 &  & variable type & REAL \\ 
\hline 
ricci\_scalar &  & compact & 0 \\ 
 & Ricci & description & The Ricci scalar \\ 
 &  & dimensions & 3 \\ 
 &  & distribution & DEFAULT \\ 
 &  & group type & GF \\ 
 &  & tags & tensortypealias="scalar" ProlongationParameter="ADMAnalysis::ricci\_prolongation\_type" \\ 
 &  & timelevels & 3 \\ 
 &  & variable type & REAL \\ 
\hline 
\end{tabular*} 



\vspace{5mm}

\noindent {\bf Uses header}: 

Symmetry.h
\vspace{2mm}

\noindent {\bf Provides}: 



CartToSphere to 

Trace to 
\vspace{2mm}\parskip = 10pt 

\section{Schedule} 


\parskip = 0pt


\noindent This section lists all the variables which are assigned storage by thorn EinsteinAnalysis/ADMAnalysis.  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 Conditional:} \\ 
~ &  ricci\_tensor[1] ricci\_scalar[1]\\ 
~ &  ricci\_tensor[2] ricci\_scalar[2]\\ 
~ &  ricci\_tensor[3] ricci\_scalar[3]\\ 
~ & ~\\ 
\end{tabular*} 


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

\noindent {\bf CCTK\_PARAMCHECK} 

\hspace{5mm} admanalysis\_paramcheck 

\hspace{5mm}{\it check that the metric\_type is recognised } 


\hspace{5mm}

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


\vspace{5mm}

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

\hspace{5mm} admanalysis\_registersymmetry 

\hspace{5mm}{\it register symmetry of ricci tensor and scalar } 


\hspace{5mm}

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


\vspace{5mm}

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

\hspace{5mm} riccigroup 

\hspace{5mm}{\it calculate ricci tensor, with boundary conditions } 


\hspace{5mm}

 \begin{tabular*}{160mm}{cll} 
~ & Storage:  & ricci\_tensor[1] \\ 
~& ~ &ricci\_scalar[1]\\ 
~& ~ &detofg\\ 
~ & Triggers:  & ricci\_tensor \\ 
~& ~ &ricci\_scalar\\ 
~ & Type:  & group \\ 
\end{tabular*} 


\vspace{5mm}

\noindent {\bf RicciGroup} 

\hspace{5mm} admanalysis\_ricci 

\hspace{5mm}{\it calculate ricci tensor, with boundary conditions } 


\hspace{5mm}

 \begin{tabular*}{160mm}{cll} 
~ & Language:  & c \\ 
~ & Reads:  & admbase::metric \\ 
~ & Type:  & function \\ 
~ & Writes:  & detg(everywhere) \\ 
~& ~ &ricci\_tensor(everywhere)\\ 
~& ~ &ricci\_scalar(everywhere)\\ 
\end{tabular*} 


\vspace{5mm}

\noindent {\bf RicciGroup} 

\hspace{5mm} ricciboundariesgroup 

\hspace{5mm}{\it set ricci tensor on the boundary } 


\hspace{5mm}

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


\vspace{5mm}

\noindent {\bf RicciBoundariesGroup} 

\hspace{5mm} admanalysis\_ricci\_boundaries 

\hspace{5mm}{\it select boundary conditions for the ricci tensor } 


\hspace{5mm}

 \begin{tabular*}{160mm}{cll} 
~ & Language:  & c \\ 
~ & Options:  & level \\ 
~ & Sync:  & ricci\_tensor \\ 
~& ~ &ricci\_scalar\\ 
~ & Type:  & function \\ 
\end{tabular*} 


\vspace{5mm}

\noindent {\bf RicciBoundariesGroup} 

\hspace{5mm} applybcs 

\hspace{5mm}{\it apply boundary conditions to the ricci tensor } 


\hspace{5mm}

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


\vspace{5mm}

\noindent {\bf CCTK\_ANALYSIS} 

\hspace{5mm} admanalysis\_evaltrk 

\hspace{5mm}{\it compute the trace of the extrinsic curvature and the determinant of the metric } 


\hspace{5mm}

 \begin{tabular*}{160mm}{cll} 
~ & Language:  & c \\ 
~ & Reads:  & admbase::metric \\ 
~& ~ &admbase::curv\\ 
~& ~ &staticconformal::psi\\ 
~& ~ &staticconformal::conformal\_state\\ 
~ & Storage:  & trace\_of\_k \\ 
~& ~ &detofg\\ 
~ & Sync:  & trace\_of\_k \\ 
~& ~ &detofg\\ 
~ & Triggers:  & trace\_of\_k \\ 
~& ~ &detofg\\ 
~ & Type:  & function \\ 
~ & Writes:  & trk(everywhere) \\ 
~& ~ &detg(everywhere)\\ 
\end{tabular*} 


\vspace{5mm}

\noindent {\bf CCTK\_ANALYSIS} 

\hspace{5mm} admanalysis\_metriccarttosphere 

\hspace{5mm}{\it calculate the spherical metric in r,theta(q), phi(p) } 


\hspace{5mm}

 \begin{tabular*}{160mm}{cll} 
~ & Language:  & c \\ 
~ & Reads:  & grid::coordinates \\ 
~& ~ &admbase::metric\\ 
~ & Storage:  & spherical\_metric \\ 
~ & Sync:  & spherical\_metric \\ 
~ & Triggers:  & spherical\_metric \\ 
~ & Type:  & function \\ 
~ & Writes:  & spherical\_metric(everywhere) \\ 
\end{tabular*} 


\vspace{5mm}

\noindent {\bf CCTK\_ANALYSIS} 

\hspace{5mm} admanalysis\_curvcarttosphere 

\hspace{5mm}{\it calculate the spherical ex. curvature in r, theta(q), phi(p) } 


\hspace{5mm}

 \begin{tabular*}{160mm}{cll} 
~ & Language:  & c \\ 
~ & Reads:  & grid::coordinates \\ 
~& ~ &admbase::curv\\ 
~ & Storage:  & spherical\_curv \\ 
~ & Sync:  & spherical\_curv \\ 
~ & Triggers:  & spherical\_curv \\ 
~ & Type:  & function \\ 
~ & Writes:  & spherical\_curv(everywhere) \\ 
\end{tabular*} 


\vspace{5mm}

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

\hspace{5mm} riccigroup 

\hspace{5mm}{\it calculate ricci tensor, with boundary conditions } 


\hspace{5mm}

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


\vspace{5mm}

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

\hspace{5mm} ricciboundariesgroup 

\hspace{5mm}{\it set ricci tensor on the boundary } 


\hspace{5mm}

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


\vspace{5mm}

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

\hspace{5mm} ricciboundariesgroup 

\hspace{5mm}{\it set ricci tensor on the boundary } 


\hspace{5mm}

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


\vspace{5mm}

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

\hspace{5mm} riccigroup 

\hspace{5mm}{\it calculate ricci tensor, with boundary conditions } 


\hspace{5mm}

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


\vspace{5mm}

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

\hspace{5mm} riccigroup 

\hspace{5mm}{\it calculate ricci tensor, with boundary conditions } 


\hspace{5mm}

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


\subsection*{Aliased Functions}

\hspace{5mm}

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

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



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