# GfsOutputErrorNorm

GfsOutputErrorNorm is used to write the norms of the difference between a scalar field and a user-defined reference field.

The norms are written using the same formatting as for GfsOutputScalarNorm.

The syntax in parameter files is:

```[ GfsOutputScalar ] {
s = [ GfsFunction ]
unbiased = 1
v = Error
w = [ GfsFunction ]
relative = 0
}
```

where `s` is the function defining the reference field and `v` is used to store the difference between the scalar and reference fields (`v` can be left undefined in which case a temporary variable is used).

If `unbiased` is set to one (default is zero), the bias (i.e. mean value of the difference) is substracted before computing the norms.

The norms can be weighted using the optional parameter `w`.

If `relative` is set to one, the norms are divided by the corresponding norms of the reference solution.

### Examples

• Convergence of the Poisson solver
• ```  OutputErrorNorm { start = end } {
awk '{print LEVEL, \$5, \$7, \$9}' >> error
} { v = P } {
s = (sin (M_PI*3.*x)*sin (M_PI*3.*y))
unbiased = 1
}
```

• Convergence with a refined circle
• ```  OutputErrorNorm { start = end } {
awk '{print LEVEL, \$5, \$7, \$9}' >> error
} { v = P } {
s = (sin (M_PI*3.*x)*sin (M_PI*3.*y))
unbiased = 1
}
```

• Dirichlet boundary condition
• ```    OutputErrorNorm { start = end } {
awk '{print LEVEL, \$5, \$7, \$9}' >> error
} { v = P } {
s = {
double theta = atan2 (y, x);
double r2 = x*x + y*y;
return r2*r2*cos (3.*theta);
}
}
```

• Convergence of the Godunov advection scheme
• ```  OutputErrorNorm { start = end } { awk '{ print LEVEL " " \$5 " " \$7 " " \$9}' } { v = T } {
s = {
double r2 = x*x + y*y;
double coeff = 20. + 20000.*r2*r2*r2*r2;
return (1. + cos(20.*x)*cos(20.*y))*exp(-coeff*r2)/2.;
}
}
```

• Time-reversed VOF advection in a shear flow
• ```    OutputErrorNorm { start = end } norms { v = T } {
s = Tref v = DT
}
```

• Time-reversed advection of a VOF concentration
• ```    OutputErrorNorm { start = end } dt-LEVEL { v = T } {
s = Tref
v = DT
}
```

```    OutputErrorNorm { start = end } dt1-LEVEL { v = C } {
s = Tref*GAUSSIAN
v = DC
}
```

```    OutputErrorNorm { start = end } dt2-LEVEL { v = G } {
s = GAUSSIAN
v = DG
}
```

• Time-reversed advection with curvature-based refinement
• ```    OutputErrorNorm { start = end } norms { v = T } {
s = Tref v = DT
}
```

• Rotation of a straight interface
• ```    OutputErrorNorm { istep = 1 } error { v = T } { s = Tref }
```

• Estimation of the numerical viscosity
• ```  OutputErrorNorm { start = end } { awk '{ print \$3,\$5,\$7,\$9 }' > errorLEVEL.dat } {
v = Velocity
} {
s = sqrt(U0*U0+V0*V0)
v = E
relative = 1
}
```

• Estimation of the numerical viscosity with refined box
• ```  OutputErrorNorm { start = end } { awk '{ print \$3,\$5,\$7,\$9 }' > errorLEVEL.dat } {
v = Velocity
} {
s = sqrt(U0*U0+V0*V0)
v = E
relative = 1
}
```

• Numerical viscosity for the skew-symmetric scheme
• ```  OutputErrorNorm { start = end } { awk '{ print \$3,\$5,\$7,\$9 }' > errorLEVEL.dat } {
v = Velocity
} {
s = sqrt(U0*U0+V0*V0)
v = E
relative = 1
}
```

• Numerical viscosity for the skew-symmetric scheme with refined box
• ```  OutputErrorNorm { start = end } {
awk '{ print 2**(LEVEL+1)/4+2**(LEVEL-1)*3/4,\$3,\$5,\$7,\$9 }'
} {
v = Velocity
} {
s = sqrt(U0*U0 + V0*V0)
v = E
relative = 1
}
```

• Numerical viscosity for vorticity/streamfunction formulation
• ```  OutputErrorNorm { start = end } { awk '{ print \$3,\$5,\$7,\$9 }' > errorLEVEL.dat } {
v = Velocity
} {
s = sqrt(U0*U0+V0*V0)
v = E
relative = 1
}
```

• Convergence for a simple periodic problem
• ```  OutputErrorNorm { start = end } stdout { v = U } {
s = (1. - 2.*cos (2.*M_PI*(x - t))*sin (2.*M_PI*(y - t)))
}
```

