PhaseFieldCrystal_.cc 3.16 KB
Newer Older
Praetorius, Simon's avatar
Praetorius, Simon committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#include "PhaseFieldCrystal_.h"

using namespace std;
using namespace AMDiS;

PhaseFieldCrystal_::PhaseFieldCrystal_(const std::string &name_, bool createProblem) :
  super(name_, createProblem),
  useMobility(false),
  tempParameter(-0.6),
  r(-0.4),		// temperature deviation
  rho0(1.0),		// liquid density
  density(-0.3),	// mean density
  two(2.0),
  minus2(-2.0)
{  
  Parameters::get(name + "->r",r);
  Parameters::get(name + "->rho0", rho0);
  Parameters::get(name + "->density", density);
  Parameters::get(name + "->use mobility", useMobility);
  tempParameter= -(1.0+r);
}


void PhaseFieldCrystal_::fillOperators()
{
  
  int degree = prob->getFeSpace(0)->getBasisFcts()->getDegree();
  
  // phi*rho
  Operator *opMnew = new Operator(prob->getFeSpace(0), prob->getFeSpace(0));
  opMnew->addTerm(new Simple_ZOT);
  Operator *opMold = new Operator(prob->getFeSpace(0), prob->getFeSpace(0));
  opMold->addTerm(new VecAtQP_ZOT(prob->getSolution()->getDOFVector(1), NULL));

  // -nabla*(phi*grad(rho))
  Operator *opL = new Operator(prob->getFeSpace(0), prob->getFeSpace(0));
  opL->addTerm(new Simple_SOT);
  
  Operator *opLM = new Operator(prob->getFeSpace(0), prob->getFeSpace(0));
  double M0 = 1.0;
  Parameters::get(name + "->M0", M0);
  if (useMobility) // non-constant mobility
    opLM->addTerm(new VecAtQP_SOT(
      prob->getSolution()->getDOFVector(1),
      new MobilityPfc(density, M0, degree)));
  else // constant mobility
    opLM->addTerm(new Simple_SOT(M0));
  
  // -(1+r)*phi*rho
  Operator *opMTemp = new Operator(prob->getFeSpace(0), prob->getFeSpace(0));
  opMTemp->addZeroOrderTerm(new Simple_ZOT());
  // -2*rho_old^3
  Operator *opMPowExpl = new Operator(prob->getFeSpace(0), prob->getFeSpace(0));
54
  opMPowExpl->addZeroOrderTerm(new VecAtQP_ZOT(prob->getSolution()->getDOFVector(1),new AMDiS::Pow<3>(-2.0, 3*degree)));
Praetorius, Simon's avatar
Praetorius, Simon committed
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
  // -3*rho_old^2
  Operator *opMPowImpl = new Operator(prob->getFeSpace(0), prob->getFeSpace(0));
  opMPowImpl->addZeroOrderTerm(new VecAtQP_ZOT(prob->getSolution()->getDOFVector(1),new AMDiS::Pow<2>(-3.0, 2*degree)));
  
  
  // dt(rho) = laplace(mu) - u*grad(rho)
  // -----------------------------------
  prob->addMatrixOperator(opMnew, 1, 1);
  prob->addMatrixOperator(opLM, 1, 0, getTau(), getTau()); // -laplace(mu)
  // . . . vectorOperators . . . . . . . . . . . . . . .
  prob->addVectorOperator(opMold, 1);
  
  // mu-2*nu-laplace(nu)-(1+r)*rho = (rho_old^3) + ExtPot - eps^2/(rho_old+0.9)
  // ----------------------------------------------------------------------
  prob->addMatrixOperator(opMTemp, 0, 1, getTempParameter(), getTempParameter()); // -phi*(1+r)*rho
70
  prob->addMatrixOperator(opMPowImpl, 0, 1); // -3*rho*rho_old^2
Praetorius, Simon's avatar
Praetorius, Simon committed
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
  prob->addMatrixOperator(opL, 0, 1, &two, &two); // -2*phi*laplace(rho) * psi
  prob->addMatrixOperator(opMnew, 0, 0); // phi*mu * psi
  prob->addMatrixOperator(opL, 0, 2); // phi*grad(nu) * grad(psi)
  // . . . vectorOperators . . . . . . . . . . . . . . .
  prob->addVectorOperator(opMPowExpl, 0); // -2*phi^old*rho_old^3
  
  // 0 = nu-laplace(rho)
  // -------------------
  prob->addMatrixOperator(opL, 2, 1); // -laplace(rho)
  prob->addMatrixOperator(opMnew, 2, 2); // nu
}


void PhaseFieldCrystal_::fillBoundaryConditions()
{}