https://mooseframework.inl.gov
MatGradSquareCoupled.C
Go to the documentation of this file.
1 //* This file is part of the MOOSE framework
2 //* https://mooseframework.inl.gov
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 
16 {
18  params.addClassDescription("Gradient square of a coupled variable.");
19  params.addCoupledVar("elec_potential", "Electric potential");
20  params.addCoupledVar("coupled_variables", "Vector of variable arguments to prefactor");
21  params.addParam<MaterialPropertyName>(
22  "prefactor",
23  "prefactor",
24  "Material property providing a prefactor of electric potential contribution");
25  return params;
26 }
27 
30  _grad_elec_potential(coupledGradient("elec_potential")),
31  _elec_potential_var(coupled("elec_potential")),
32  _prefactor(getMaterialProperty<Real>("prefactor")),
33  _dprefactor_dphi(getMaterialPropertyDerivative<Real>("prefactor", _var.name())),
34  _dprefactor_darg(_n_args)
35 {
36  for (unsigned int i = 0; i < _n_args; ++i)
37  _dprefactor_darg[i] = &getMaterialPropertyDerivative<Real>("prefactor", i);
38 }
39 
40 void
42 {
43  validateNonlinearCoupling<Real>("prefactor");
44 }
45 
46 Real
48 {
50 }
51 
52 Real
54 {
56  _phi[_j][_qp] * _test[_i][_qp];
57 }
58 
59 Real
61 {
62  const unsigned int cvar = mapJvarToCvar(jvar);
63 
64  if (jvar == _elec_potential_var)
65  return -2 * _prefactor[_qp] * _grad_elec_potential[_qp] * _grad_phi[_j][_qp] * _test[_i][_qp] -
67  _phi[_j][_qp] * _test[_i][_qp];
68 
70  _phi[_j][_qp] * _test[_i][_qp];
71 }
static InputParameters validParams()
void addParam(const std::string &name, const std::initializer_list< typename T::value_type > &value, const std::string &doc_string)
std::vector< const MaterialProperty< Real > * > _dprefactor_darg
const VariableGradient & _grad_elec_potential
virtual Real computeQpOffDiagJacobian(unsigned int jvar)
const MaterialProperty< Real > & _prefactor
virtual Real computeQpJacobian()
const std::string name
Definition: Setup.h:20
virtual Real computeQpResidual()
const unsigned int _elec_potential_var
const MaterialProperty< Real > & _dprefactor_dphi
void addCoupledVar(const std::string &name, const std::string &doc_string)
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
static InputParameters validParams()
void addClassDescription(const std::string &doc_string)
registerMooseObject("PhaseFieldApp", MatGradSquareCoupled)
MatGradSquareCoupled(const InputParameters &parameters)