sandbox/Antoonvh/internalwacesAMR.c
Internal waves using an adaptive grid
Similar to the succesful simulation using the multigrid we now want to use adaptive mesh refinement for the simulation of internal waves.
Numerical set-up
The set-up is very similar to the multigrid simulation. This run is altered so that it uses an adaptive quadtree grid.
#include "navier-stokes/centered.h"
#include "tracer.h"
#include "view.h" //For cells()
#include "navier-stokes/perfs.h"
scalar b[], * tracers = {b};
face vector av[];
double sqN = 1, omega;
[top] = neumann (sqN);
b[bottom] = neumann (-sqN);
b
int main() {
= sqrt(1./2.);
omega = av;
a = 30;
L0 = Y0 = -L0/2;
X0 = 1e-4;
TOLERANCE = 0.2/omega;
DT .prolongation = p.refine = refine_linear; //3rd-order interpolation (vertical)
p= 256;
N run();
}
event init (t = 0) {
foreach()
[] = sqN*y;
bboundary ({b});
}
event acceleration (i++) {
= {0, 1};
coord del foreach_face()
.x[] = del.x*((b[] + b[-1])/2 +
av0.1*(sin(omega*t)*((sq(x) + sq(y)) < 1)));
}
event output (t += 0.5; t <= 75) {
scalar grb[];
foreach() {
[] = 0;
grbforeach_dimension()
[] += sq((b[1] - b[-1])/(2*Delta));
grb[] = sqrt(grb[]);
grb}
boundary ({grb});
squares ("grb", linear = true);
cells();
save ("mov.mp4");
}
Adaptivity
Inspired by the equations of motion, we decide to refine upon the discrete representation for the byoyancy and velocity-component fields.
event adapt (i++)
({b, u}, (double[]){0.01, 0.01, 0.01}, 8, 4); adapt_wavelet
Results
Waves and grid
set xlabel 'iteration'
set ylabel 'mgp.i / mgp.nrelax'
plot 'perfs' u 3, '' u 4