• Flow created by a cylindrical volume source
• ```    OutputErrorNorm { start = end } { awk '{ print LEVEL,\$5,\$7,\$9 }' > error-LEVEL } {
v = Velocity
} {
s = sol(x,y)
v = E
w = (x*x + y*y < 25.*R0*R0)
relative = 1
}
```

• Potential flow around a sphere
• ```    OutputErrorNorm { start = end } { awk '{ print LEVEL " " \$7 " " \$9}' } { v = U } {
s = (dx("Phi") + 1.)
}
```

• Poiseuille flow
• ```    OutputErrorNorm { start = end } { awk '{print LEVEL,\$5,\$7,\$9}' } { v = U } {
s = 1./2.*(1./4 - y*y)
}
```

• Bagnold flow of a granular material
• ```    OutputErrorNorm { start = end } { awk '{print LEVEL,\$5,\$7,\$9}' } { v = U } {
# Bagnold's solution
s = UB(y)
}
```

• Poiseuille flow with metric
• ```    OutputErrorNorm { start = end } { awk '{print LEVEL,\$5,\$7,\$9}' } { v = U } {
s = 1./2.*(1./4 - y*y)
}
```

• Hydrostatic balance with quadratic pressure profile
• ```    OutputErrorNorm { istep = 1 } p { v = P } {
s = -(cy*cy/2. + 0.5*cy)
unbiased = 1
}
```

• Translation of an hexagon in a uniform flow
• ```  OutputErrorNorm { istep = 1 } {
awk '{ printf ("%e %e %e %e\n", \$3, \$5, \$7, \$9) }' > momentumerror-ORDER
} { v = sqrt((U - 1.)*(U - 1.) + V*V) } { s = 0. }
```

• ```  OutputErrorNorm { istep = 1 } {
awk '{print \$3/86400. " " \$9; fflush (stdout); }' > e
} { v = P/G } {
s = ETA0*exp (-(x*x + y*y)/(R0*R0))
unbiased = 1
v = E
}
```

• ```  OutputErrorNorm { istep = 1 } {
awk '{print \$3/86400. " " \$9; fflush (stdout); }' > e
} { v = P } {
s = (H0 + ETA0*exp (-(x*x + y*y)/(R0*R0)))
v = E
}
```

• ```  OutputErrorNorm { istep = 1 } error-OMEGA { v = P } {
s = h0(sqrt (x*x + y*y))
v = E
unbiased = 1
relative = 1
}
```

• Oscillations in a parabolic container
• ```    OutputErrorNorm { istep = 1 } error-LEVEL { v = P } {
s = Pt
v = DP
}
```

• Parabolic container with embedded solid
• ```    OutputErrorNorm { istep = 1 } error-LEVEL { v = P } {
s = Pt
v = DP
}
```

• Transcritical flow over a bump
• ```    OutputErrorNorm { start = end } { awk '{ print LEVEL,\$5,\$7,\$9 }' } { v = H } {
s = href.cgd
v = EH
}
```

• Lake-at-rest balance in an inclined domain with cut cells
• ```    OutputErrorNorm { start = end } ep { v = P } {
s = MAX(0, 0.5 - x/10.)
unbiased = 1
relative = 1
}
```

• Lake-at-rest balance in an inclined domain with bipolar metric
• ```    OutputErrorNorm { start = end } ep { v = P } {
s = MAX(0, 1.26 - x/10.)
unbiased = 1
relative = 1
}
```

• Terrain reconstruction
• ```    OutputErrorNorm { start = end } { awk '{ print LEVEL,\$5,\$7,\$9 }' >> error-t } { v = T } {
s = {
double r = sqrt (x*x + y*y);
return r*r/8.+cos(M_PI*r)/2.;
}
w = (fabs (x) < 3.8 && fabs (y) < 3.8)
relative = 1
v = Et
}
```

```    OutputErrorNorm { start = end } { awk '{ print LEVEL,\$5,\$7,\$9 }' >> error-h } { v = H0 } {
s = {
double r = sqrt (x*x + y*y);
return r*r/8.+cos(M_PI*r)/2.;
}
w = (fabs (x) < 3.8 && fabs (y) < 3.8)
relative = 1
v = Eh
}
```

• Advection of a cosine bell around the sphere
• ```  OutputErrorNorm { istep = 1 } { awk '{ print LEVEL,\$3,\$5,\$7,\$9}' > error-LEVEL-ALPHA } { v = T } {
s = bell_moving(x*DTR,y*DTR,t)
v = E
relative = 1
}
```

