% vim: set foldmethod=marker foldmarker=<<<,>>>:

\begin{FIframe}{Accelerating GMRES Solves}{} %<<<

  \vspace{0.5em}
  \resizebox{.9\textwidth}{!}{\begin{tikzpicture}%<<<
    % draw horizontal line
    \draw[ultra thick, ->] (0,0) -- (14,0);

    % draw vertical lines
    \foreach \x in {2,4,6,8,10,12}
    \draw[ultra thick] (\x cm,3pt) -- (\x cm,-3pt);

    % draw node
    \draw[ultra thick] ( 4,0) node[below=3pt] {$t_{n-2}$};
    \draw[ultra thick] ( 6,0) node[below=3pt] {$t_{n-1}$};
    \draw[ultra thick] ( 8,0) node[below=3pt] {$t_{n}$};
    \draw[ultra thick] (10,0) node[below=3pt] {$t_{n+1}$};
  \end{tikzpicture}}%>>>

  \vspace{0.5em}
  \begin{itemize}
    \setlength\itemsep{0.5em}
    \item Forward Euler: ~$n\text{-}{th}$~ time step
      \begin{itemize}
        \item solve BIE using GMRES:~~ $A_{y_n} \sigma_{\!n} = b_{y_n}$
        \item advance to $t_{n+1}$:~~~ $y_{n+1} = y_{n} + h\, v(\sigma_{\!n})$
      \end{itemize}
    \only<2->{\item Use ~$\sigma_{\!n-1}$~ as initial guess to GMRES}
    \only<3->{: {\color{red} doesn't work well}}
  \end{itemize}

  \only<4->{
  %\vspace{0.5em}
  \begin{columns}
    \column{0.65\textwidth}
    \begin{itemize}
      \item Re-use Krylov subspace from previous time step?

      \only<5->{
      \begin{itemize}
        \item Krylov subspace: ~~$X \leftarrow [b, ~A b, ~\cdots, ~A^{k\shortminus\!1} b]$

        \item Compute QR decomposition: ~ $QR \leftarrow AX$

        \item Preconditioner: ~ $P \coloneq I - Q Q^{T} + X R^{-1} Q^{T}$

          \vspace{0.5em}
        \item[] \qquad $P \, Ax = x$ \quad for all~~ $x \in span(X)$
        \item[] \qquad ~\, $P \, y = y$  \quad for all~~ $y \perp span(X)$

      \end{itemize}
      }
    \end{itemize}
    \column{0.35\textwidth}
      \centering
      \only<6->{\bf Similar to \\
      subspace deflation}
  \end{columns}}

  % TODO: {Similar idea to subspace deflation}

\end{FIframe} %>>>

\begin{FIframe}{Krylov Preconditioning with SDC}{} %<<<

  \vspace{-1em}
  \resizebox{.9\textwidth}{!}{\begin{tikzpicture}%<<<
    % draw horizontal line
    \draw[ultra thick, ->] (0,0) -- (14,0);

    % draw vertical lines
    \foreach \x in {1.7, 12.3}
    \draw[ultra thick] (\x cm,6pt) -- (\x cm,-6pt);
    \draw[ultra thick] (1.7000 ,0) node[above=5pt] {$a$};
    \draw[ultra thick] (12.3000,0) node[above=5pt] {$b$};

    \foreach \x in {1.9000, 2.6699, 4.5000, 7.0000, 9.5000, 11.3301, 12.1000}
    \draw[ultra thick, blue] (\x cm,3pt) -- (\x cm,-3pt);

    % draw node
    \draw[ultra thick, blue] (1.9000 ,0) node[below=3pt] {$t_1$};
    \draw[ultra thick, blue] (2.6699 ,0) node[below=3pt] {$t_2$};
    \draw[ultra thick, blue] (4.5000 ,0) node[below=3pt] {$t_3$};
    %\draw[ultra thick, blue] (7.0000 ,0) node[below=3pt] {$t_4$};
    %\draw[ultra thick, blue] (9.5000 ,0) node[below=3pt] {$t_5$};
    \draw[ultra thick, blue] (8.5,0) node[below=3pt] {$\cdots$};
    %\draw[ultra thick, blue] (11.3301,0) node[below=3pt] {$t_6$};
    \draw[ultra thick, blue] (12.1000,0) node[below=3pt] {$t_m$};

    \only<2->{%<<<
      \draw[ultra thick, DarkGreen] (1.9000 ,-1) node {$P_1$};
      \draw[ultra thick, DarkGreen] (2.6699 ,-1) node {$P_2$};
      \draw[ultra thick, DarkGreen] (4.5000 ,-1) node {$P_3$};
      \draw[ultra thick, DarkGreen] (8.5000 ,-1) node {$\cdots$};
      \draw[ultra thick, DarkGreen] (12.1000,-1) node {$P_m$};

      \draw[ultra thick, DarkGreen, ->] (2.10 ,-1) -- (2.40 ,-1);
      \draw[ultra thick, DarkGreen, ->] (3.00 ,-1) -- (3.50 ,-1);
      \draw[ultra thick, DarkGreen, ->] (4.86 ,-1) -- (5.40 ,-1);
    }%>>>
    \only<3->{%<<<
      \draw[ultra thick, DarkGreen, ->] (1.9000 ,-1.25) -- (1.9000 ,-1.8);
      \draw[ultra thick, DarkGreen, ->] (2.6699 ,-1.25) -- (2.6699 ,-1.8);
      \draw[ultra thick, DarkGreen, ->] (4.5000 ,-1.25) -- (4.5000 ,-1.8);
      \draw[ultra thick, DarkGreen, ->] (12.100 ,-1.25) -- (12.100 ,-1.8);

      \draw[ultra thick, DarkGreen] (1.9000 ,-2.1) node {~~\,$P^{(1)}_1$};
      \draw[ultra thick, DarkGreen] (2.6699 ,-2.1) node {~~\,$P^{(1)}_2$};
      \draw[ultra thick, DarkGreen] (4.5000 ,-2.1) node {~~\,$P^{(1)}_3$};
      \draw[ultra thick, DarkGreen] (8.5000 ,-2.1) node {$\cdots$};
      \draw[ultra thick, DarkGreen] (12.100 ,-2.1) node {~~\,$P^{(1)}_m$};

      \draw[ultra thick, black, ->] (0.75 ,-0.5) -- (0.75 ,-3.5);
      \draw[ultra thick, black] (0.5,-2) node[rotate=-90] {corrections};
    }%>>>
    \only<4->{%<<<
      \draw[ultra thick, DarkGreen, ->] (1.9000 ,-2.5) -- (1.9000 ,-3.0);
      \draw[ultra thick, DarkGreen, ->] (2.6699 ,-2.5) -- (2.6699 ,-3.0);
      \draw[ultra thick, DarkGreen, ->] (4.5000 ,-2.5) -- (4.5000 ,-3.0);
      \draw[ultra thick, DarkGreen, ->] (12.100 ,-2.5) -- (12.100 ,-3.0);

      \draw[ultra thick, DarkGreen] (1.9000 ,-3.3) node {~~\,$P^{(2)}_1$};
      \draw[ultra thick, DarkGreen] (2.6699 ,-3.3) node {~~\,$P^{(2)}_2$};
      \draw[ultra thick, DarkGreen] (4.5000 ,-3.3) node {~~\,$P^{(2)}_3$};
      \draw[ultra thick, DarkGreen] (8.5000 ,-3.3) node {$\cdots$};
      \draw[ultra thick, DarkGreen] (12.100 ,-3.3) node {~~\,$P^{(2)}_m$};

      %\draw[ultra thick, DarkGreen, ->] (1.9000 ,-3.7) -- (1.9000 ,-4.2);
      %\draw[ultra thick, DarkGreen, ->] (2.6699 ,-3.7) -- (2.6699 ,-4.2);
      %\draw[ultra thick, DarkGreen, ->] (4.5000 ,-3.7) -- (4.5000 ,-4.2);
      %\draw[ultra thick, DarkGreen, ->] (12.100 ,-3.7) -- (12.100 ,-4.2);
    }%>>>

  \end{tikzpicture}}%>>>
  \only<5->{
    \vspace{1.4em}

    \begin{columns}
      \column{0.05\textwidth}
      \column{0.45\textwidth}
        GMRES iter without preconditioner:

        \vspace{0.5em}
        \begin{tabular}{r | r r r r r}
          \parbox[t]{2mm}{\multirow{5}{*}{\rotatebox[origin=c]{-90}{correction $\rightarrow$}}}
            & \multicolumn{5}{c}{sub-step $\rightarrow$}  \\
          \hline
                                  & 66 & 66 & 66 & 66 & 66    \\
                                  & 66 & 66 & 66 & 66 & 66    \\
                                  & 66 & 66 & 66 & 66 & 66    \\
                                  & 66 & 66 & 66 & 66 & 66    \\
        \end{tabular}

      \column{0.05\textwidth}
      \column{0.44\textwidth}
        \only<6->{
        GMRES iter with preconditioner:

        \vspace{0.5em}
        \begin{tabular}{r | r r r r r}
          \parbox[t]{2mm}{\multirow{5}{*}{\rotatebox[origin=c]{-90}{correction $\rightarrow$}}}
            & \multicolumn{5}{c}{sub-step $\rightarrow$}  \\
          \hline
                                  & 66 & 30 & 22 & 45 & 30    \\
                                  & 35 & 17 & 33 & 28 & 24    \\
                                  &  8 &  4 & 14 &  5 & 12    \\
                                  &  1 &  1 &  2 &  2 &  4    \\
        \end{tabular}}

    \end{columns}
  }

\end{FIframe} %>>>

\begin{FIframe}{Numerical Results}{} %<<< disc-chain

  \centering
  {\bf Average iterations per GMRES solve: 30 \quad (130 without Krylov preconditioner)}

  \embedvideo{\includegraphics[width=0.985\textwidth]{videos/chain32}}{videos/chain32.avi}

  {\bf 32 discs (36K unknowns)}, \hfill {\bf minimum distance: 1e-4}, \hfill {\bf 10-th order SDC}

  \vspace{1em}
  {\bf 7-digits accuracy} in quadratures, GMRES solve, and time-stepping.

\end{FIframe} %>>>

\begin{FIframe}{Numerical Results - Sedimentation Flow}{} %<<<

  \vspace{-1.75em}
  \begin{columns}
    \column{0.42\textwidth}

      {\bf 200K unknowns}\\
      127 discs.

      \vspace{1em}
      {\bf Minimum distance: 1e-4}

      \vspace{1em}
      {\bf 10-th order adaptive SDC}

      \vspace{1em}
      {\bf 5-digits accuracy} in quadratures, GMRES solve, and time-stepping.

    \column{0.583\textwidth}
      \embedvideo{\includegraphics[width=0.99\textwidth]{videos/sed127_2}}{videos/sed127__.mp4}
  \end{columns}

\end{FIframe} %>>>

%\begin{FIframe}{High Order vs Low Order Time Stepping}{} %<<<
%  TODO: compare high order vs low order
%  TODO: explain Krylov preconditioner
%\end{FIframe} %>>>

