Basilisk Tutorial
Basilisk Tutorial
Basilisk Tutorial
Step 3: Pulling new changes in Basilisk (just to ensure, more useful while updating)
$ cd basilisk
$ darcs pull
$ cd $BASILISK/gl
$ cd $BASILISK
$ make bview-servers
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
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
$ ./run_plate
$ sh run0.sh plate
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);
bid circle;
u.t[circle] = dirichlet(0);