www.mooseframework.org
CHBulk.h
Go to the documentation of this file.
1 //* This file is part of the MOOSE framework
2 //* https://www.mooseframework.org
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("args", "Vector of variable arguments of the mobility");
81  params.deprecateCoupledVar("args", "coupled_variables", "02/27/2024");
82  return params;
83 }
84 
85 template <typename T>
86 void
88 {
89  validateNonlinearCoupling<Real>("mob_name");
90 }
91 
92 template <typename T>
95 {
96  return _M[_qp] * computeGradDFDCons(Residual);
97 }
98 
99 template <typename T>
102 {
103  RealGradient grad_value = _M[_qp] * computeGradDFDCons(Jacobian) +
104  _dMdc[_qp] * _phi[_j][_qp] * computeGradDFDCons(Residual);
105 
106  return grad_value;
107 }
108 
109 template <typename T>
110 Real
112 {
113  // get the coupled variable jvar is referring to
114  const unsigned int cvar = mapJvarToCvar(jvar);
115 
116  return (*_dMdarg[cvar])[_qp] * _phi[_j][_qp] * computeGradDFDCons(Residual) * _grad_test[_i][_qp];
117 }
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:111
virtual RealGradient precomputeQpJacobian()
Definition: CHBulk.h:101
const std::string name
Definition: Setup.h:20
void deprecateCoupledVar(const std::string &old_name, const std::string &new_name, const std::string &removal_date)
virtual RealGradient precomputeQpResidual()
Definition: CHBulk.h:94
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:87