samurai documentation

samurai stands for Structured Adaptive mesh and MUlti-Resolution based on Algebra of Intervals. It is a header-only C++ library that stores adaptive Cartesian meshes as sets of intervals and adapts them with multiresolution or adaptive mesh refinement (AMR). Plate 1 (The adaptive mesh and its intervals) shows such a mesh and the intervals that store one of its rows.

The adaptive mesh and its intervalsPlate 1
01/211aabcdFig. 1.level 2side 1/4level 3side 1/8level 4side 1/16level 5side 1/32level 6side 1/64Fig. 2.level 2no cell of this level in the rowlevel 3[3, 4)[7, 8)level 4[0, 2)[4, 6)[8, 11)[13, 14)level 5[4, 5)[6, 8)[22, 24)[25, 26)level 6[10, 12)[48, 50)Fig. 3. Section a-a

Explanation of Plate 1

Fig. 1. The unit square, meshed between level 2 and level 6: a cell of level \(\ell\) has the side \(1/2^\ell\). The mesh is refined where a circle crosses it. b, the cells of the finest level, hatched in red, follow the circle. c, away from the circle the cells coarsen one level at a time, down to level 3. Two touching cells never differ by more than one level: the mesh is graded. To keep it so, the grading splits every cell of level 2, and none is left. d, inside the disc, ruled in fine lines, the cells are coarse again.

Fig. 2. One cell of each level, at the scale of Fig. 1: each level halves the side of the level before.

Fig. 3. Section a-a: the cells that the row a-a of Fig. 1 crosses, level by level. Each level stores them as half-open intervals of indices, counted in cells of that level: \([10, 12)\) and \([48, 50)\) at level 6, \([4, 5)\), \([6, 8)\), \([22, 24)\) and \([25, 26)\) at level 5, \([0, 2)\), \([4, 6)\), \([8, 11)\) and \([13, 14)\) at level 4, \([3, 4)\) and \([7, 8)\) at level 3. Level 2 has no cell in this row. Together the levels cover the row exactly once.

Start here

Learn and use samurai

  • Tutorials: how samurai works inside: intervals, fields, set algebra and graduation.

  • How-to guides: steps for one task, such as installing samurai, adapting a mesh or saving a field.

  • Philosophy of samurai: why samurai is built on intervals and set algebra, and what this design costs.

  • Reference: the full description of boundary conditions, set algebra, schemes and load balancing.

  • API reference: the C++ classes and functions, generated from the headers.

Examples and applications

  • Lattice Boltzmann: lattice Boltzmann schemes on multiresolution meshes, with the test cases that validate them.

  • Demos: the complete programs of the repository, grouped by method (finite volume, lattice Boltzmann, multigrid, MPI), with the command that builds and runs each one.

  • samurai gallery: complete simulations, with videos of the solution and the mesh, to start from.

Contributing

  • Contributing guide: how to report a bug, set up a development environment and propose a change.