0% found this document useful (1 vote)
772 views12 pages

Basilisk Tutorial

Download as pdf or txt
Download as pdf or txt
Download as pdf or txt
You are on page 1/ 12

Basilisk

is the latin name of the extraordinary Jesus Christ lizard, famous


for its ability to run on the surface of water, a characteristic it
shares with another well-known water-walker Gerris lacustris.
Installation (Basilisk)
Step 0:
$ sudo apt-get upd1ate
$ sudo apt-get upgrade
$ sudo apt-get dist-upgrade

Step 1: Installing darcs


$ sudo apt-get install darcs flex make

Step 2: Getting Basilisk source code


$ darcs get http://basilisk.fr/basilisk

Step 3: Pulling new changes in Basilisk (just to ensure, more useful while updating)
$ cd basilisk
$ darcs pull

Step 4: Compilation (or recompilation, after pulling new changes in Basilisk)


$ cd basilisk/src
$ export BASILISK=$PWD
$ export PATH=$PATH:$PWD
$ echo "export BASILISK=$PWD" >> ~/.bashrc
$ echo "export PATH=\$PATH:$BASILISK" >> ~/.bashrc
$ ln -s config.gcc config
$ make -k
$ make
Installation (Bview)
$ sudo apt-get install libglu1-mesa-dev libglew-dev libgl1-mesa-dev libosmesa6-dev

$ cd $BASILISK/gl

$ make libglutils.a libfb_glx.a libfb_osmesa.a

$ sudo apt-get install python-pil.imagetk

$ cd $BASILISK

$ make bview-servers

Installation (Side packages)


$ sudo apt-get install gnuplot imagemagick libav-tools smpeg-plaympeg graphviz
valgrind gifsicle
Gerris
Strong points:
• Adaptivity, precision, surface tension, flexibility
• Balance simplicity – power of user interface (parameter file)
• Integration with auxilliary tools (UNIX) : scripts, GfsView, post-processing
etc...

Weak points:
• Performance on a pure Cartesian mesh
• Barrier “expert user” – “beginner programmer” too high: the code is too
complex
• Code complexity of the ‘auxilliary language’ (compilation of GfsFunction, C-
object orientation etc...)
• Accumulation of historic workarounds
Basilisk
• Principal objectives: Precision – Simplicity – Performance
◦ Precision: identical to Gerris
◦ Code simplicity: − Implementation: complexity comparable (or less than) that
of a (simple) pure cartesian code, minimal use of complex
programming (object orientation etc...)
− Algorithms: simplified compared to Gerris, elimination of
historical workarounds
− No barrier ‘expert user – beginner programmer”:
the code is the user interface
− Portability: only one strict dependency: ISO C99
compiler/library, no auxilliary librairies (glib etc...)
◦ Performance: identical to that of a pure Cartesian code (i.e. >×10 Gerris),
much better than Gerris (>×4) in adaptive mode
• Scientific objective: real estimation of performance gain of quad/octree adaptive
methods compared to an optimised pure Cartesian code
• Basic simlplicity allows for more complex numerical schemes
Key points

Some reserved words (N, L0, X0, Y0, Z0, rho1, mu 1, f.sigma … )

Automatic grid setting

New types (scalar, ) with automatic memory allocation

Function run()

Boundary conditions

Position in the grid : A[1,0], A[-1,0], A[]

New “iterators” like foreach() (replacing “for ( …)”

New method “events” managing code actions
Example 1: Flow over a flat plate
Including solvers (header files)
#include "navier-stokes/centered.h"
#include "tracer.h" //to trace certain portion within a fluid
#include "view.h" //for visualization

Defining custom fields and variables


scalar f[];
scalar * tracers = {f};
#define U 0.1 //defined using macros
Bounday conditions
u.n[left] = dirichlet(U); //inflow velocity
p[left] = neumann(0.);
pf[left] = neumann(0.);
f[left] = dirichlet(1); //tracer entry from left wall

u.t[bottom] = dirichlet(0.); //no slip condition

u.n[right] = neumann(0.);
p[right] = dirichlet(0.);
pf[right] = dirichlet(0.);
Example 1: Flow over a flat plate
Initial condition
event init (t = 0) {
foreach()
u.x[] = 1.; //initially fluid is moving at u=1
}
int main () function, where we set domain size, origin, properties and give run() command
int main() {
L0 = 8.; //square box of 8 unit
origin (0, -L0/2.); //location of left-bottom point in
new coordinate system
N = 512; //number of cells in domain at the begining of
simulation
const face vector muc[] = {0.78125,0.78125}; //viscocity
mu = muc; //passing property to the system variable
run(); //command to run simulation
}
Adapation
event adapt (i++) {
adapt_wavelet ({u,f},(double[]){3.*U/100.,3.*U/100.,3e-2},9,4);
}
Example 1: Flow over a flat plate
Running from terminal
Method 1
Step 1: Create an new folder with the name “shots” at same location where your .c code is

Step 2: Compile the code with following commnd in the terminal


$ qcc -Wall -O2 plate.c -o run_plate -L$BASILISK/gl -lfb_osmesa \
-lOSMesa -lglutils -lGLU -lfb_glx -lGLEW -lGL -lX11 -lm
Step 3: Executr “run_plate” file with following command in the terminal

$ ./run_plate

Method 2 (using shell script)


Step 1: run shell script with following command in the terminal

$ sh run0.sh plate

Step 2: Executr “run_plate” file with following command in the terminal


$ ./run_plate
Example 2: drop impact on
a liquid surface
#include "navier-stokes/centered.h"
#include "two-phase.h"
#include "tension.h"
#include "reduced.h"
#include "view.h"

int maxlevel = 9;

event init(t=0){
CFL = 0.3;
// refine (sq(x) + sq(y) < 1.1 && level < maxlevel);
fraction(f, sq(1.) - sq(x) - sq (y - 9));//The drop
scalar m[];
fraction(m, -y+5);// and the pool
foreach()
f[] += m[];
DT = 0.05;
}
Example 2: drop impact on
a liquid surface
int main(){
L0 = 20;
X0 = -L0/2;
Y0 = -2;
f.sigma = 10.;
mu1 = .5;
mu2 = .5;
rho1 = 50.;
rho2 = 1.;
G.y = -5.;
init_grid(64); //equivalent to N=64
run();
}

event adapt(i++){
scalar KAPPA[];
curvature(f,KAPPA);
adapt_wavelet((scalar*){f,KAPPA,u},
(double[]){0.001, 0.0001, 0.01, 0.01}, maxlevel);
}
bid (Boundary Internal Domain)

to turn the domain into a rectangle with the variable y between 0 and 0.5
mask (y > 0.5 ? top : none);

mask (y > 0.5 ? top : none);

More complex boundary conditions can be done using the Boundary


Internal Domain (or bid) by defining

bid circle;

where circle is a user-defined identifier. For example for a no-slip


boundary condition for a vector field u could be defined using

u.t[circle] = dirichlet(0);

mask (sq(x - 0.5) + sq(y - 0.5) < sq(0.5) ? circle : none);

You might also like