www.mooseframework.org
SplitCHWResBase.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 SPLITCHWRESBASE_H
8 #define SPLITCHWRESBASE_H
9 
10 #include "Kernel.h"
11 #include "JvarMapInterface.h"
12 #include "DerivativeMaterialInterface.h"
13 
20 template <typename T>
21 class SplitCHWResBase : public DerivativeMaterialInterface<JvarMapKernelInterface<Kernel>>
22 {
23 public:
24  SplitCHWResBase(const InputParameters & parameters);
25 
26  static InputParameters validParams();
27 
28 protected:
29  virtual Real computeQpResidual();
30  virtual Real computeQpJacobian();
31  virtual Real computeQpOffDiagJacobian(unsigned int jvar);
32 
33 private:
34  const MaterialPropertyName _mob_name;
35  const MaterialProperty<T> & _mob;
36 
37  std::vector<const MaterialProperty<T> *> _dmobdarg;
38 };
39 
40 template <typename T>
41 SplitCHWResBase<T>::SplitCHWResBase(const InputParameters & parameters)
42  : DerivativeMaterialInterface<JvarMapKernelInterface<Kernel>>(parameters),
43  _mob_name(getParam<MaterialPropertyName>("mob_name")),
44  _mob(getMaterialProperty<T>("mob_name"))
45 {
46  // Get number of coupled variables
47  unsigned int nvar = _coupled_moose_vars.size();
48 
49  // reserve space for derivatives
50  _dmobdarg.resize(nvar);
51 
52  // Iterate over all coupled variables
53  for (unsigned int i = 0; i < nvar; ++i)
54  _dmobdarg[i] = &getMaterialPropertyDerivative<T>(_mob_name, _coupled_moose_vars[i]->name());
55 }
56 
57 template <typename T>
58 InputParameters
60 {
61  InputParameters params = ::validParams<Kernel>();
62  params.addClassDescription(
63  "Split formulation Cahn-Hilliard Kernel for the chemical potential variable");
64  params.addParam<MaterialPropertyName>("mob_name", "mobtemp", "The mobility used with the kernel");
65  params.addCoupledVar("args", "Vector of arguments of the mobility");
66  return params;
67 }
68 
69 template <typename T>
70 Real
72 {
73  return _mob[_qp] * _grad_u[_qp] * _grad_test[_i][_qp];
74 }
75 
76 template <typename T>
77 Real
79 {
80  return _mob[_qp] * _grad_phi[_j][_qp] * _grad_test[_i][_qp];
81 }
82 
83 template <typename T>
84 Real
86 {
87  // get the coupled variable jvar is referring to
88  const unsigned int cvar = mapJvarToCvar(jvar);
89 
90  return (*_dmobdarg[cvar])[_qp] * _phi[_j][_qp] * _grad_u[_qp] * _grad_test[_i][_qp];
91 }
92 
93 #endif // SPLITCHWRESBASE_H
SplitCHWResBase(const InputParameters &parameters)
virtual Real computeQpResidual()
SplitCHWresBase implements the residual for the chemical potential in the split form of the Cahn-Hill...
const MaterialProperty< T > & _mob
static InputParameters validParams()
virtual Real computeQpJacobian()
virtual Real computeQpOffDiagJacobian(unsigned int jvar)
const MaterialPropertyName _mob_name
std::vector< const MaterialProperty< T > * > _dmobdarg