#include "unicorn/Elasticity2D.h"
#include "unicorn/ElasticityStress2D.h"
#include "unicorn/ElasticityJac2D.h"
#include "unicorn/Projection2D.h"
#include "unicorn/Elasticity3D.h"
#include "unicorn/ElasticityStress3D.h"
#include "unicorn/ElasticityJac3D.h"
#include "unicorn/Projection3D.h"

#include "unicorn/FormFactory.h"

using namespace dolfin;
using namespace dolfin::unicorn;

void dolfin::unicorn::
FormFactory(Mesh& mesh,
	    Form*& a, Form*& L,
	    Form*& aJac,
	    Form*& aS, Form*& LS,
	    Form*& aP, Form*& LP,
	    Function& U,
	    Function& B,
	    Function& u0,
	    Function& rho,
	    Function& mu,
	    Function& lmbda,
	    Function& beta,
	    Function& kf,
	    Function& f)
{
  int d = mesh.topology().dim();

  cout << "dim: " << d << endl;
  
  if(d == 2)
  {
    a = new Elasticity2DBilinearForm(rho);
    L = new Elasticity2DLinearForm(U, B, mu, lmbda, beta, f);
    aS = new ElasticityStress2DBilinearForm();
    LS = new ElasticityStress2DLinearForm(B, U);
    aJac = new ElasticityJac2DBilinearForm(mu, lmbda, beta, kf);
    aP = new Projection2DBilinearForm();
    LP = new Projection2DLinearForm(u0);
  }
  else if(d == 3)
  {
    a = new Elasticity3DBilinearForm(rho);
    L = new Elasticity3DLinearForm(U, B, mu, lmbda, beta, f);
    aS = new ElasticityStress3DBilinearForm();
    LS = new ElasticityStress3DLinearForm(B, U);
    aJac = new ElasticityJac3DBilinearForm(mu, lmbda, beta, kf);
    aP = new Projection3DBilinearForm();
    LP = new Projection3DLinearForm(u0);
  }
}

