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"
15 
23 template <typename T>
24 class ACBulk : public DerivativeMaterialInterface<JvarMapKernelInterface<KernelValue>>
25 {
26 public:
27  ACBulk(const InputParameters & parameters);
28 
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 
47 
50 
52  std::vector<const MaterialProperty<T> *> _dLdarg;
53 };
54 
55 template <typename T>
58  _L(getMaterialProperty<T>("mob_name")),
59  _dLdop(getMaterialPropertyDerivative<T>("mob_name", _var.name())),
60  _dLdarg(_n_args)
61 {
62  // Iterate over all coupled variables
63  for (unsigned int i = 0; i < _n_args; ++i)
64  _dLdarg[i] = &getMaterialPropertyDerivative<T>("mob_name", i);
65 }
66 
67 template <typename T>
70 {
72  params.addClassDescription("Allen-Cahn base Kernel");
73  params.addParam<MaterialPropertyName>("mob_name", "L", "The mobility used with the kernel");
74  return params;
75 }
76 
77 template <typename T>
78 void
80 {
81  validateNonlinearCoupling<Real>("mob_name");
82 }
83 
84 template <typename T>
85 Real
87 {
88  // Get free energy derivative from function
89  Real dFdop = computeDFDOP(Residual);
90 
91  // Set residual
92  return _L[_qp] * dFdop;
93 }
94 
95 template <typename T>
96 Real
98 {
99  // Get free energy derivative and Jacobian
100  Real dFdop = computeDFDOP(Residual);
101 
102  Real JdFdop = computeDFDOP(Jacobian);
103 
104  // Set Jacobian value using product rule
105  return _L[_qp] * JdFdop + _dLdop[_qp] * _phi[_j][_qp] * dFdop;
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  // Set off-diagonal Jacobian term from mobility derivatives
116  return (*_dLdarg[cvar])[_qp] * _phi[_j][_qp] * computeDFDOP(Residual) * _test[_i][_qp];
117 }
const MaterialProperty< T > & _L
Mobility.
Definition: ACBulk.h:46
void addParam(const std::string &name, const std::initializer_list< typename T::value_type > &value, const std::string &doc_string)
virtual void initialSetup()
Definition: ACBulk.h:79
ACBulk(const InputParameters &parameters)
Definition: ACBulk.h:56
This is the Allen-Cahn equation base class that implements the bulk or local energy term of the equat...
Definition: ACBulk.h:24
const std::string name
Definition: Setup.h:20
static InputParameters validParams()
virtual Real computeDFDOP(PFFunctionType type)=0
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
virtual Real computeQpOffDiagJacobian(unsigned int jvar)
Definition: ACBulk.h:110
std::vector< const MaterialProperty< T > * > _dLdarg
Mobility derivative w.r.t coupled variables.
Definition: ACBulk.h:52
void addClassDescription(const std::string &doc_string)
virtual Real precomputeQpJacobian()
Definition: ACBulk.h:97
virtual Real precomputeQpResidual()
Definition: ACBulk.h:86
static InputParameters validParams()
Definition: ACBulk.h:69
const MaterialProperty< T > & _dLdop
Mobility derivative w.r.t. order parameter.
Definition: ACBulk.h:49