sandbox/Antoonvh/poiseuille-periodic.c
A Poiseuille flow test case
On this page we test the accuracy of the Stokes solver to represent a periodic Poiseuille flow over a domain x \in [-1, 1] forced with \frac{1}{\rho}\frac{\mathrm{d}P}{\mathrm{d}y} = 1:
u_y = 0.5 \left( 1-x \right) ^2
#include "grid/multigrid.h"
#include "navier-stokes/centered.h"
A macro to obtain the cell-averaged analytical solution:
#define sol(x) (0.5*(1. - sq(x) - sq(Delta)/12.))
int main(){
= 2.;
L0 = -L0/2.;
X0 periodic (top);
= true;
stokes = 1e-5; TOLERANCE
We set Neumann conditions corresponding to the analytical solution and run with increasing grid resolutions.
.t[left] = neumann(-1);
u.t[right] = neumann(-1);
ufor (N = 2; N <= 64; N *= 2)
run();
}
event init (t = 0) {
= 0.01;
DT const face vector g[] = {0., 1.};
= g;
a const face vector muc[] = {1.,1.};
= muc;
mu foreach()
.y[] = sol(x);
u}
event profile (t = 6) {
static FILE * fp = fopen("output", "w");
double e = 0;
foreach()
+= fabs(u.y[] - sol(x)) * sq(Delta);
e fprintf (fp, "%d %g \n", N, e);
}
The 2nd order solver is able to exactly represent the second order polynomial solution:
set logscale x 2
set xr [ 1:128]
set yr [-0.00000001:0.00000001]
set xlabel 'N'
set ylabel 'Error'
plot 'output' u 1:2