software.tex 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411
  1. % vim: set foldmethod=marker foldmarker=<<<,>>>:
  2. \section{Software} %<<<
  3. \begin{frame}[t,fragile] \frametitle{{CSBQ library}} \framesubtitle{{}} %<<<
  4. \vspace{0.5em}
  5. {\bf Code:} ~~ {\color{blue} \url{https://github.com/dmalhotra/CSBQ}}
  6. (remember to checkout submodule SCTL)
  7. %\vspace{0.5em}
  8. %{\bf Documentation:} ~~ {\color{blue} \url{https://csbq.readthedocs.io/}}
  9. \vspace{1.5em}
  10. {\bf Requirements:} ~~ {\color{red}C++11} ~compiler ~with ~{\color{red}OpenMP}
  11. \vspace{1.5em}
  12. {\bf Build system:} ~~ none (header only)
  13. \vspace{0.5em}
  14. {\bf
  15. \begin{minted}[
  16. %frame=lines,
  17. fontsize=\small,
  18. %linenos,
  19. gobble=0,
  20. mathescape
  21. ]{C++}
  22. #include <csbq.hpp>
  23. \end{minted}
  24. }
  25. \only<2->{
  26. \vspace{4em}
  27. {\bf Optional dependencies:} ~~ BLAS, ~~LAPACK, ~~FFTW, ~~MPI, ~~and ~~PVFMM}
  28. %\begin{itemize}
  29. %\item includes simple `Makefile' for example codes.
  30. %\end{itemize}
  31. \end{frame}
  32. %>>>
  33. \begin{FIframe}{Library overview}{} %<<<
  34. \resizebox{0.91\linewidth}{!}{\begin{tikzpicture}
  35. \node[anchor=north west, draw=none, rounded corners=.45cm, minimum height=8.3cm, minimum width=13.5cm] at (0.65,2) {};
  36. \only<4->{
  37. \node[anchor=north west, draw=DarkGreen,thick, rounded corners=.45cm, scale=1.7] at (4.7,1.9) {\begin{tabular}{c} \bf Applications \end{tabular}};
  38. \draw [line width=1mm] (0.8,0.20) -- (14.0,0.20);
  39. }
  40. \only<3->{
  41. \draw [->,line width=0.6mm] (2.7,-1.79) -- (2.7,-3.2);
  42. }
  43. \only<2->{
  44. \node[anchor=north west, draw=black,thick, rounded corners=.55cm] at (1,-0.2) {
  45. \begin{tabular}{c}
  46. {\bf CSBQ:} Convergent Slender Body Quadrature\\
  47. \hspace{12cm} \vspace{0.5cm}
  48. \end{tabular}};
  49. \node[anchor=north west, draw=blue,thick, rounded corners=.45cm] at (1.25,-1.0) {\begin{tabular}{c} \bf SlenderElemL \end{tabular}};
  50. \node[anchor=north west, draw=blue,thick, rounded corners=.45cm] at (4.50,-1.0) {\begin{tabular}{c} \bf RigidBodyL, Mobility \end{tabular}};
  51. \node[anchor=north west, draw=blue,thick, rounded corners=.45cm] at (9.00,-1.0) {\begin{tabular}{c} \bf CubeVolumeVis, Utils \end{tabular}};
  52. %\node[anchor=north west, draw=blue,thick, rounded corners=.45cm] at (12.20,-1.0) {\begin{tabular}{c} \bf Utils \end{tabular}};
  53. }
  54. \node[anchor=north west, draw=black,thick, rounded corners=.55cm] at (1,-2.4) {
  55. \begin{tabular}{c}
  56. {\bf SCTL:} Scientific Computing Template Library\\
  57. \hspace{12cm} \vspace{2.39cm}
  58. \end{tabular}};
  59. \node[anchor=north west, draw=red,thick, rounded corners=.45cm] at (1.50,-3.2) {\begin{tabular}{c} \bf BoundaryIntegralOp \end{tabular}};
  60. \node[anchor=north west, draw=red,thick, rounded corners=.45cm] at (6.15,-3.2) {\begin{tabular}{c} \bf Kernel \end{tabular}};
  61. \node[anchor=north west, draw=red,thick, rounded corners=.45cm] at (8.60,-3.2) {\begin{tabular}{c} \bf FMM \end{tabular}};
  62. \node[anchor=north west, draw=red,thick, rounded corners=.45cm] at (10.50,-3.2) {\begin{tabular}{c} \bf Quadrature \end{tabular}};
  63. \node[anchor=north west, draw=red,thick, rounded corners=.45cm] at (1.50,-4.2) {\begin{tabular}{c} \bf GMRES \end{tabular}};
  64. \node[anchor=north west, draw=red,thick, rounded corners=.45cm] at (3.95,-4.2) {\begin{tabular}{c} \bf SDC \end{tabular}};
  65. \node[anchor=north west, draw=red,thick, rounded corners=.45cm] at (5.90,-4.2) {\begin{tabular}{c} \bf Profile \end{tabular}};
  66. \node[anchor=north west, draw=red,thick, rounded corners=.45cm] at (8.15,-4.2) {\begin{tabular}{c} \bf Vec (SIMD) \end{tabular}};
  67. \node[anchor=north west, draw=red,thick, rounded corners=.45cm] at (11.30,-4.2) {\begin{tabular}{c} \bf Comm \end{tabular}};
  68. \node[anchor=north west, draw=red,thick, rounded corners=.45cm] at (1.50,-5.2) {\begin{tabular}{c} \bf Vector \end{tabular}};
  69. \node[anchor=north west, draw=red,thick, rounded corners=.45cm] at (3.70,-5.2) {\begin{tabular}{c} \bf Matrix \end{tabular}};
  70. \node[anchor=north west, draw=red,thick, rounded corners=.45cm] at (5.90,-5.2) {\begin{tabular}{c} \bf VTUData \end{tabular}};
  71. \node[anchor=north west, draw=red,thick, rounded corners=.45cm] at (8.40,-5.2) {\begin{tabular}{c} \bf Interpolation \end{tabular}};
  72. \node[anchor=north west, draw=red,thick, rounded corners=.45cm] at (11.70,-5.2) {\begin{tabular}{c} \bf Tree \end{tabular}};
  73. \end{tikzpicture}}
  74. \end{FIframe}%>>>
  75. \begin{FIframe}{Solving BIEs with CSBQ}{} %<<<
  76. \vspace{-1em}
  77. {\bf Step 1: Stokes Dirichlet boundary value problem (exterior)}
  78. \vspace{-0.5em}
  79. \begin{columns}[t]
  80. \column{0.5\textwidth}
  81. \begin{itemize}
  82. \item Stokes equations:
  83. \vspace{-0.5em}
  84. \begin{align*}
  85. \Delta \mathbf{u} - \nabla p &= 0 \qquad ~\mbox{ in } \mathbb{R}^3 \setminus \overline{\Omega}, \\
  86. \nabla \cdot \mathbf{u} &= 0 \qquad ~\mbox{ in } \mathbb{R}^3 \setminus \overline{\Omega}, \\
  87. \end{align*}
  88. \vspace{-2.5em}
  89. \item Boundary conditions:
  90. \vspace{-0.8em}
  91. \begin{align*}
  92. \mathbf{u}|_{\Gamma} &= \mathbf{u}_0 \qquad \mbox{ on } \Gamma, \\
  93. \mathbf{u}(\mathbf{x}) &\rightarrow \mathbf{0} \qquad \mbox{ as } |\mathbf{x}| \rightarrow \infty \\
  94. \end{align*}
  95. \end{itemize}
  96. \column{0.5\textwidth}
  97. \centering
  98. \vspace{2em}
  99. \resizebox{0.75\linewidth}{!}{\begin{tikzpicture}
  100. % Draw the irregular domain Omega
  101. \draw[fill=blue!20] plot [smooth cycle] coordinates {(1,0) (1.5,1) (2,1.5) (3,1) (3.5,0.5) (2.5,0)};
  102. \node at (2,1) {\(\Omega\)};
  103. % Draw the boundary Gamma
  104. \draw[line width=1.5pt] plot [smooth cycle] coordinates {(1,0) (1.5,1) (2,1.5) (3,1) (3.5,0.5) (2.5,0)};
  105. \node at (2.0,-0.3) {\(\Gamma = \partial\Omega \)};
  106. \node at (4.5,1.8) {\( \mathbb{R}^3 \setminus \overline{\Omega} \)};
  107. \end{tikzpicture}}
  108. \end{columns}
  109. \end{FIframe}%>>>
  110. \begin{FIframe}{Solving BIEs with CSBQ}{} %<<<
  111. \vspace{-1em}
  112. {\bf Step 2: Integral Equation Formulation}
  113. \vspace{-0.5em}
  114. \begin{columns}[t]
  115. \column{0.5\textwidth}
  116. \begin{itemize}
  117. \item Boundary integral representation:
  118. \vspace{-0.5em}
  119. \begin{align*}
  120. \mathbf{u} = \mathcal{D}[\mathbf{\sigma}] + \eta \, \mathcal{S}[\mathbf{\sigma}] \quad \mbox{ in } \mathbb{R}^3 \setminus \overline{\Omega},
  121. \end{align*}
  122. \vspace{-0.8em}
  123. \item[] where\\
  124. {\small
  125. \qquad $\displaystyle\mathcal{S}[\mathbf{\sigma}](\mathbf{x}) \coloneq \int_{\Gamma} S(\mathbf{x} - \mathbf{y}) \, \mathbf{\sigma}(\mathbf{y}) \, dS_{\mathbf{y}}$,
  126. \qquad $\displaystyle\mathcal{D}[\mathbf{\sigma}](\mathbf{x}) \coloneq \int_{\Gamma} D(\mathbf{x} - \mathbf{y}) \, \mathbf{\sigma}(\mathbf{y}) \, dS_{\mathbf{y}}$,
  127. \qquad $\displaystyle\eta = 1/(\epsilon \log \epsilon^{-1})$
  128. }
  129. \vspace{0.9em}
  130. \item Enforce boundary conditions:
  131. \vspace{-0.5em}
  132. \begin{align*}
  133. (I/2 + D + \eta \, S) \mathbf{\sigma} = \mathbf{u}_0 \quad \mbox{ on } \Gamma,
  134. \end{align*}
  135. \vspace{-1.0em}
  136. \item[] Solve for unknown { \color{red} $\sigma$ }
  137. \end{itemize}
  138. \column{0.5\textwidth}
  139. \centering
  140. \vspace{2em}
  141. \resizebox{0.75\linewidth}{!}{\begin{tikzpicture}
  142. % Draw the irregular domain Omega
  143. \draw[fill=blue!20] plot [smooth cycle] coordinates {(1,0) (1.5,1) (2,1.5) (3,1) (3.5,0.5) (2.5,0)};
  144. \node at (2,1) {\(\Omega\)};
  145. % Draw the boundary Gamma
  146. \draw[line width=1.5pt] plot [smooth cycle] coordinates {(1,0) (1.5,1) (2,1.5) (3,1) (3.5,0.5) (2.5,0)};
  147. \node at (2.0,-0.3) {\(\Gamma = \partial\Omega \)};
  148. \node at (4.5,1.8) {\( \mathbb{R}^3 \setminus \overline{\Omega} \)};
  149. \end{tikzpicture}}
  150. \end{columns}
  151. \end{FIframe}%>>>
  152. \begin{frame}[t,fragile] \frametitle{{Solving BIEs with CSBQ}} \framesubtitle{{}} %<<<
  153. \vspace{-1em}
  154. {\bf Step 3: Discretize the geometry}
  155. \vspace{-0.5em}
  156. \begin{columns}[t]
  157. \column{0.7\textwidth}
  158. \only<2->{
  159. \begin{itemize}
  160. \item Geometry described by centerline {\color{red} $\gamma$}.
  161. \only<3->{\item Partition into panels.\\
  162. \begin{itemize}
  163. \item Choose panel order and Fourier order.
  164. \end{itemize}
  165. }
  166. \only<4->{\item Determine nodes {\color{blue} $\mathbf{x}_c$} and radius {\color{blue} $\epsilon$}.}
  167. \end{itemize}
  168. }
  169. \vspace{1em}
  170. \only<5>{~~ Code:}
  171. \begin{overprint}
  172. \onslide<5>%<<<
  173. \bf
  174. \begin{minted}[
  175. %frame=lines,
  176. fontsize=\footnotesize,
  177. %linenos,
  178. gobble=5,
  179. ]{C++}
  180. Vector<Long> ElemOrder, FourierOrder;
  181. Vector<double> Xc, eps;
  182. // set vector data ...
  183. SlenderElemList<double> elem_lst(ElemOrder,
  184. FourierOrder, Xc, eps);
  185. \end{minted}
  186. %>>>
  187. \end{overprint}
  188. \column{0.4\textwidth}
  189. \only<1>{\includegraphics[width=0.99\textwidth]{figs/geom1}}
  190. \only<2>{\resizebox{0.99\linewidth}{!}{\begin{tikzpicture}
  191. \node[inner sep=0pt] at (0,0) {\includegraphics[width=5cm]{figs/geom2}};
  192. \node at (1,0) {\color{red} \( \gamma \)};
  193. \end{tikzpicture}}}
  194. \only<3>{\resizebox{0.99\linewidth}{!}{\begin{tikzpicture}
  195. \node[inner sep=0pt] at (0,0) {\includegraphics[width=5cm]{figs/geom3_}};
  196. \node at (1.3,0) {\color{red} \( \gamma_k \)};
  197. \end{tikzpicture}}}
  198. \only<4->{\resizebox{0.99\linewidth}{!}{\begin{tikzpicture}
  199. \node[inner sep=0pt] at (0,0) {\includegraphics[width=5cm]{figs/geom4}};
  200. \node at (1.3,0) {\color{red} \( \gamma_k \)};
  201. \node at (1.4,1.2) {\color{blue} \( \mathbf{x}_c, \epsilon \)};
  202. \end{tikzpicture}}}
  203. \end{columns}
  204. \end{frame}
  205. %>>>
  206. \begin{frame}[t,fragile] \frametitle{{Solving BIEs with CSBQ}} \framesubtitle{{}} %<<<
  207. \vspace{-1em}
  208. {\bf Step 4: Discretize Integral Operator}
  209. \begin{itemize}
  210. \item {Stokes combined field kernel:}
  211. \end{itemize}
  212. {\bf
  213. \begin{minted}[
  214. %frame=lines,
  215. fontsize=\scriptsize,
  216. %linenos,
  217. gobble=3,
  218. ]{C++}
  219. struct Stokes3D_CF_ {
  220. template <Integer digits, class VecType>
  221. static void uKerMatrix(VecType (&u)[3][3], const VecType (&r)[3],
  222. const VecType (&n)[3], const void* ctx_ptr) {
  223. // u[i][j] = [Stokes-SL] + [Stokes-DL];
  224. }
  225. // other member functions ...
  226. };
  227. \end{minted}
  228. }
  229. %using Stokes3D_CF = GenericKernel<Stokes3D_CF_>;
  230. \vspace{-1.7em}
  231. \begin{overprint}
  232. \onslide<2>
  233. \begin{columns}
  234. \column{0.78\textwidth}
  235. \vspace{1em}
  236. \begin{itemize}
  237. \item {Boundary integral operator:}
  238. \end{itemize}
  239. {\bf
  240. \begin{minted}[
  241. %frame=lines,
  242. fontsize=\scriptsize,
  243. %linenos,
  244. gobble=3,
  245. ]{C++}
  246. Stokes3D_CF ker;
  247. BoundaryIntegralOp<double,Stokes3D_CF> LayerPotenOp(ker);
  248. LayerPotenOp.AddElemList(elem_lst); // add geometry to operator
  249. LayerPotenOp.SetAccuracy(tol); // set accuracy
  250. const auto BIO = [&LayerPotenOp](Vector<double>* U,
  251. const Vector<double>& sigma) {
  252. LayerPotenOp.ComputePotential(*U, sigma);
  253. (*U) += sigma * 0.5;
  254. };
  255. \end{minted}
  256. }
  257. \column{0.23\textwidth}
  258. \small
  259. \vspace{2em}
  260. $\displaystyle {\mathbf u}({\mathbf x}) = (\mathcal{D} + \mathcal{S})[\sigma]({\mathbf{x}})$
  261. %\quad\qquad for ~~ ${\mathbf x} \in \mathbb{R}^3 \setminus \overline \Omega$
  262. \[ K \, \sigma \coloneq (I/2 + D + S) \, \sigma \]
  263. \end{columns}
  264. \end{overprint}
  265. \end{frame}
  266. %>>>
  267. \begin{frame}[t,fragile] \frametitle{{Solving BIEs with CSBQ}} \framesubtitle{{}} %<<<
  268. \vspace{-1em}
  269. {\bf Step 5: Solve Integral Equation}
  270. \vspace{1em}
  271. {\bf
  272. \begin{minted}[
  273. %frame=lines,
  274. fontsize=\footnotesize,
  275. %linenos,
  276. gobble=4,
  277. ]{C++}
  278. Vector<double> sigma, U0(LayerPotenOp.Dim(0));
  279. // set boundary condition U0
  280. GMRES<double> solver;
  281. solver(&sigma, BIO, U0, tol);
  282. \end{minted}
  283. }
  284. \end{frame}
  285. %>>>
  286. \begin{frame}[t,fragile] \frametitle{{Solving BIEs with CSBQ}} \framesubtitle{{}} %<<<
  287. \vspace{-1em}
  288. {\bf Step 6: Post-process}
  289. \vspace{1em}
  290. {\bf
  291. \begin{minted}[
  292. %frame=lines,
  293. fontsize=\footnotesize,
  294. %linenos,
  295. gobble=4,
  296. ]{C++}
  297. Vector<double> U;
  298. LayerPotenOp.SetTargetCoord(Xtrg); // Set targets for LayerPotenOp
  299. LayerPotenOp.ComputePotential(U, sigma); // Evaluate solution
  300. //... Write to VTK file
  301. \end{minted}
  302. }
  303. %CubeVolumeVis<double> cube(50, 2.0); // 50x50x50 grid, side length 2
  304. %LayerPotenOp.SetTargetCoord(cube.GetCoord()); // Set targets for LayerPotenOp
  305. %Vector<double> U;
  306. %LayerPotenOp.ComputePotential(U, sigma); // Evaluate solution
  307. %cube.WriteVTK("vis/bie-solution", U); // Write to VTK file
  308. \vspace{1em}
  309. \only<2->{
  310. \centering
  311. \includegraphics[width=0.75\textwidth]{figs/stokes-dirichlet}
  312. }
  313. \end{frame}
  314. %>>>
  315. %>>>