www.mooseframework.org
ACBulk.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 "KernelValue.h"
13 #include "JvarMapInterface.h"
14 #include "DerivativeMaterialInterface.h"
15 
23 template <typename T>
24 class ACBulk : public DerivativeMaterialInterface<JvarMapKernelInterface<KernelValue>>
25 {
26 public:
27  ACBulk(const InputParameters & parameters);
28 
29  static InputParameters validParams();
30  virtual void initialSetup();
31 
32 protected:
33  virtual Real precomputeQpResidual();
34  virtual Real precomputeQpJacobian();
35  virtual Real computeQpOffDiagJacobian(unsigned int jvar);
36 
38  {
41  };
42 
43  virtual Real computeDFDOP(PFFunctionType type) = 0;
44 
46  const MaterialProperty<T> & _L;
47 
49  const MaterialProperty<T> & _dLdop;
50 
52  std::vector<const MaterialProperty<T> *> _dLdarg;
53 };
54 
55 template <typename T>
56 ACBulk<T>::ACBulk(const InputParameters & parameters)
57  : DerivativeMaterialInterface<JvarMapKernelInterface<KernelValue>>(parameters),
58  _L(getMaterialProperty<T>("mob_name")),
59  _dLdop(getMaterialPropertyDerivative<T>("mob_name", _var.name()))
60 {
61  // Get number of coupled variables
62  unsigned int nvar = _coupled_moose_vars.size();
63 
64  // reserve space for derivatives
65  _dLdarg.resize(nvar);
66 
67  // Iterate over all coupled variables
68  for (unsigned int i = 0; i < nvar; ++i)
69  _dLdarg[i] = &getMaterialPropertyDerivative<T>("mob_name", _coupled_moose_vars[i]->name());
70 }
71 
72 template <typename T>
73 InputParameters
75 {
76  InputParameters params = ::validParams<KernelValue>();
77  params.addClassDescription("Allen-Cahn base Kernel");
78  params.addParam<MaterialPropertyName>("mob_name", "L", "The mobility used with the kernel");
79  params.addCoupledVar("args", "Vector of arguments of the mobility");
80  return params;
81 }
82 
83 template <typename T>
84 void
86 {
87  validateNonlinearCoupling<Real>("mob_name");
88 }
89 
90 template <typename T>
91 Real
93 {
94  // Get free energy derivative from function
95  Real dFdop = computeDFDOP(Residual);
96 
97  // Set residual
98  return _L[_qp] * dFdop;
99 }
100 
101 template <typename T>
102 Real
104 {
105  // Get free energy derivative and Jacobian
106  Real dFdop = computeDFDOP(Residual);
107 
108  Real JdFdop = computeDFDOP(Jacobian);
109 
110  // Set Jacobian value using product rule
111  return _L[_qp] * JdFdop + _dLdop[_qp] * _phi[_j][_qp] * dFdop;
112 }
113 
114 template <typename T>
115 Real
117 {
118  // Get the coupled variable jvar is referring to
119  const unsigned int cvar = mapJvarToCvar(jvar);
120 
121  // Set off-diagonal Jacobian term from mobility derivatives
122  return (*_dLdarg[cvar])[_qp] * _phi[_j][_qp] * computeDFDOP(Residual) * _test[_i][_qp];
123 }
124 
ACBulk::Residual
Definition: ACBulk.h:40
ACBulk::ACBulk
ACBulk(const InputParameters &parameters)
Definition: ACBulk.h:56
ACBulk::computeQpOffDiagJacobian
virtual Real computeQpOffDiagJacobian(unsigned int jvar)
Definition: ACBulk.h:116
ACBulk
This is the Allen-Cahn equation base class that implements the bulk or local energy term of the equat...
Definition: ACBulk.h:24
ACBulk::_dLdarg
std::vector< const MaterialProperty< T > * > _dLdarg
Mobility derivative w.r.t coupled variables.
Definition: ACBulk.h:52
ACBulk::_dLdop
const MaterialProperty< T > & _dLdop
Mobility derivative w.r.t. order parameter.
Definition: ACBulk.h:49
ACBulk::computeDFDOP
virtual Real computeDFDOP(PFFunctionType type)=0
name
const std::string name
Definition: Setup.h:21
ACBulk::initialSetup
virtual void initialSetup()
Definition: ACBulk.h:85
ACBulk::Jacobian
Definition: ACBulk.h:39
ACBulk::precomputeQpResidual
virtual Real precomputeQpResidual()
Definition: ACBulk.h:92
ACBulk::validParams
static InputParameters validParams()
Definition: ACBulk.h:74
ACBulk::precomputeQpJacobian
virtual Real precomputeQpJacobian()
Definition: ACBulk.h:103
ACBulk::_L
const MaterialProperty< T > & _L
Mobility.
Definition: ACBulk.h:46
ACBulk< Real >::PFFunctionType
PFFunctionType
Definition: ACBulk.h:37