www.mooseframework.org
MatReaction.C
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 #include "MatReaction.h"
11 
12 registerMooseObject("PhaseFieldApp", MatReaction);
13 
14 template <>
15 InputParameters
17 {
18  InputParameters params = validParams<Kernel>();
19  params.addCoupledVar("v",
20  "Set this to make v a coupled variable, otherwise it will use the "
21  "kernel's nonlinear variable for v");
22  params.addClassDescription("Kernel to add -L*v, where L=reaction rate, v=variable");
23  params.addParam<MaterialPropertyName>("mob_name", "L", "The reaction rate used with the kernel");
24  params.addCoupledVar("args", "Vector of nonlinear variable arguments this object depends on");
25  return params;
26 }
27 
28 MatReaction::MatReaction(const InputParameters & parameters)
29  : DerivativeMaterialInterface<JvarMapKernelInterface<Kernel>>(parameters),
30  _is_coupled(isCoupled("v")),
31  _v_name(_is_coupled ? getVar("v", 0)->name() : _var.name()),
32  _v(_is_coupled ? coupledValue("v") : _u),
33  _v_var(_is_coupled ? coupled("v") : _var.number()),
34  _L(getMaterialProperty<Real>("mob_name")),
35  _eta_name(_var.name()),
36  _dLdop(getMaterialPropertyDerivative<Real>("mob_name", _eta_name)),
37  _dLdv(getMaterialPropertyDerivative<Real>("mob_name", _v_name)),
38  _nvar(_coupled_moose_vars.size()),
39  _dLdarg(_nvar)
40 {
41  // Get reaction rate derivatives
42  for (unsigned int i = 0; i < _nvar; ++i)
43  {
44  MooseVariableFEBase * ivar = _coupled_moose_vars[i];
45  _dLdarg[i] = &getMaterialPropertyDerivative<Real>("mob_name", ivar->name());
46  }
47 }
48 
49 void
51 {
52  validateNonlinearCoupling<Real>("mob_name");
53 }
54 
55 Real
57 {
58  return -_L[_qp] * _test[_i][_qp] * _v[_qp];
59 }
60 
61 Real
63 {
64  if (_is_coupled)
65  return -_dLdop[_qp] * _v[_qp] * _phi[_j][_qp] * _test[_i][_qp];
66 
67  return -(_L[_qp] + _dLdop[_qp] * _v[_qp]) * _phi[_j][_qp] * _test[_i][_qp];
68 }
69 
70 Real
72 {
73  // first handle the case where jvar is a coupled variable v being added to residual
74  // the first term in the sum just multiplies by L which is always needed
75  // the second term accounts for cases where L depends on v
76  if ((jvar == _v_var) && _is_coupled)
77  return -(_L[_qp] + _dLdv[_qp] * _v[_qp]) * _test[_i][_qp] * _phi[_j][_qp];
78 
79  // for all other vars get the coupled variable jvar is referring to
80  const unsigned int cvar = mapJvarToCvar(jvar);
81 
82  return -(*_dLdarg[cvar])[_qp] * _v[_qp] * _test[_i][_qp] * _phi[_j][_qp];
83 }
MatReaction.h
MatReaction
This kernel adds to the residual a contribution of where is a material property and is a variable ...
Definition: MatReaction.h:26
MatReaction::computeQpJacobian
virtual Real computeQpJacobian()
Definition: MatReaction.C:62
MatReaction::_v_var
unsigned int _v_var
Definition: MatReaction.h:48
registerMooseObject
registerMooseObject("PhaseFieldApp", MatReaction)
MatReaction::_nvar
const unsigned int _nvar
number of coupled variables
Definition: MatReaction.h:63
MatReaction::_dLdv
const MaterialProperty< Real > & _dLdv
Reaction rate derivative w.r.t. the variable being added by this kernel.
Definition: MatReaction.h:60
MatReaction::initialSetup
virtual void initialSetup()
Definition: MatReaction.C:50
MatReaction::computeQpResidual
virtual Real computeQpResidual()
Definition: MatReaction.C:56
MatReaction::_dLdop
const MaterialProperty< Real > & _dLdop
Reaction rate derivative w.r.t. order parameter.
Definition: MatReaction.h:57
validParams< MatReaction >
InputParameters validParams< MatReaction >()
Definition: MatReaction.C:16
MatReaction::_dLdarg
std::vector< const MaterialProperty< Real > * > _dLdarg
Reaction rate derivatives w.r.t. other coupled variables.
Definition: MatReaction.h:66
MatReaction::MatReaction
MatReaction(const InputParameters &parameters)
Definition: MatReaction.C:28
name
const std::string name
Definition: Setup.h:21
MatReaction::_L
const MaterialProperty< Real > & _L
Reaction rate.
Definition: MatReaction.h:51
MatReaction::_v
const VariableValue & _v
Definition: MatReaction.h:47
MatReaction::computeQpOffDiagJacobian
virtual Real computeQpOffDiagJacobian(unsigned int jvar)
Definition: MatReaction.C:71
MatReaction::_is_coupled
const bool _is_coupled
is the kernel used in a coupled form?
Definition: MatReaction.h:38