www.mooseframework.org
CHBulk.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 CHBULK_H
8 #define CHBULK_H
9 
10 #include "KernelGrad.h"
11 #include "JvarMapInterface.h"
12 #include "DerivativeMaterialInterface.h"
13 
22 template <typename T>
23 class CHBulk : public DerivativeMaterialInterface<JvarMapKernelInterface<KernelGrad>>
24 {
25 public:
26  CHBulk(const InputParameters & parameters);
27 
28  static InputParameters validParams();
29  virtual void initialSetup();
30 
31 protected:
32  virtual RealGradient precomputeQpResidual();
33  virtual RealGradient precomputeQpJacobian();
34  virtual Real computeQpOffDiagJacobian(unsigned int jvar);
35 
37  {
40  };
41 
42  virtual RealGradient computeGradDFDCons(PFFunctionType type) = 0;
43 
45  const MaterialProperty<T> & _M;
46 
48  const MaterialProperty<T> & _dMdc;
49 
51  std::vector<const MaterialProperty<T> *> _dMdarg;
52 };
53 
54 template <typename T>
55 CHBulk<T>::CHBulk(const InputParameters & parameters)
56  : DerivativeMaterialInterface<JvarMapKernelInterface<KernelGrad>>(parameters),
57  _M(getMaterialProperty<T>("mob_name")),
58  _dMdc(getMaterialPropertyDerivative<T>("mob_name", _var.name()))
59 {
60  // Get number of coupled variables
61  unsigned int nvar = _coupled_moose_vars.size();
62 
63  // reserve space for derivatives
64  _dMdarg.resize(nvar);
65 
66  // Iterate over all coupled variables
67  for (unsigned int i = 0; i < nvar; ++i)
68  _dMdarg[i] = &getMaterialPropertyDerivative<T>("mob_name", _coupled_moose_vars[i]->name());
69 }
70 
71 template <typename T>
72 InputParameters
74 {
75  InputParameters params = ::validParams<KernelGrad>();
76  params.addClassDescription("Cahn-Hilliard base Kernel");
77  params.addParam<MaterialPropertyName>("mob_name", "M", "The mobility used with the kernel");
78  params.addCoupledVar("args", "Vector of arguments of the mobility");
79  return params;
80 }
81 
82 template <typename T>
83 void
85 {
86  validateNonlinearCoupling<Real>("mob_name");
87 }
88 
89 template <typename T>
90 RealGradient
92 {
93  return _M[_qp] * computeGradDFDCons(Residual);
94 }
95 
96 template <typename T>
97 RealGradient
99 {
100  RealGradient grad_value = _M[_qp] * computeGradDFDCons(Jacobian) +
101  _dMdc[_qp] * _phi[_j][_qp] * computeGradDFDCons(Residual);
102 
103  return grad_value;
104 }
105 
106 template <typename T>
107 Real
109 {
110  // get the coupled variable jvar is referring to
111  const unsigned int cvar = mapJvarToCvar(jvar);
112 
113  return (*_dMdarg[cvar])[_qp] * _phi[_j][_qp] * computeGradDFDCons(Residual) * _grad_test[_i][_qp];
114 }
115 
116 #endif // CHBULK_H
virtual RealGradient computeGradDFDCons(PFFunctionType type)=0
This is the Cahn-Hilliard equation base class that implements the bulk or local energy term of the eq...
Definition: CHBulk.h:23
const MaterialProperty< T > & _M
Mobility.
Definition: CHBulk.h:45
const MaterialProperty< T > & _dMdc
Mobility derivative w.r.t. concentration.
Definition: CHBulk.h:48
virtual Real computeQpOffDiagJacobian(unsigned int jvar)
Definition: CHBulk.h:108
virtual RealGradient precomputeQpJacobian()
Definition: CHBulk.h:98
virtual RealGradient precomputeQpResidual()
Definition: CHBulk.h:91
static InputParameters validParams()
Definition: CHBulk.h:73
CHBulk(const InputParameters &parameters)
Definition: CHBulk.h:55
std::vector< const MaterialProperty< T > * > _dMdarg
Mobility derivative w.r.t coupled variables.
Definition: CHBulk.h:51
virtual void initialSetup()
Definition: CHBulk.h:84