struct f : field_functor<f,Float> {
 Float operator() (const point& x) const { 
  switch (d) {
  case 1:  return (1+d*pi*pi)*sin(pi*x[0]);
  case 2:  return (1+d*pi*pi)*sin(pi*x[0])*sin(pi*x[1]);
  default: return (1+d*pi*pi)*sin(pi*x[0])*sin(pi*x[1])*sin(pi*x[2]);
 }}
 f(size_t d1) : d(d1), pi(acos(Float(-1.0))) {}
 size_t d; const Float pi;
};
struct g : field_functor<g,Float> {
 Float operator() (const point& x) const {
  switch (d) {
  case 1:  return -pi;
  case 2:  return -pi*(sin(pi*x[0]) + sin(pi*x[1]));
  default: return -pi*( sin(pi*x[0])*sin(pi*x[1])
                      + sin(pi*x[1])*sin(pi*x[2])
                      + sin(pi*x[2])*sin(pi*x[0])); 
 }}
 g(size_t d1) : d(d1), pi(acos(Float(-1.0))) {}
 size_t d; const Float pi;
};
