www.mooseframework.org
CoupledMaterialDerivative.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 
11 
13 
14 template <>
15 InputParameters
17 {
18  InputParameters params = validParams<Kernel>();
19  params.addClassDescription("Kernel that implements the first derivative of a function material "
20  "property with respect to a coupled variable.");
21  params.addRequiredCoupledVar("v", "Variable to take the derivative with respect to");
22  params.addParam<MaterialPropertyName>("f_name",
23  "F",
24  "Function material to take the derivative of (should "
25  "provide derivative properties - such as a "
26  "DerivativeParsedMaterial)");
27  params.addCoupledVar(
28  "args",
29  "Vector of other nonlinear variables F depends on (used for computing Jacobian entries)");
30  return params;
31 }
32 
33 CoupledMaterialDerivative::CoupledMaterialDerivative(const InputParameters & parameters)
34  : DerivativeMaterialInterface<JvarMapKernelInterface<Kernel>>(parameters),
35  _v_name(getVar("v", 0)->name()),
36  _v_var(coupled("v")),
37  _dFdv(getMaterialPropertyDerivative<Real>("f_name", _v_name)),
38  _d2Fdvdu(getMaterialPropertyDerivative<Real>("f_name", _v_name, _var.name())),
39  _nvar(_coupled_moose_vars.size()),
40  _d2Fdvdarg(_nvar)
41 {
42  // Get material property derivatives for all coupled variables
43  for (unsigned int i = 0; i < _nvar; ++i)
44  {
45  MooseVariableFEBase * ivar = _coupled_moose_vars[i];
46  _d2Fdvdarg[i] = &getMaterialPropertyDerivative<Real>("f_name", _v_name, ivar->name());
47  }
48 }
49 
50 void
52 {
53  validateNonlinearCoupling<Real>("f_name");
54 }
55 
56 Real
58 {
59  return _dFdv[_qp] * _test[_i][_qp];
60 }
61 
62 Real
64 {
65  return _d2Fdvdu[_qp] * _test[_i][_qp] * _phi[_j][_qp];
66 }
67 
68 Real
70 {
71  const unsigned int cvar = mapJvarToCvar(jvar);
72  return (*_d2Fdvdarg[cvar])[_qp] * _test[_i][_qp] * _phi[_j][_qp];
73 }
CoupledMaterialDerivative::CoupledMaterialDerivative
CoupledMaterialDerivative(const InputParameters &parameters)
Definition: CoupledMaterialDerivative.C:33
CoupledMaterialDerivative::initialSetup
virtual void initialSetup() override
Definition: CoupledMaterialDerivative.C:51
CoupledMaterialDerivative::_d2Fdvdarg
std::vector< const MaterialProperty< Real > * > _d2Fdvdarg
2nd order material property derivatives w.r.t. v and then all other coupled variables
Definition: CoupledMaterialDerivative.h:50
CoupledMaterialDerivative.h
CoupledMaterialDerivative::_v_name
std::string _v_name
name of the coupled variable the derivative is taken with respect to
Definition: CoupledMaterialDerivative.h:37
CoupledMaterialDerivative::_dFdv
const MaterialProperty< Real > & _dFdv
Material property derivative w.r.t. v.
Definition: CoupledMaterialDerivative.h:41
CoupledMaterialDerivative::_nvar
const unsigned int _nvar
Number of coupled variables.
Definition: CoupledMaterialDerivative.h:47
CoupledMaterialDerivative::computeQpJacobian
virtual Real computeQpJacobian() override
Definition: CoupledMaterialDerivative.C:63
CoupledMaterialDerivative
This kernel adds the term (dFdv, test), where v is a coupled variable.
Definition: CoupledMaterialDerivative.h:25
name
const std::string name
Definition: Setup.h:21
CoupledMaterialDerivative::computeQpOffDiagJacobian
virtual Real computeQpOffDiagJacobian(unsigned int jvar) override
Definition: CoupledMaterialDerivative.C:69
CoupledMaterialDerivative::computeQpResidual
virtual Real computeQpResidual() override
Definition: CoupledMaterialDerivative.C:57
validParams< CoupledMaterialDerivative >
InputParameters validParams< CoupledMaterialDerivative >()
Definition: CoupledMaterialDerivative.C:16
CoupledMaterialDerivative::_d2Fdvdu
const MaterialProperty< Real > & _d2Fdvdu
2nd order material property derivative w.r.t. v then u
Definition: CoupledMaterialDerivative.h:44
registerMooseObject
registerMooseObject("PhaseFieldApp", CoupledMaterialDerivative)