\frame{ \frametitle{WaveToy Thorn: Wave Equation} For a given source function $S(x,y,z,t)$ find a scalar wave field $\varphi(x,y,z,t)$ inside the domain $\mathcal{D}$ with a boundary condition: \begin{columns}[t] \column{.3\textwidth} \begin{figure}[!htp] \begin{center} \begin{tikzpicture}[rotate=5,scale=1.2] \filldraw[fill=green!60!white, draw=green!50!black, thick] (-1,-1) rectangle (1,1); \draw (0,0) node {{\large $\mathcal{D}$}}; \draw (1.4,0.2) node {$\partial\mathcal{D}$}; \draw[->,thick,color=red] (1.1,0.2) -- (1,0.2); \end{tikzpicture} \end{center} \end{figure} \column{.6\textwidth} \begin{itemize} \item inside $\mathcal{D}$: \begin{equation*} \frac{\partial^2\varphi}{\partial t^2} = c^2\Delta\varphi + S \end{equation*} \item on the boundary $\partial\mathcal{D}$: \begin{equation*} \varphi|_{\partial\mathcal{D}} = \varphi(t=0) \end{equation*} \end{itemize} \end{columns} } \frame{ \frametitle{WaveToy Thorn: Discretization} Discretization: \\ approximating continuous function $\varphi(x,t)$ with a grid function $\varphi^{(n)}_{i}$: \begin{columns}[t] \column{.2\textwidth} \begin{figure}[!htp] \begin{center} \begin{tikzpicture}[scale=1.1] \draw (-1,0) -- (1,0); \draw (0,-1) -- (0,1); \scope[fill=green!50!blue, draw=black] \filldraw (0,0) circle (0.07cm); \filldraw (1,0) circle (0.07cm); \filldraw (0,1) circle (0.07cm); \filldraw (-1,0) circle (0.07cm); \filldraw (0,-1) circle (0.07cm); \endscope \scope[xshift=0.45cm,yshift=0.25cm] \draw (0,0) node {{\tiny $\varphi^{(n)}_{i}$}}; \draw (1,0) node {{\tiny $\varphi^{(n)}_{i+1}$}}; \draw (0,1) node {{\tiny $\varphi^{(n+1)}_{i}$}}; \draw (-1,0) node {{\tiny $\varphi^{(n)}_{i-1}$}}; \draw (0,-1) node {{\tiny $\varphi^{(n-1)}_{i}$}}; \endscope \end{tikzpicture} \end{center} \end{figure} \column{.8\textwidth} \begin{eqnarray*} \\ &\frac{\partial^2\varphi}{\partial t^2} = c^2 (\partial_x^2\varphi) + S \\ &\Downarrow (c\equiv1)\\ &\frac{\varphi^{(n+1)}_{i} - 2\varphi^{(n)}_{i}+\varphi^{(n-1)}_{i}} {2\Delta t^2} = \frac{\varphi^{(n)}_{i+1} - 2\varphi^{(n)}_{i}+\varphi^{(n)}_{i-1}} {2\Delta x^2} + S^{(n)}_{i} \end{eqnarray*} \end{columns} } \frame{ \frametitle{WaveToy Thorn} Thorn structure: \begin{columns}[t] \column{.4\textwidth} \begin{exampleblock}{interface.ccl} \begin{itemize} \item grid function {\color{blue}phi[3]}: \end{itemize} \begin{figure}[!htp] \begin{center} \begin{tikzpicture} \scope[fill=white!90!green, draw=black] \filldraw (-1.5,-1) -- (0.5,-1) -- (1.5,-0.2) -- (-0.5,-0.2) -- cycle; \filldraw (-1.5,-0.4) -- (0.5,-0.4) -- (1.5,0.4) -- (-0.5,0.4) -- cycle; \filldraw (-1.5,0.2) -- (0.5,0.2) -- (1.5,1) -- (-0.5,1) -- cycle; \endscope \scope[fill=green!50!blue, draw=black, dashed, very thin] \draw (-0.6,0) -- (0.6,0); \draw (0,-0.6) -- (0,0.6); \draw (-0.35,-0.3) -- (0.35,0.3); \filldraw (0,0) circle (0.07cm); \filldraw (0.6,0) circle (0.07cm); \filldraw (0,0.6) circle (0.07cm); \filldraw (-0.6,0) circle (0.07cm); \filldraw (0,-0.6) circle (0.07cm); \filldraw (-0.35,-0.3) circle (0.07cm); \filldraw (0.35,0.3) circle (0.07cm); \endscope \scope[left=2pt,yshift=0.2cm] \draw (-1.5,-1) node {\color{blue}phi\_p\_p}; \draw (-1.5,-0.4) node {\color{blue}phi\_p}; \draw (-1.5, 0.2) node {\color{blue}phi}; \endscope \scope[xshift=0.6cm,yshift=0.2cm] \draw (-1.5,-1) node {{\tiny $\varphi^{(n-2)}$}}; \draw (-1.5,-0.4) node {{\tiny $\varphi^{(n-1)}$}}; \draw (-1.5, 0.2) node {{\tiny $\varphi^{(n)}$}}; \endscope %\includegraphics[height=0.3\textheight]{time_levels} \end{tikzpicture} \end{center} \end{figure} \begin{itemize} \item {\small Boundary\_SelectVarForBC} \end{itemize} \end{exampleblock} \column{.4\textwidth} \begin{exampleblock}{param.ccl} \begin{itemize} \item Parameters of initial Gaussian pulse: amplitude {\color{brown}$A$}, radius {\color{brown}$R$}, width {\color{brown}$\sigma$} \end{itemize} \end{exampleblock} \begin{exampleblock}{schedule.ccl} \begin{itemize} \item WaveToy\_InitialData \item WaveToy\_Evolution \item WaveToy\_Boundaries \end{itemize} \end{exampleblock} \end{columns} } % \frame{ \frametitle{WaveToy Thorn} % \begin{itemize} % \item Choose initial values $\Phi_{i,j,k,0}$; % \item Loop: % \begin{itemize} % \item Calculate field at current time based on discretized wave equation % \item On boundary points, where derivatives may not be present, apply chosen % boundary conditions % \end{itemize} % \end{itemize} % } \frame{ \frametitle{WaveToy Thorn: Algorithm Illustration} \begin{columns}[t] \column{.7\textwidth} \begin{figure}[!htp] \begin{center} \begin{tikzpicture} %\draw[->] (0,0) -- (1,1); % Step 1: axes and grid \draw[->,very thin] (-.6,-.4) -- (6,-.4); \draw[->,very thin] (-.4,-.6) -- (-.4,3); \draw[left=2pt] (-.4,2.5) node {$t$}; \draw[above=2pt] (5.8,-0.4) node {$x$}; \uncover<1>{ \draw[xstep=.6cm,ystep=.4cm,gray,dashed] (0,0) grid(5.4cm,2.6cm); }% % Step 2: splitting between two processors \uncover<2->{ \draw (0,2.8) -- (.6,3.2) -- (2.4,3.2) -- (3,2.8); \draw[above=1pt] (1.4,3.2) node {\emph{PROC1}}; \draw[xshift=2.4cm] (0,2.8) -- (.6,3.2) -- (2.4,3.2) -- (3,2.8); \draw[above=1pt] (3.8,3.2) node {\emph{PROC2}}; }% \uncover<2-4>{ \draw[xstep=.6cm,ystep=.4cm,gray,dashed] (0,0) grid (3.0cm,2.6cm); \draw[xstep=.6cm,ystep=.4cm,gray,dashed,xshift=0.05cm,yshift=0.05cm] (2.4,0) grid (5.4cm,2.6cm); }% % Step 3: memory "allocations" \uncover<3>{ \draw[color=blue] (1.5,-0.6) node {\tiny x, phi, phi\_p, phi\_p\_p}; \draw[color=blue] (4.2,-0.6) node {\tiny x, phi, phi\_p, phi\_p\_p}; }% % Step 4: CoordBase / CartGrid3D \uncover<4->{ \foreach \x in {0.0,0.6,1.2,1.8,2.4,3.0,3.6,4.2,4.8,5.4} \draw (\x cm,-0.4cm) node[anchor=south] {{\tiny $\x$}}; \draw[very thick,color=brown,xstep=0.6cm,ystep=1cm,yshift=-0.4cm] (0cm,-1pt) grid (3.0cm,1pt); \draw[color=blue] (1.5,-0.6) node {\small x}; \draw[very thick,color=brown,xstep=0.6cm,ystep=1cm,xshift=2.45cm,yshift=-0.35cm] (0cm,-1pt) grid (3.0cm,1pt); \draw[color=blue] (4.2,-0.6) node {\small x}; } \uncover<4-5>{ \draw[color=blue] (1.5,-1.0) node {\tiny phi, phi\_p, phi\_p\_p}; \draw[color=blue] (4.2,-1.0) node {\tiny phi, phi\_p, phi\_p\_p}; }% % Step 5: Time \uncover<5->{ \draw[xstep=.6cm,ystep=.4cm,gray,dashed] (0,0) grid (3.0cm,2.6cm); \draw[xstep=.6cm,ystep=.4cm,gray,dashed,xshift=0.05cm,yshift=0.05cm] (2.4,0) grid (5.4cm,2.6cm); }% \uncover<5>{ \scope[color=red,thick,fill=white] \draw (-0.5,0.4) -- (0.0,0.4); \draw (-0.5,0.8) -- (0.0,0.8); \draw[->] (-0.1,1.2) -- (-0.1,0.8); \draw[<-] (-0.1,0.4) -- (-0.1,0.0); \endscope \draw (0,0.6) node[anchor=west,fill=white] {$\Delta t = \lambda\Delta x_{\min}$}; } % Step 6: Initial data routines \uncover<6->{ \scope[very thick,color=green,xstep=0.6cm,ystep=1cm] \draw[xshift=0cm,yshift=0cm] (0cm,-1pt) grid (3.0cm,1pt); \draw[xshift=2.45cm,yshift=0.05cm] (0cm,-1pt) grid (3.0cm,1pt); \draw[xshift=0cm,yshift=0.4cm] (0cm,-1pt) grid (3.0cm,1pt); \draw[xshift=2.45cm,yshift=0.45cm] (0cm,-1pt) grid (3.0cm,1pt); \draw[xshift=0cm,yshift=0.8cm,color=black] (0cm,-1pt) grid (3.0cm,1pt); \draw[xshift=2.45cm,yshift=0.85cm,color=black] (0cm,-1pt) grid (3.0cm,1pt); \endscope }% \uncover<6>{ \scope[color=blue] \draw (-0.5,0.0) node[anchor=east] {\small phi\_p}; \draw (-0.5,0.4) node[anchor=east] {\small phi}; \draw (-0.5,0.8) node[anchor=east] {\small phi\_p\_p}; \endscope } % Step 7: Layers rotation \uncover<7>{ %\draw[thick,color=red,->] (-0.5,-0.1) arc (-25:25:1.1cm); \draw[thick,color=red,->] (-1.8, 0.8) arc (155:205:1.1cm); } \uncover<7-11>{ \scope[color=blue] \draw (-0.5,0.0) node[anchor=east] {\small phi\_p\_p}; \draw (-0.5,0.4) node[anchor=east] {\small phi\_p}; \draw (-0.5,0.8) node[anchor=east] {\small phi}; \endscope } % Step 8: Evaluation of RHS \uncover<8>{ \scope[draw=red,thick,fill=green] \draw (0.0,0.4) -- (1.2,0.4); \draw[->] (0.6,0.0) -- (0.6,0.7); \filldraw (0.6,0.8) circle (0.1cm); \filldraw (0.6,0.0) circle (0.1cm); \filldraw (0.0,0.4) circle (0.1cm); \filldraw (0.6,0.4) circle (0.1cm); \filldraw (1.2,0.4) circle (0.1cm); % second processor: \scope[xshift=0.05cm,yshift=0.05cm] \fill (3.0,0.8) circle (0.05cm); \fill (3.6,0.8) circle (0.05cm); \scope[xshift=3.6cm] \draw (0.0,0.4) -- (1.2,0.4); \draw[->] (0.6,0.0) -- (0.6,0.7); \filldraw (0.6,0.8) circle (0.1cm); \filldraw (0.6,0.0) circle (0.1cm); \filldraw (0.0,0.4) circle (0.1cm); \filldraw (0.6,0.4) circle (0.1cm); \filldraw (1.2,0.4) circle (0.1cm); \endscope \endscope \endscope }% % Step 9: Ghost zones \uncover<9>{ \scope[very thick,color=green,xstep=0.6cm,ystep=1cm] \draw[xshift=0.6cm,yshift=0.8cm] (0cm,-1pt) grid (1.8cm,1pt); \draw[xshift=3.05cm,yshift=0.85cm] (0cm,-1pt) grid (1.8cm,1pt); \draw[->,color=red] (2.4,0.7) -- (2.4,0.9); \draw[->,color=red] (3.05,0.9) -- (3.05,0.7); \endscope }% % Step 10: Boundary conditions \uncover<10>{ \scope[very thick,color=green,xstep=0.6cm,ystep=1cm] \draw[xshift=0.6cm,yshift=0.8cm] (0cm,-1pt) grid (2.4cm,1pt); \draw[xshift=2.45cm,yshift=0.85cm] (0cm,-1pt) grid (2.4cm,1pt); \draw[->,color=red] (0.0,0.4) -- (0.0,0.8); \draw[->,color=red] (5.45,0.45) -- (5.45,0.85); \endscope }% % Step 11: Output data \uncover<11->{ \scope[very thick,color=green,xstep=0.6cm,ystep=1cm] \draw[xshift=0cm,yshift=0.8cm] (0cm,-1pt) grid (3.0cm,1pt); \draw[xshift=2.45cm,yshift=0.85cm] (0cm,-1pt) grid (3.0cm,1pt); \endscope } % Step 11: Advance to the next time level \uncover<12>{ \scope[very thick,color=green,xstep=0.6cm,ystep=1cm] \draw[xshift=0cm,yshift=1.2cm,color=black] (0cm,-1pt) grid (3.0cm,1pt); \draw[xshift=2.45cm,yshift=1.25cm,color=black] (0cm,-1pt) grid (3.0cm,1pt); \draw[xshift=0cm,yshift=0.8cm] (0cm,-1pt) grid (3.0cm,1pt); \draw[xshift=2.45cm,yshift=0.85cm] (0cm,-1pt) grid (3.0cm,1pt); \endscope \scope[color=blue] \draw (-0.5,0.4) node[anchor=east] {\small phi\_p}; \draw (-0.5,0.8) node[anchor=east] {\small phi}; \draw (-0.5,1.2) node[anchor=east] {\small phi\_p\_p}; \endscope } \end{tikzpicture} \end{center} \end{figure} \column{.3\textwidth} \begin{figure}[!htp] \begin{center} \vspace{-1cm} \begin{tikzpicture} \draw (0,7) node [anchor=north,right,text width=3cm,rounded corners,fill=green!20,draw=blue!50!black] %,inner sep=1ex] (begin) {\begin{footnotesize} \begin{itemize} \item[] \hspace{-0.5cm} Grid structure \item[] \hspace{-0.5cm} GF allocation \end{itemize} \end{footnotesize}}; \draw (0,5.3) node [anchor=north,right,text width=3cm,rounded corners,fill=green!20,draw=blue!50!black] %,inner sep=1ex] (init) {\begin{footnotesize} \begin{itemize} \item[] \hspace{-0.5cm} Set up coords \item[] \hspace{-0.5cm} Compute $\Delta t$ \item[] \hspace{-0.5cm} Initial data \end{itemize} \end{footnotesize} }; \draw[->,thick,draw=blue!50!black] (0,2.15) -- (-0.3,2.15) -- (-0.3,3.8) -- (-0.05,3.8); \draw (0,3) node [anchor=north,right,text width=3cm,rounded corners,fill=green!20,draw=blue!50!black] %,inner sep=1ex] (evol) {\begin{footnotesize} \begin{itemize} \item[] \hspace{-0.5cm} Rotate timelevels \item[] \hspace{-0.5cm} Evolve GF, sync \item[] \hspace{-0.5cm} Apply BCs \item[] \hspace{-0.5cm} Output data \end{itemize} \end{footnotesize} }; \scope[color=blue!50!black,thick] \draw[->,shorten >=2pt] (begin.south) -- (init.north); \draw[->,shorten >=2pt] (init.south) -- (evol.north); \endscope \end{tikzpicture} \end{center} \end{figure} \end{columns} } %\frame[containsverbatim]{ \frametitle{WaveToy Thorn} % Implemented in \verb|CactusWave/WaveToy|: % \begin{itemize} % \item \href{http://www.cct.lsu.edu/~bentivegna/WaveToy/interface.ccl}{interface.ccl} % \item \href{http://www.cct.lsu.edu/~bentivegna/WaveToy/schedule.ccl}{schedule.ccl} % \item \href{http://www.cct.lsu.edu/~bentivegna/WaveToy/param.ccl}{param.ccl} % \item \href{http://www.cct.lsu.edu/~bentivegna/WaveToy/src}{src/ directory} % \end{itemize} %} \frame[containsverbatim]{ \frametitle{WaveToy Thorn} Directory structure: \begin{alltt} WaveToy/ |-- COPYRIGHT |-- README |-- configuration.ccl |-- doc | `-- documentation.tex |-- interface.ccl |-- schedule.ccl |-- param.ccl `-- src |-- WaveToy.c `-- make.code.defn \end{alltt} } \frame[containsverbatim]{ \frametitle{WaveToy Thorn} Directory structure: \begin{alltt} WaveToy/ |-- COPYRIGHT |-- README |-- configuration.ccl |-- doc | `-- documentation.tex \textcolor{blue}{|-- interface.ccl |-- schedule.ccl |-- param.ccl} `-- src |-- WaveToy.c `-- make.code.defn \end{alltt} } \frame[containsverbatim]{ \frametitle{WaveToy Thorn} \begin{itemize} \item \verb|interface.ccl|: \tiny\begin{verbatim} IMPLEMENTS: wavetoy_simple INHERITS: grid PUBLIC: CCTK_REAL scalarevolve TYPE=gf TIMELEVELS=3 { phi } "The evolved scalar field" CCTK_INT FUNCTION Boundary_SelectVarForBC( \ CCTK_POINTER_TO_CONST IN GH, CCTK_INT IN faces, \ CCTK_INT IN boundary_width, CCTK_INT IN table_handle, \ CCTK_STRING IN var_name, CCTK_STRING IN bc_name) REQUIRES FUNCTION Boundary_SelectVarForBC\end{verbatim} \end{itemize} } \frame[containsverbatim]{ \frametitle{WaveToy Thorn cont.} \begin{itemize} \item \verb|schedule.ccl|: \tiny\begin{verbatim} STORAGE: scalarevolve[3] SCHEDULE WaveToy_InitialData AT CCTK_INITIAL { LANG: C } "Initial data for 3D wave equation" SCHEDULE WaveToy_Evolution AT CCTK_EVOL { LANG: C SYNC: scalarevolve } "Evolution of 3D wave equation" SCHEDULE WaveToy_Boundaries AT CCTK_EVOL AFTER WaveToy_Evolution { LANG: C } "Select boundary conditions for the evolved scalar" SCHEDULE GROUP ApplyBCs as WaveToy_ApplyBCs AT CCTK_EVOL AFTER WaveToy_Boundaries { } "Apply boundary conditions"\end{verbatim} \end{itemize} } \frame[containsverbatim]{ \frametitle{WaveToy Thorn cont.} \begin{itemize} \item \verb|param.ccl|: \tiny\begin{verbatim} CCTK_REAL amplitude "The amplitude of the waves" { *:* :: "Anything" } 1.0 CCTK_REAL radius "The radius of the gaussian wave" { 0:* :: "Positive" } 0.0 CCTK_REAL sigma "The sigma for the gaussian wave" { 0:* :: "Positive" } 0.1\end{verbatim} \end{itemize} } \frame[containsverbatim]{ \frametitle{WaveToy Thorn cont.} \begin{itemize} \item Example parameter file: \tiny\begin{verbatim} Cactus::cctk_run_title = "Simple WaveToy" ActiveThorns = "time boundary Carpet CarpetLib CartGrid3D" ActiveThorns = "CoordBase ioutil CarpetIOBasic CarpetIOASCII" ActiveThorns = "CarpetIOHDF5 SymBase wavetoy" cactus::cctk_itlast = 10000 time::dtfac = 0.5 IO::out_dir = $parfile IOBasic::outInfo_every = 1 IOASCII::out1D_every = 1 IOASCII::out1D_vars = "wavetoy_simple::phi" iohdf5::out_every = 10 iohdf5::out_vars = "grid::coordinates{out_every=10000000} wavetoy_simple::phi"\end{verbatim} \end{itemize} } %\frame[containsverbatim]{ \frametitle{WaveToy Thorn} % \begin{enumerate} % \item Define a new variable in \verb|interface.ccl|, and allocate storage % for it in \verb|schedule.ccl|. % \item Schedule the energy calculation in the appropriate time bin, also in % \verb|schedule.ccl|. %\item Code up the energy calculation procedure in a file under the \verb|src/| % subdirectory, and request its compilation in \verb|make.code.defn|. % \end{enumerate} %} %\frame[containsverbatim]{ \frametitle{WaveToy Thorn} % Modified thorn: % \begin{itemize} % \item \href{http://www.cct.lsu.edu/~bentivegna/WaveToyEnergy/interface.ccl}{interface.ccl} % \item \href{http://www.cct.lsu.edu/~bentivegna/WaveToyEnergy/schedule.ccl}{schedule.ccl} % \item \href{http://www.cct.lsu.edu/~bentivegna/WaveToyEnergy/param.ccl}{param.ccl} % \item \href{http://www.cct.lsu.edu/~bentivegna/WaveToyEnergy/src}{src/ directory} % \end{itemize} %} % %\frame[containsverbatim]{ \frametitle{WaveToy Thorn} % Running this example: % \begin{enumerate} % \item Download the thornlist, optionlist and parameter file: % % \small{\url{www.cct.lsu.edu/~bentivegna/ICCS09Demo/wavetoy.th}} % % \small{\url{www.cct.lsu.edu/~bentivegna/ICCS09Demo/wavetoy.op}} % % \small{\url{www.cct.lsu.edu/~bentivegna/ICCS09Demo/wavetoy.par}} % % \item Configure and compile: % % \verb|cd $CACTUS_DIR| % % \verb|make wave-config options=wavetoy.op THORNLIST=wavetoy.th| % % \verb|make wave| % \item Run: % % \verb|./exe/cactus_wave wavetoy.par| % \end{enumerate} %} % %\frame[containsverbatim]{ \frametitle{WaveToy Thorn} % Visualize the results: % \begin{itemize} % \item ASCII output with gnuplot. % \item HDF5 output with VisIt and visitCarpetHDF5. % \includegraphics[height=3cm]{viz1.png} % \quad % \includegraphics[height=3cm]{viz3.png} % \quad % \includegraphics[height=3cm]{viz6.png} % \end{itemize} %}