https://mooseframework.inl.gov
SplitCHWResBase.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 "Kernel.h"
13 #include "JvarMapInterface.h"
15 
22 template <typename T>
23 class SplitCHWResBase : public DerivativeMaterialInterface<JvarMapKernelInterface<Kernel>>
24 {
25 public:
27 
29 
30 protected:
31  virtual Real computeQpResidual();
32  virtual Real computeQpJacobian();
33  virtual Real computeQpWJacobian();
34  virtual Real computeQpOffDiagJacobian(unsigned int jvar);
35 
36  const MaterialPropertyName _mob_name;
38 
40  const bool _is_coupled;
41 
43  unsigned int _w_var;
44 
47 
49  std::vector<const MaterialProperty<T> *> _dmobdarg;
50 };
51 
52 template <typename T>
55  _mob_name(getParam<MaterialPropertyName>("mob_name")),
56  _mob(getMaterialProperty<T>("mob_name")),
57  _is_coupled(isCoupled("w")),
58  _w_var(_is_coupled ? coupled("w") : _var.number()),
59  _grad_w(_is_coupled ? coupledGradient("w") : _grad_u),
60  _dmobdarg(_n_args)
61 {
62  // Iterate over all coupled variables
63  for (unsigned int i = 0; i < _n_args; ++i)
64  _dmobdarg[i] = &getMaterialPropertyDerivative<T>(_mob_name, i);
65 }
66 
67 template <typename T>
68 Real
70 {
71  return _mob[_qp] * _grad_w[_qp] * _grad_test[_i][_qp];
72 }
73 
74 template <typename T>
75 Real
77 {
78  return (_is_coupled && _w_var != _var.number()) ? 0.0 : computeQpWJacobian();
79 }
80 
81 template <typename T>
82 Real
84 {
85  return _mob[_qp] * _grad_phi[_j][_qp] * _grad_test[_i][_qp];
86 }
87 
88 template <typename T>
89 Real
91 {
92  // c Off-Diagonal Jacobian
93  if (_w_var == jvar)
94  return computeQpWJacobian();
95 
96  // get the coupled variable jvar is referring to
97  const unsigned int cvar = mapJvarToCvar(jvar);
98 
99  return (*_dmobdarg[cvar])[_qp] * _phi[_j][_qp] * _grad_w[_qp] * _grad_test[_i][_qp];
100 }
101 
102 template <typename T>
105 {
107  params.addClassDescription(
108  "Split formulation Cahn-Hilliard Kernel for the chemical potential variable");
109  params.addParam<MaterialPropertyName>("mob_name", "mobtemp", "The mobility used with the kernel");
110  params.addCoupledVar("args", "Vector of variable arguments of the mobility");
111  params.deprecateCoupledVar("args", "coupled_variables", "02/27/2024");
112  params.addCoupledVar(
113  "w", "Coupled chemical potential (if not specified kernel variable will be used)");
114  return params;
115 }
OutputTools< Real >::VariableGradient VariableGradient
static InputParameters validParams()
void addParam(const std::string &name, const std::initializer_list< typename T::value_type > &value, const std::string &doc_string)
SplitCHWResBase(const InputParameters &parameters)
virtual Real computeQpResidual()
SplitCHWresBase implements the residual for the chemical potential in the split form of the Cahn-Hill...
void deprecateCoupledVar(const std::string &old_name, const std::string &new_name, const std::string &removal_date)
const MaterialProperty< T > & _mob
virtual Real computeQpWJacobian()
static InputParameters validParams()
virtual Real computeQpJacobian()
void addCoupledVar(const std::string &name, const std::string &doc_string)
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
virtual Real computeQpOffDiagJacobian(unsigned int jvar)
const bool _is_coupled
is the kernel used in a coupled form?
void addClassDescription(const std::string &doc_string)
unsigned int _w_var
int label for the chemical potential
const MaterialPropertyName _mob_name
const VariableGradient & _grad_w
Variable value for the chemical potential.
std::vector< const MaterialProperty< T > * > _dmobdarg
derivatives of the mobility