• Poisson problem with a pure spherical harmonics solution
• ```  OutputErrorNorm { start = end } {
awk '{print LEVEL, \$5, \$7, \$9}' >> error
} { v = P } {
s = Sol
v = E
unbiased = 1
}
```

• Spherical harmonics with longitude-latitude coordinates
• ```  OutputErrorNorm { start = end } {
awk '{print LEVEL, \$5, \$7, \$9}' >> error
} { v = P } {
s = Sol
v = E
unbiased = 1
}
```

• Creeping Couette flow between cylinders
• ```    OutputErrorNorm { start = end } { awk '{print LEVEL,\$5,\$7,\$9}' } { v = V } {
s = {
double r = rx/4. + 0.375;
// the analytical solution for the tangential velocity
return r*((0.5/r)*(0.5/r) - 1.)/((0.5/0.25)*(0.5/0.25) - 1.);
}
v = E
}
```

• Creeping Couette flow between eccentric cylinders
• ```  OutputErrorNorm { start = end } { awk '{ print LEVEL,\$5,\$7,\$9 }' } { v = Velocity } {
s = {
double p, u, v;
psiuv (x, y - ECC, R1, R2, ECC, 1., 0., &u, &v, &p);
return sqrt (u*u + v*v);
}
v = EU
}
```

• Flow between eccentric cylinders using bipolar coordinates
• ```  OutputErrorNorm { start = end } { awk '{ print LEVEL,\$5,\$7,\$9 }' } { v = Velocity } {
s = {
double p, u, v;
// we need to rotate coordinates by 90 degrees
psiuv (y, x - X2, R1, R2, ECC, 1., 0., &u, &v, &p);
return sqrt (u*u + v*v);
}
v = EU
}
```

• Flow between eccentric cylinders on a stretched grid
• ```  OutputErrorNorm { start = end } { awk '{ print LEVEL,\$5,\$7,\$9 }' } { v = Velocity } {
s = {
double p, u, v;
psiuv (x, y - ECC, R1, R2, ECC, 1., 0., &u, &v, &p);
return sqrt (u*u + v*v);
}
v = EU
}
```

• Rossby--Haurwitz wave
• ```    OutputErrorNorm { istart = 1 istep = 10 } eh-LEVEL { v = P/G } {
s = p0(x*DTR,y*DTR,t)/G
v = EH unbiased = 1 relative = 1
}
```

• Rossby--Haurwitz wave with a free surface
• ```    OutputErrorNorm { istart = 1 istep = 10 } eh-LEVEL { v = P/G } {
s = p0(x*DTR,y*DTR,t)/G
v = EH unbiased = 1 relative = 1
}
```

• Rossby--Haurwitz wave with Saint-Venant
• ```    OutputErrorNorm { istep = 10 } eh-LEVEL { v = P } {
s = p0(x*DTR,y*DTR,t)/G
v = EH unbiased = 1 relative = 1
}
```

• Relaxation of a charge bump
• ```    OutputErrorNorm { istep = 10 } norms-SCHEME { v = Rhoe } { s = gaussbell(x,y,t) }
```

• Charge relaxation in an axisymmetric insulated conducting column
• ```    OutputErrorNorm { start = end } norms-LEVEL { v = Ey } {
s = (y < R0 ? 0 : 0.5*R0*R0*rhoinic/y)
}
```

• Charge relaxation in a planar cross-section
• ```    OutputErrorNorm { start = end } norms-LEVEL { v = sqrt(Ex*Ex + Ey*Ey) } {
s = {
double r = sqrt (x*x + y*y);
return (r < R0 ? 0 : 0.5*R0*R0*rhoinic/r);
}
}
```

• Simple example of groundwater flow following Darcy's law
• ```	OutputErrorNorm {} { awk '{print LEVEL, \$5, \$7, \$9}' >> p } { v = P } {
s = atan2 (y, x)
}
```

```	OutputErrorNorm {} { awk '{print LEVEL, \$5, \$7, \$9}' >> U } { v = U } {
s = y / (x*x + y*y)
}
```

```	OutputErrorNorm {} { awk '{print LEVEL, \$5, \$7, \$9}' >> V } { v = V } {
s = -x / (x*x + y*y)
}
```

• Groundwater flow with piecewise constant permeability
• ```	OutputErrorNorm {} { awk '{print LEVEL, \$5, \$7, \$9}' >> p } { v = P } {
s = THETA>-M_PI/3 ? THETA : 2*THETA+M_PI/3
}
```

```	OutputErrorNorm {} { awk '{print LEVEL, \$5, \$7, \$9}' >> U } { v = U } {
s = y / (x*x + y*y)
}
```

```	OutputErrorNorm {} { awk '{print LEVEL, \$5, \$7, \$9}' >> V } { v = V } {
s = -x / (x*x + y*y)
}
```