https://mooseframework.inl.gov
CHBulk.h
Go to the documentation of this file.
1 //* This file is part of the MOOSE framework
2 //* https://mooseframework.inl.gov
3 //*
4 //* All rights reserved, see COPYRIGHT for full restrictions
5 //* https://github.com/idaholab/moose/blob/master/COPYRIGHT
6 //*
7 //* Licensed under LGPL 2.1, please see LICENSE for details
8 //* https://www.gnu.org/licenses/lgpl-2.1.html
9 
10 #pragma once
11 
12 #include "KernelGrad.h"
13 #include "JvarMapInterface.h"
15 
24 template <typename T>
25 class CHBulk : public DerivativeMaterialInterface<JvarMapKernelInterface<KernelGrad>>
26 {
27 public:
28  CHBulk(const InputParameters & parameters);
29 
31  virtual void initialSetup();
32 
33 protected:
36  virtual Real computeQpOffDiagJacobian(unsigned int jvar);
37 
39  {
42  };
43 
45 
48 
51 
53  std::vector<const MaterialProperty<T> *> _dMdarg;
54 };
55 
56 template <typename T>
59  _M(getMaterialProperty<T>("mob_name")),
60  _dMdc(getMaterialPropertyDerivative<T>("mob_name", _var.name()))
61 {
62  // Get number of coupled variables
63  unsigned int nvar = _coupled_moose_vars.size();
64 
65  // reserve space for derivatives
66  _dMdarg.resize(nvar);
67 
68  // Iterate over all coupled variables
69  for (unsigned int i = 0; i < nvar; ++i)
70  _dMdarg[i] = &getMaterialPropertyDerivative<T>("mob_name", _coupled_moose_vars[i]->name());
71 }
72 
73 template <typename T>
76 {
78  params.addClassDescription("Cahn-Hilliard base Kernel");
79  params.addParam<MaterialPropertyName>("mob_name", "M", "The mobility used with the kernel");
80  params.addCoupledVar("coupled_variables", "Vector of variable arguments of the mobility");
81  return params;
82 }
83 
84 template <typename T>
85 void
87 {
88  validateNonlinearCoupling<Real>("mob_name");
89 }
90 
91 template <typename T>
94 {
95  return _M[_qp] * computeGradDFDCons(Residual);
96 }
97 
98 template <typename T>
101 {
102  RealGradient grad_value = _M[_qp] * computeGradDFDCons(Jacobian) +
103  _dMdc[_qp] * _phi[_j][_qp] * computeGradDFDCons(Residual);
104 
105  return grad_value;
106 }
107 
108 template <typename T>
109 Real
111 {
112  // get the coupled variable jvar is referring to
113  const unsigned int cvar = mapJvarToCvar(jvar);
114 
115  return (*_dMdarg[cvar])[_qp] * _phi[_j][_qp] * computeGradDFDCons(Residual) * _grad_test[_i][_qp];
116 }
virtual RealGradient computeGradDFDCons(PFFunctionType type)=0
void addParam(const std::string &name, const std::initializer_list< typename T::value_type > &value, const std::string &doc_string)
This is the Cahn-Hilliard equation base class that implements the bulk or local energy term of the eq...
Definition: CHBulk.h:25
const MaterialProperty< T > & _M
Mobility.
Definition: CHBulk.h:47
const MaterialProperty< T > & _dMdc
Mobility derivative w.r.t. concentration.
Definition: CHBulk.h:50
virtual Real computeQpOffDiagJacobian(unsigned int jvar)
Definition: CHBulk.h:110
virtual RealGradient precomputeQpJacobian()
Definition: CHBulk.h:100
const std::string name
Definition: Setup.h:20
virtual RealGradient precomputeQpResidual()
Definition: CHBulk.h:93
void addCoupledVar(const std::string &name, const std::string &doc_string)
static InputParameters validParams()
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
void addClassDescription(const std::string &doc_string)
static InputParameters validParams()
Definition: CHBulk.h:75
CHBulk(const InputParameters &parameters)
Definition: CHBulk.h:57
std::vector< const MaterialProperty< T > * > _dMdarg
Mobility derivative w.r.t coupled variables.
Definition: CHBulk.h:53
virtual void initialSetup()
Definition: CHBulk.h:86