#include <dolfin.h>

namespace dolfin
{

  // Sub domain for Dirichlet boundary condition
  class DirichletBoundary : public SubDomain
  {
  public:
    bool inside(const real* x, bool on_boundary) const
    {
      if(fabs(x[0] - 0.0) < 1.0e-8)
	return true;
      else
	return false;
    }
  };

  class MySource : public Function
  {
  public:
    MySource(Mesh& mesh) : Function(mesh)
    {
    }
    
    void eval(real* values, const real* x) const
    {
      values[0] = 0.0;
      values[1] = -200.0;
    }
  };
  
  class InitialValue : public Function
  {
  public:
    InitialValue(Mesh& mesh) : Function(mesh)
    {
    }
    
    void eval(real* values, const real* x) const
    {
      for(int i = 0; i < 4; i++)
      {
	values[i] = 0.0;
      }
    }
  };

  class MyBC : public Function
  {
  public:
    MyBC(Mesh& mesh) : Function(mesh)
    {
    }
    
    void eval(real* values, const real* x) const
    {
      for(int i = 0; i < 2; i++)
      {
	values[i] = 0.0;
      }
    }
  };

  void transform(Mesh& mesh, int Nx, int Ny)
  {
    for (VertexIterator n(mesh); !n.end(); ++n)
    {
      Vertex& vertex = *n;
      
      MeshGeometry& geometry = mesh.geometry();
      
      for(unsigned int i = 0; i < mesh.topology().dim(); i++)
      {
	if(i == 0)
	  geometry.x(vertex.index(), i) *= 2.0 * Nx / 6.0;
	if(i == 1)
	  geometry.x(vertex.index(), i) *= Ny / 3.0;
      }
    }
  }
}
