summaryrefslogtreecommitdiff
path: root/lbm.org
diff options
context:
space:
mode:
authorAdrian Kummerlaender2021-07-03 17:21:10 +0200
committerAdrian Kummerlaender2021-07-03 17:21:10 +0200
commit4892b69b3b94652489591c568908369ec205a6a6 (patch)
treef4fca91de20437ded9c9c6bc111a9e0c79764a9c /lbm.org
parent1eb15a532461a3546c84da072aba13a5182da460 (diff)
downloadLiterateLB-4892b69b3b94652489591c568908369ec205a6a6.tar
LiterateLB-4892b69b3b94652489591c568908369ec205a6a6.tar.gz
LiterateLB-4892b69b3b94652489591c568908369ec205a6a6.tar.bz2
LiterateLB-4892b69b3b94652489591c568908369ec205a6a6.tar.lz
LiterateLB-4892b69b3b94652489591c568908369ec205a6a6.tar.xz
LiterateLB-4892b69b3b94652489591c568908369ec205a6a6.tar.zst
LiterateLB-4892b69b3b94652489591c568908369ec205a6a6.zip
Add Magnus video
Diffstat (limited to 'lbm.org')
-rw-r--r--lbm.org26
1 files changed, 19 insertions, 7 deletions
diff --git a/lbm.org b/lbm.org
index dcd20ab..95fb004 100644
--- a/lbm.org
+++ b/lbm.org
@@ -5257,7 +5257,7 @@ After setting up the lattice we define the relaxation time for the BGK collision
bulk and the desired rotation and inflow velocities.
#+BEGIN_SRC cpp :tangle tangle/magnus.cu
-const float tau = 0.54;
+const float tau = 0.52;
const float u_inflow = 0.02;
const float u_rotate = 0.08;
#+END_SRC
@@ -5363,7 +5363,9 @@ renderSliceViewToTexture<<<
dim3(cuboid.nX / 32 + 1, cuboid.nY / 32 + 1),
dim3(32,32)
>>>(cuboid.nX, cuboid.nY,
- slice,
+ [cuboid] __device__ (int iX, int iY) -> std::size_t {
+ return descriptor::gid(cuboid,iX,cuboid.nY-1-iY);
+ },
[u,u_rotate] __device__ (std::size_t gid) -> float {
return length(make_float2(u[2*gid+0], u[2*gid+1])) / u_rotate;
},
@@ -5373,21 +5375,27 @@ renderSliceViewToTexture<<<
window.getRenderSurface());
#+END_SRC
+The render target is provided by our =RenderWindow= class. We also need
+variables for storing the colormap and buffers for storing the computed
+moments.
+
#+BEGIN_SRC cpp :tangle tangle/magnus.cu
RenderWindow window("Magnus");
cudaSurfaceObject_t colormap;
ColorPalette palette(colormap);
-auto slice = [cuboid] __device__ (int iX, int iY) -> std::size_t {
- return descriptor::gid(cuboid,iX,cuboid.nY-1-iY);
- };
DeviceBuffer<T> moments_rho(cuboid.volume);
DeviceBuffer<T> moments_u(2*cuboid.volume);
T* u = moments_u.device();
-std::size_t iStep = 0;
+#+END_SRC
+Finally we run the simulation as long as the window is open
+while periodically calling the visualization code.
+
+#+BEGIN_SRC cpp :tangle tangle/magnus.cu
+std::size_t iStep = 0;
while (window.isOpen()) {
<<magnus-simulation-step>>
- if (iStep % 100 == 0) {
+ if (iStep % 200 == 0) {
cudaDeviceSynchronize();
<<magnus-visualization-step>>
window.draw([&]() {
@@ -5401,6 +5409,10 @@ while (window.isOpen()) {
}
#+END_SRC
+#+BEGIN_EXPORT html
+<video style="width:100%" src="https://literatelb.org/media/magnus.webm" playsinline muted controls loop/>
+#+END_EXPORT
+
** Flow around a Sphere
This example models a channel flow around a spherical obstacle.