www.mooseframework.org
MatGradSquareCoupled.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 "MatGradSquareCoupled.h"
11 
13 
14 template <>
15 InputParameters
17 {
18  InputParameters params = validParams<Kernel>();
19  params.addClassDescription("Gradient square of a coupled variable.");
20  params.addCoupledVar("elec_potential", "Electric potential");
21  params.addCoupledVar("args", "Vector of arguments to prefactor");
22  params.addParam<MaterialPropertyName>(
23  "prefactor",
24  "prefactor",
25  "Material property providing a prefactor of electric potential contribution");
26  return params;
27 }
28 
29 MatGradSquareCoupled::MatGradSquareCoupled(const InputParameters & parameters)
30  : DerivativeMaterialInterface<JvarMapKernelInterface<Kernel>>(parameters),
31  _grad_elec_potential(coupledGradient("elec_potential")),
32  _elec_potential_var(coupled("elec_potential")),
33  _prefactor(getMaterialProperty<Real>("prefactor")),
34  _dprefactor_dphi(getMaterialPropertyDerivative<Real>("prefactor", _var.name())),
35  _dprefactor_darg(_coupled_moose_vars.size())
36 {
37  for (unsigned int i = 0; i < _dprefactor_darg.size(); ++i)
38  _dprefactor_darg[i] =
39  &getMaterialPropertyDerivative<Real>("prefactor", _coupled_moose_vars[i]->name());
40 }
41 
42 void
44 {
45  validateNonlinearCoupling<Real>("prefactor");
46 }
47 
48 Real
50 {
51  return -_prefactor[_qp] * _grad_elec_potential[_qp] * _grad_elec_potential[_qp] * _test[_i][_qp];
52 }
53 
54 Real
56 {
58  _phi[_j][_qp] * _test[_i][_qp];
59 }
60 
61 Real
63 {
64  const unsigned int cvar = mapJvarToCvar(jvar);
65 
66  if (jvar == _elec_potential_var)
67  return -2 * _prefactor[_qp] * _grad_elec_potential[_qp] * _grad_phi[_j][_qp] * _test[_i][_qp] -
68  (*_dprefactor_darg[cvar])[_qp] * _grad_elec_potential[_qp] * _grad_elec_potential[_qp] *
69  _phi[_j][_qp] * _test[_i][_qp];
70 
71  return -(*_dprefactor_darg[cvar])[_qp] * _grad_elec_potential[_qp] * _grad_elec_potential[_qp] *
72  _phi[_j][_qp] * _test[_i][_qp];
73 }
MatGradSquareCoupled::_prefactor
const MaterialProperty< Real > & _prefactor
Definition: MatGradSquareCoupled.h:43
MatGradSquareCoupled
Definition: MatGradSquareCoupled.h:28
MatGradSquareCoupled::computeQpJacobian
virtual Real computeQpJacobian()
Definition: MatGradSquareCoupled.C:55
MatGradSquareCoupled::MatGradSquareCoupled
MatGradSquareCoupled(const InputParameters &parameters)
Definition: MatGradSquareCoupled.C:29
registerMooseObject
registerMooseObject("PhaseFieldApp", MatGradSquareCoupled)
name
const std::string name
Definition: Setup.h:21
MatGradSquareCoupled::_dprefactor_darg
std::vector< const MaterialProperty< Real > * > _dprefactor_darg
Definition: MatGradSquareCoupled.h:45
MatGradSquareCoupled::computeQpOffDiagJacobian
virtual Real computeQpOffDiagJacobian(unsigned int jvar)
Definition: MatGradSquareCoupled.C:62
MatGradSquareCoupled::initialSetup
virtual void initialSetup()
Definition: MatGradSquareCoupled.C:43
validParams< MatGradSquareCoupled >
InputParameters validParams< MatGradSquareCoupled >()
Definition: MatGradSquareCoupled.C:16
MatGradSquareCoupled::_elec_potential_var
const unsigned int _elec_potential_var
Definition: MatGradSquareCoupled.h:41
MatGradSquareCoupled::_dprefactor_dphi
const MaterialProperty< Real > & _dprefactor_dphi
Definition: MatGradSquareCoupled.h:44
MatGradSquareCoupled::computeQpResidual
virtual Real computeQpResidual()
Definition: MatGradSquareCoupled.C:49
MatGradSquareCoupled.h
MatGradSquareCoupled::_grad_elec_potential
const VariableGradient & _grad_elec_potential
Definition: MatGradSquareCoupled.h:40