www.mooseframework.org
ACBulk.h
Go to the documentation of this file.
1 /****************************************************************/
2 /* MOOSE - Multiphysics Object Oriented Simulation Environment */
3 /* */
4 /* All contents are licensed under LGPL V2.1 */
5 /* See LICENSE for full restrictions */
6 /****************************************************************/
7 #ifndef ACBULK_H
8 #define ACBULK_H
9 
10 #include "KernelValue.h"
11 #include "JvarMapInterface.h"
12 #include "DerivativeMaterialInterface.h"
13 
21 template <typename T>
22 class ACBulk : public DerivativeMaterialInterface<JvarMapKernelInterface<KernelValue>>
23 {
24 public:
25  ACBulk(const InputParameters & parameters);
26 
27  static InputParameters validParams();
28  virtual void initialSetup();
29 
30 protected:
31  virtual Real precomputeQpResidual();
32  virtual Real precomputeQpJacobian();
33  virtual Real computeQpOffDiagJacobian(unsigned int jvar);
34 
36  {
39  };
40 
41  virtual Real computeDFDOP(PFFunctionType type) = 0;
42 
44  const MaterialProperty<T> & _L;
45 
47  const MaterialProperty<T> & _dLdop;
48 
50  std::vector<const MaterialProperty<T> *> _dLdarg;
51 };
52 
53 template <typename T>
54 ACBulk<T>::ACBulk(const InputParameters & parameters)
55  : DerivativeMaterialInterface<JvarMapKernelInterface<KernelValue>>(parameters),
56  _L(getMaterialProperty<T>("mob_name")),
57  _dLdop(getMaterialPropertyDerivative<T>("mob_name", _var.name()))
58 {
59  // Get number of coupled variables
60  unsigned int nvar = _coupled_moose_vars.size();
61 
62  // reserve space for derivatives
63  _dLdarg.resize(nvar);
64 
65  // Iterate over all coupled variables
66  for (unsigned int i = 0; i < nvar; ++i)
67  _dLdarg[i] = &getMaterialPropertyDerivative<T>("mob_name", _coupled_moose_vars[i]->name());
68 }
69 
70 template <typename T>
71 InputParameters
73 {
74  InputParameters params = ::validParams<KernelValue>();
75  params.addClassDescription("Allen-Cahn base Kernel");
76  params.addParam<MaterialPropertyName>("mob_name", "L", "The mobility used with the kernel");
77  params.addCoupledVar("args", "Vector of arguments of the mobility");
78  return params;
79 }
80 
81 template <typename T>
82 void
84 {
85  validateNonlinearCoupling<Real>("mob_name");
86 }
87 
88 template <typename T>
89 Real
91 {
92  // Get free energy derivative from function
93  Real dFdop = computeDFDOP(Residual);
94 
95  // Set residual
96  return _L[_qp] * dFdop;
97 }
98 
99 template <typename T>
100 Real
102 {
103  // Get free energy derivative and Jacobian
104  Real dFdop = computeDFDOP(Residual);
105 
106  Real JdFdop = computeDFDOP(Jacobian);
107 
108  // Set Jacobian value using product rule
109  return _L[_qp] * JdFdop + _dLdop[_qp] * _phi[_j][_qp] * dFdop;
110 }
111 
112 template <typename T>
113 Real
115 {
116  // Get the coupled variable jvar is referring to
117  const unsigned int cvar = mapJvarToCvar(jvar);
118 
119  // Set off-diagonal Jacobian term from mobility derivatives
120  return (*_dLdarg[cvar])[_qp] * _phi[_j][_qp] * computeDFDOP(Residual) * _test[_i][_qp];
121 }
122 
123 #endif // ACBULK_H
const MaterialProperty< T > & _L
Mobility.
Definition: ACBulk.h:44
virtual void initialSetup()
Definition: ACBulk.h:83
ACBulk(const InputParameters &parameters)
Definition: ACBulk.h:54
This is the Allen-Cahn equation base class that implements the bulk or local energy term of the equat...
Definition: ACBulk.h:22
virtual Real computeDFDOP(PFFunctionType type)=0
virtual Real computeQpOffDiagJacobian(unsigned int jvar)
Definition: ACBulk.h:114
std::vector< const MaterialProperty< T > * > _dLdarg
Mobility derivative w.r.t coupled variables.
Definition: ACBulk.h:50
virtual Real precomputeQpJacobian()
Definition: ACBulk.h:101
virtual Real precomputeQpResidual()
Definition: ACBulk.h:90
static InputParameters validParams()
Definition: ACBulk.h:72
const MaterialProperty< T > & _dLdop
Mobility derivative w.r.t. order parameter.
Definition: ACBulk.h:47