6 12 GfsPoisson GfsBox GfsGEdge {} {
  Time { iend = 1 }
  PhysicalParams { L = 2.*M_PI/4. }
  MetricCubed M LEVEL

  # Use alternative implementation
  # MetricCubed1 M
  # MapFunction {
  #     x = atan2 (X, Z)*180./M_PI
  #     y = asin (CLAMP(Y,-1.,1.))*180./M_PI
  # }

  Refine LEVEL

  GModule hypre
  ApproxProjectionParams { tolerance = 1e-30 nitermin = CYCLE nitermax = CYCLE }

  Global {
      #include <gsl/gsl_sf.h>
      @link -lgsl -lgslcblas

      double fact (double n) {
        if (n <= 1)
      	  return 1.;
    	else
	  return n*fact(n - 1.);
      }

      double legendre (int l, int m, double x) {
	  if (m < 0) 
	      return pow(-1.,fabs(m))*fact(l-fabs(m))/fact(l+fabs(m))*
	      gsl_sf_legendre_Plm (l, fabs(m), x);
	  else
	      return gsl_sf_legendre_Plm (l, m, x);
      }

      double spherical_harmonic_re (int l, int m, double X, double Y) {
	  return sqrt((2*l+1)/(4*M_PI)*fact(l-m)/fact(l+m))*
	  legendre (l, m, sin(Y/180*M_PI))*cos(m*X/180*M_PI);
      }
  }

  Init { } { 
      Div = -4*(4+1)*spherical_harmonic_re (4, 2, x, y) 
      Sol = spherical_harmonic_re (4, 2, x, y)
  }

  OutputTime { istep = 1 } {
    awk '{if ($2 == 1) print CYCLE, $8;}' >> time
  }
  OutputProjectionStats { start = end } {
    awk '{if ($1 == "residual.infty:") print CYCLE, $3, $4;}' >> proj
  }
  OutputErrorNorm { start = end } {
    awk '{print LEVEL, $5, $7, $9}' >> error 
  } { v = P } {
    s = Sol
    v = E
    unbiased = 1
  }
  OutputSimulation { start = end } end-SOLVER-LEVEL.gfs
}
GfsBox {}
GfsBox {}
GfsBox {}
GfsBox {}
GfsBox {}
GfsBox {}
1 2 right
2 3 top
3 4 right
4 5 top
5 6 right
6 1 top
1 3 top left
3 5 top left
5 1 top left
2 6 bottom right
4 2 bottom right
6 4 bottom right