Convergence of axisymmetric viscous terms

We wish to test the accuracy of the discretisation of viscous terms in axisymmetric coordinates. To do so, we “manufacture” a solution to the pure viscous diffusion problem ${\partial }_{t}\left(yu\right)={\partial }_{x}\left(y{\tau }_{xx}\right)+{\partial }_{y}\left(y{\tau }_{xy}\right)+{s}_{x}$ ${\partial }_{t}\left(yv\right)={\partial }_{x}\left(y{\tau }_{yx}\right)+{\partial }_{y}\left(y{\tau }_{yy}\right)+{s}_{y}-2\frac{v}{y}$ with ${\tau }_{xx}=2{\partial }_{x}u$ ${\tau }_{xy}={\tau }_{yx}=\left({\partial }_{y}u+{\partial }_{x}v\right)$ ${\tau }_{yy}=2{\partial }_{y}v$ and where ${s}_{x}$ and ${s}_{y}$ are source terms to be determined. We look for solutions of the form $u\left(x,y\right)=v\left(x,y\right)={y}^{a}\mathrm{cos}x\mathrm{sin}y$ The viscous stress tensor is then (for $\mu =1$) ${\tau }_{xx}=-2{y}^{a}\mathrm{sin}x\mathrm{sin}y$ ${\tau }_{xy}={\tau }_{yx}=\mathrm{cos}x\left({y}^{a}\mathrm{cos}y+a{y}^{a-1}\mathrm{sin}y\right)-{y}^{a}\mathrm{sin}x\mathrm{sin}y$ ${\tau }_{yy}=2\mathrm{cos}x\left({y}^{a}\mathrm{cos}y+a{y}^{a-1}\mathrm{sin}y\right)$ and the viscosity equation gives ${s}_{x}={y}^{a}\left[3y\mathrm{cos}x\mathrm{sin}y-\left(2a+1\right)\mathrm{cos}x\mathrm{cos}y-{a}^{2}{y}^{-1}\mathrm{cos}x\mathrm{sin}y+y\mathrm{sin}x\mathrm{cos}y+\left(a+1\right)\mathrm{sin}x\mathrm{sin}y\right]$ ${s}_{y}={y}^{a}\left[y\mathrm{sin}x\mathrm{cos}y+a\mathrm{sin}x\mathrm{sin}y+3y\mathrm{cos}x\mathrm{sin}y-2\left(2a+1\right)\mathrm{cos}x\mathrm{cos}y+2\left(1-{a}^{2}\right){y}^{-1}\mathrm{cos}x\mathrm{sin}y\right]$ The game is then to solve the viscosity equation with the forcing terms defined above and recover the (stationary) solution for the velocity field.

We use the axisymmetric metric, the viscous solver and the standard time loop.

``````#include "grid/multigrid.h"
#include "axi.h"
#include "viscosity.h"
#include "run.h"
``````

We impose the correct boundary conditions for $u$ (the default boundary conditions for $v$ are already correct).

``````vector u[];

u.t[top] = dirichlet(0);
u.t[bottom] = dirichlet(0);

int main()
{
L0 = 2.*π;
periodic (right);
for (N = 16; N <= 128; N *= 2)
run();
}``````

We solve only for the case $a=1$. The case $a=0$ is ill-posed because the forcing terms diverge near the axis of symmetry.

``````double a = 1.;
mgstats mg;

event init (i = 0) {
foreach()
u.x[] = u.y[] = 0.;
boundary ((scalar *){u});
}

event integration (i++)
{
double dt = 1.;``````

This is the time integration loop. We first add the forcing term…

``````  foreach() {
u.x[] += dt*pow(y, a - 1.)*(3.*y*cos(x)*sin(y) - (2.*a + 1.)*cos(x)*cos(y)
- sq(a)*cos(x)*sin(y)/y
+ y*sin(x)*cos(y) + (a + 1.)*sin(x)*sin(y));
u.y[] += dt*pow(y, a - 1.)*(y*sin(x)*cos(y) + a*sin(x)*sin(y)
+ 3.*y*cos(x)*sin(y)
- 2.*(2.*a + 1.)*cos(x)*cos(y) +
2.*(1. - sq(a))*cos(x)*sin(y)/y);
}
boundary ((scalar *){u});``````

…and then solve for viscosity.

``````  mg = viscosity (u, fm, cm, dt);
}

event error (i = 20)
{``````

Twenty timesteps are enough to converge toward the stationary solution.

``````  scalar e[];
foreach() {
printf ("%g %g %g %g %g\n", x, y, u.x[], u.y[], pow(y,a)*cos(x)*sin(y));
e[] = u.x[] - pow(y,a)*cos(x)*sin(y);
}
norm n = normf (e);
fprintf (stderr, "%d %g %g %g %d %d\n",
N, n.avg, n.rms, n.max, mg.i, mg.nrelax);
}``````

As expected we get second-order convergence.