% *======================================================================* % 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]{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} \begin{document} % The author of the documentation \author{Erik Schnetter \textless schnetter@aei.mpg.de\textgreater} % The title of the document (not necessarily the name of the Thorn) \title{SymBase} % the date your document was last changed, if your document is in CVS, % please use: \date{$ $Date$ $} \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} Thorn SymBase contains a registry for symmetry conditions and for symmetry faces. \end{abstract} % The following sections are suggestive only. % Remove them or add your own. \section{Introduction} Thorn SymBase contains a registry for symmetry conditions and for symmetry faces. Other thorns that implement symmetry boundary conditions register themselves with this thorn and reserve certain faces of the grid, so that no other boundary condition is applied there. Thorns that implement physical boundary conditions should query this thorn about the set of faces that have symmetry boundary conditions and should not apply the physical boundary condition there. \begin{figure}[tb] \begin{center} \includegraphics[scale=.833,clip=true]{fig/faces.eps} \end{center} \caption[Symmetry transformations across faces] { A SymBase symmetry transformation can incorporate multiple geometric symetry transformations, one for each registered symmetry face. In cases of a reflection symmetry across a component face, the data may be stored only on one side of the face. To get data values at a point on the other side of the face, the point is transformed (reflected, in this case) across the face. Here, a point $x$ is transformed to point $x'$ by transformation $A$, and then to point $x''$ by transformation $B$. Data is only actually stored for point $x''$. } \label{SymBase.faces} \end{figure} \section{Registering Symmetry Conditions} Each thorn that implements a symmetry boundary condition should register itself with thorn SymBase. This has no consequences per se, but it reservers a symmetry handle for later use. The API for registering and querying symmetry names and handles is \begin{verbatim} CCTK_INT FUNCTION SymmetryRegister (CCTK_STRING IN sym_name) CCTK_INT FUNCTION SymmetryHandleOfName (CCTK_STRING IN sym_name) CCTK_POINTER_TO_CONST FUNCTION SymmetryNameOfHandle (CCTK_INT IN sym_handle) \end{verbatim} The routine \texttt{SymmetryRegister} should be called in a routine that has been scheduled in the schedule group \texttt{SymmetryRegister}. \begin{quote} Note: We have the API in the specification, we have it in the interface file, in the source code, and in a header file, and I duplicated it into grdoc headers. I refuse to write and describe and cross-check the API a \emph{sixth} time in latex. At some point, we have to start using tools for that. Please read the grdoc headers or the grdoc-produced html files for a detailed description. \end{quote} \section{Registering Symmetries for Faces} Thorn SymBase keeps two registries. The first, described in the previous section, contains the set of symmetry boundary conditions that exist at all. The second, described here, describes which face of the grids have which symmetry condition applied to it, if any. Each such mapping from grid face to symmetry condition is described by a symmetry table with the following entries: \begin{verbatim} CCTK_INT symmetry_handle[] CCTK_INT symmetry_zone_width[] \end{verbatim} Each of these arrays contains one element per face, numbered in the same way as the \texttt{cctk\_bbox} array. The \texttt{symmetry\_handle} is a symmetry handle as described in the previous section, and the \texttt{symmetry\_zone\_width} is the width of the symmetry zone. Code outside SymBase should not modify these table entries. There is one such table for the grid hierarchy, which is valid for all grid functions. There is additionally one such table for each grid array group. The API for registering symmetries for faces is \begin{verbatim} CCTK_INT FUNCTION SymmetryRegisterGrid (CCTK_POINTER IN cctkGH, CCTK_INT IN sym_handle, CCTK_INT IN ARRAY which_faces, CCTK_INT IN ARRAY symmetry_zone_width) CCTK_INT FUNCTION SymmetryRegisterGI (CCTK_POINTER IN cctkGH, CCTK_INT IN sym_handle, CCTK_INT IN ARRAY which_faces, CCTK_INT IN ARRAY symmetry_zone_width, CCTK_INT IN group_index) CCTK_INT FUNCTION SymmetryRegisterGN (CCTK_POINTER IN cctkGH, CCTK_INT IN sym_handle, CCTK_INT IN ARRAY which_faces, CCTK_INT IN ARRAY symmetry_zone_width, CCTK_STRING IN group_name) \end{verbatim} The first routine registers a symmetry condition for certain faces for the grid hierarchy, the other two routines register for grid array groups. \texttt{sym\_handle} must be a symmetry handle obtained as described in the previous section. \texttt{which\_faces} and \texttt{symmetry\_zone\_width} are arrays with one element per face, numbered in the same way as the \texttt{cctk\_bbox} array. \texttt{which\_faces} selects which faces to register, and \texttt{symmetry\_zone\_width} sets the number of symmetry zones for these faces. It is obviously not possible to register multiple symmetry conditions for the same face. \section{Querying Symmetries of Faces} Physical boundary conditions need to know to which faces they should apply the boundary condition. They need to query SymBase for the set of faces that have a symmetry boundary condition, and they must not apply their physical boundary condition there. The API is \begin{verbatim} CCTK_INT FUNCTION SymmetryTableHandleForGrid (CCTK_POINTER_TO_CONST IN cctkGH) CCTK_INT FUNCTION SymmetryTableHandleForGI (CCTK_POINTER_TO_CONST IN cctkGH, CCTK_INT IN group_index) CCTK_INT FUNCTION SymmetryTableHandleForGN (CCTK_POINTER_TO_CONST IN cctkGH, CCTK_STRING IN group_name) \end{verbatim} These functions return the the handle for the symmetry table for the grid hierarchy or for the grid array group, respectively. The table entry \texttt{symmetry\_handle} contains the symmetry handle for the symmetry boundary condition, or a negative number if the face has no symmetry boundary condition associated with it. The code to find out which boundaries should have a physical boundary condition applied might look as follows: \begin{verbatim} #include "cctk.h" #include "util_Table.h" CCTK_INT symtable; CCTK_INT symbnd[6]; int face; int ierr; symtable = SymmetryTableHandleForGrid (cctkGH); if (symtable<0) CCTK_VWarn(0, __LINE__, __FILE__, "Thorn_Name", "symtable is out of bounds"); ierr = Util_TableGetIntArray (symtable, 6, symbnd, "symmetry_handle"); if (ierr!=6) CCTK_VWarn(0, __LINE__, __FILE__, "Thorn_Name", "Util_TableGetIntArray returned error"); for (face=0; face<6; ++face) { if (cctk_bbox[face] && symbnd[face]<0) { /* Apply physical boundary condition here */ } } \end{verbatim} \hrule \begin{verbatim} #include "util_Table.h" CCTK_INT symtable CCTK_INT symbnd(6) integer face integer ierr symtable = SymmetryTableHandleForGrid (cctkGH) if (symtable<0) call CCTK_WARN (0, "internal error") call Util_TableGetIntArray (ierr, int(symtable), 6, symbnd, "symmetry_handle") if (ierr/=6) call CCTK_WARN (0, "internal error") do face=1,6 if (cctk_bbox(face)/=0 .and. symbnd(face)<0) then ! Apply physical boundary condition here end if end do \end{verbatim} \section{Symmetry Interpolation} When the computational domain has symmetries, then it is often very convenient to be able to interpolate at points that are not present on the actual computational grid, but can be mapped into the grid through the symmetries. Thorn SymBase provides a mechanism by which symmetry conditions can register routines that handle this mapping when a global interpolator is called. Additionally, the driver has to be aware that it calls thorn SymBase's mapping routine before it actually interpolates. The whole mechanism is transparent for the user. The mechanism by which the grid points are mapped into the domain works as follows: \begin{enumerate} \item The user calls \texttt{CCTK\_InterpGridArrays} with a list of coordinates. \item The flesh forwards this call to the driver. \item The driver calls SymBase's aliased function, \texttt{SymmetryInterpolate}, passing along all arguments. \item SymBase sets a flag for all boundaries that have a symmetry condition associated with it, and then calls \texttt{SymmetryInterpolateFaces}, passing along all arguments. This is the beginning of a chain of recursive calls. \item \texttt{SymmetryInterpolateFaces} checks whether any faces are flagged. \item If no faces are flagged, SymBase calls the driver's aliased function \texttt{DriverInterpolate}, which performs the actual interpolation. This ends the chain of recursive calls. \item If there are faces with symmetry conditions flagged, SymBase chooses one such face, and then calls this face's symmetry condition's ``symmetry interpolation'' routine, passing along all arguments. \item The ``symmetry interpolation'' routine maps the coordinates into the domain by applying the symmetry condition for this face. It then removes the flag for the corresponding face, and calls \texttt{SymmetryInterpolateFaces}, passing along the arguments with the changed interpolation locations. \item After the actual interpolation has happened in the driver, the recursive call will return. The ``symmetry interpolation'' routine then examines the tensor types of the interpolated quantities and un-maps the values back onto their original locations. That is, e.g., after a reflection on the lower $x$-boundary, $x$-components of vectors need their sign changed. \item The chain of recursive calls unravels until the call to \texttt{CCTK\_InterpGridArrays} returns. \end{enumerate} This mechanism has thus four players: \begin{itemize} \item The driver forwards the call to SymBase so that the list of interpolation points can be mapped into the domain. \item Thorn SymBase controls which symmetry conditions perform this mapping on which faces. \item Each symmetry boundary condition has to register a ``symmetry interpolation'' routine that first maps the points into the domain, then calls SymBase recursively, and finally corrects the tensor types of the interpolated quantities. \item Finally, the user calls \texttt{CCTK\_InterpGridArrays} as before, and everything happens transparently for her. \end{itemize} \begin{figure}[tb] \begin{center} \includegraphics[scale=.833,clip=true]{fig/recursion.eps} \end{center} \caption[Symmetry interpolation] { The recursive calls involved in symmety interpolation. Values of grid functions $a$ at global cartesian coordinates $x$ are calculated by nested calls to the symmetry interpolators, which first apply the symmetry transformation to the coordinates. When all the symmetries have been applied, the local interpolator is called, producing the interpolation of grid function values in the local basis. As the symmetry interpolators return, they apply the inverse basis transformation to the interpolated grid function values. } \label{SymBase.recursion} \end{figure} \subsection{Driver Interaction} The driver has to call SymBase's aliased function \texttt{SymmetryInterpolate}, and has to provide an aliased function \texttt{DriverInterpolate}. Both functions have essentially the same prototype as \texttt{CCTK\_InterpGridArrays}, which are: \begin{verbatim} CCTK_INT FUNCTION SymmetryInterpolate (CCTK_POINTER_TO_CONST IN cctkGH, CCTK_INT IN N_dims, CCTK_INT IN local_interp_handle, CCTK_INT IN param_table_handle, CCTK_INT IN coord_system_handle, CCTK_INT IN N_interp_points, CCTK_INT IN interp_coords_type, CCTK_POINTER_TO_CONST ARRAY IN interp_coords, CCTK_INT IN N_input_arrays, CCTK_INT ARRAY IN input_array_indices, CCTK_INT IN N_output_arrays, CCTK_INT ARRAY IN output_array_types, CCTK_POINTER ARRAY IN output_arrays) \end{verbatim} \begin{verbatim} CCTK_INT FUNCTION DriverInterpolate (CCTK_POINTER_TO_CONST IN cctkGH, CCTK_INT IN N_dims, CCTK_INT IN local_interp_handle, CCTK_INT IN param_table_handle, CCTK_INT IN coord_system_handle, CCTK_INT IN N_interp_points, CCTK_INT IN interp_coords_type, CCTK_POINTER_TO_CONST ARRAY IN interp_coords, CCTK_INT IN N_input_arrays, CCTK_INT ARRAY IN input_array_indices, CCTK_INT IN N_output_arrays, CCTK_INT ARRAY IN output_array_types, CCTK_POINTER ARRAY IN output_arrays) \end{verbatim} \subsection{Interaction With Symmetry Conditions} The symmetry conditions have to register their ``symmetry interpolation'' routines by calling SymBase's aliased function \texttt{SymmetryRegisterGridInterpolator}. The ``symmetry interpolation'' routine must use C linkage and must have the prototype \begin{verbatim} CCTK_INT symmetry_interpolate (CCTK_POINTER_TO_CONST IN cctkGH, CCTK_INT IN N_dims, CCTK_INT IN local_interp_handle, CCTK_INT IN param_table_handle, CCTK_INT IN coord_system_handle, CCTK_INT IN N_interp_points, CCTK_INT IN interp_coords_type, CCTK_POINTER_TO_CONST ARRAY IN interp_coords, CCTK_INT IN N_input_arrays, CCTK_INT ARRAY IN input_array_indices, CCTK_INT IN N_output_arrays, CCTK_INT ARRAY IN output_array_types, CCTK_POINTER ARRAY IN output_arrays, CCTK_INT IN faces) \end{verbatim} These arguments are essentially the same as those for \texttt{CCTK\_InterpGridArrays}, except that the bit field \texttt{faces} flags those faces that still need their symmetry boundary condition applied to the interpolation points. The aliased function \texttt{SymmetryRegisterGridInterpolator} has the prototype \begin{verbatim} CCTK_INT FUNCTION \ SymmetryRegisterGridInterpolator \ (CCTK_POINTER IN cctkGH, \ CCTK_INT IN sym_handle, \ CCTK_INT CCTK_FPOINTER IN symmetry_interpolate \ (CCTK_POINTER_TO_CONST IN cctkGH, \ CCTK_INT IN N_dims, \ CCTK_INT IN local_interp_handle, \ CCTK_INT IN param_table_handle, \ CCTK_INT IN coord_system_handle, \ CCTK_INT IN N_interp_points, \ CCTK_INT IN interp_coords_type, \ CCTK_POINTER_TO_CONST ARRAY IN interp_coords, \ CCTK_INT IN N_input_arrays, \ CCTK_INT ARRAY IN input_array_indices, \ CCTK_INT IN N_output_arrays, \ CCTK_INT ARRAY IN output_array_types, \ CCTK_POINTER ARRAY IN output_arrays, \ CCTK_INT IN faces)) \end{verbatim} which takes a function pointer to the aforementioned ``symmetry interpolation'' routine, while \texttt{sym\_handle} specifies which symmetry condition this routine is for. This handle must have been obtained from \texttt{SymmetryRegister}. \begin{quote} The routine \texttt{SymmetryRegisterGridInterpolator} must be called \emph{after} the symmetry faces have been selected by the call to \texttt{SymmetryRegisterGrid}. \end{quote} \section{Tensor Types} Cactus supports declaring the \emph{tensor type} of grid function groups. These tensor types define how the grid functions, which are supposed to be tensor components, transform under various transformations, such as reflections and rotations. The tensor types are not declared directly; instead, a \emph{tensor type alias} is declared. The following tensor type aliases are currently known and supported: \begin{description} \item[\texttt{scalar}:] a scalar $\rho$ \item[\texttt{u}:] a vector $\beta^i$ \item[\texttt{d}:] a covector $s_i$ \item[\texttt{dd\_sym}:] a symmetric rank two tensor $\gamma_{ij}$ \end{description} (More tensor type aliases are likely to be defined in the future.) In addition to the tensor type, one can also declare the \emph{tensor weight} and a \emph{tensor metric}. The tensor weight specifies the behaviour under transformations that change the volume element. The tensor metric specifies what metric has to be used to raise or lower indices for that quantity. Last but not least, a \emph{tensor special} can be defined for quantities that do not transform as tensor. The currently supported tensor specials are \begin{description} \item[\texttt{Gamma}:] for the transformation behaviour of the $\Gamma^i$ variables of the BSSN formalism; it is $\Gamma^i := - \gamma^{jk} \Gamma^i_{jk}$ with $\Gamma^i_{jk} := \frac{1}{2} \gamma^{il} \left( \partial_k \gamma_{lj} + \partial_j \gamma_{lk} - \partial_l \gamma_{jk} \right)$ \item[\texttt{log}:] for the transformation behaviour of the variable $\phi$ of the BSSN formalism; it is $\phi := \log \psi$ with $\psi^{12} := \det \gamma_{ij}$. \end{description} \subsection{Example Tensor Type Declarations} From CactusWave/WaveToy: \begin{verbatim} CCTK_REAL scalarevolve TYPE=gf TAGS='tensortypealias="scalar"' \end{verbatim} From CactusEinstein/ADMBase: \begin{verbatim} CCTK_REAL metric TYPE=gf TAGS='tensortypealias="dd_sym" tensormetric="ADMBase::metric"' CCTK_REAL curv TYPE=gf TAGS='tensortypealias="dd_sym" tensormetric="ADMBase::metric"' CCTK_REAL lapse TYPE=gf TAGS='tensortypealias="scalar" tensormetric="ADMBase::metric"' CCTK_REAL shift TYPE=gf TAGS='tensortypealias="U" tensormetric="ADMBase::metric"' \end{verbatim} From AEIThorns/BSSN\_MoL: \begin{verbatim} CCTK_REAL ADM_BSSN_B TYPE=gf \ TAGS='tensortypealias="u" tensormetric="ADMBase::metric"' CCTK_REAL ADM_BSSN_dtlapse TYPE=gf \ TAGS='tensortypealias="scalar" tensormetric="ADMBase::metric"' CCTK_REAL ADM_BSSN_phi TYPE=gf \ TAGS='tensortypealias="scalar" tensormetric="BSSN_MoL::ADM_BSSN_metric" \ tensorweight=0.16666666666666667 tensorspecial="log"' CCTK_REAL ADM_BSSN_metric TYPE=gf \ TAGS='tensortypealias="dd_sym" tensormetric="BSSN_MoL::ADM_BSSN_metric" \ tensorweight=-0.66666666666666667' CCTK_REAL ADM_BSSN_K TYPE=gf \ TAGS='tensortypealias="scalar" tensormetric="BSSN_MoL::ADM_BSSN_metric"' CCTK_REAL ADM_BSSN_curv TYPE=gf \ TAGS='tensortypealias="dd_sym" tensormetric="BSSN_MoL::ADM_BSSN_metric" \ tensorweight=-0.66666666666666667' CCTK_REAL ADM_BSSN_gamma TYPE=gf \ TAGS='tensortypealias="u" tensormetric="BSSN_MoL::ADM_BSSN_metric" \ tensorweight=0.66666666666666667 tensorspecial="Gamma"' \end{verbatim} % Do not delete next line % END CACTUS THORNGUIDE \end{document}