https://mooseframework.inl.gov
Loading...
Searching...
No Matches
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
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
40void
42{
43 validateNonlinearCoupling<Real>("prefactor");
44}
45
46Real
48{
49 return -_prefactor[_qp] * _grad_elec_potential[_qp] * _grad_elec_potential[_qp] * _test[_i][_qp];
50}
51
52Real
54{
56 _phi[_j][_qp] * _test[_i][_qp];
57}
58
59Real
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
69 return -(*_dprefactor_darg[cvar])[_qp] * _grad_elec_potential[_qp] * _grad_elec_potential[_qp] *
70 _phi[_j][_qp] * _test[_i][_qp];
71}
registerMooseObject("PhaseFieldApp", MatGradSquareCoupled)
const std::string name
Definition Setup.h:21
void addParam(const std::string &name, const std::initializer_list< typename T::value_type > &value, const std::string &doc_string)
void addClassDescription(const std::string &doc_string)
void addCoupledVar(const std::string &name, const std::string &doc_string)
static InputParameters validParams()
virtual Real computeQpJacobian()
const MaterialProperty< Real > & _prefactor
MatGradSquareCoupled(const InputParameters &parameters)
const VariableGradient & _grad_elec_potential
std::vector< const MaterialProperty< Real > * > _dprefactor_darg
const unsigned int _elec_potential_var
virtual Real computeQpOffDiagJacobian(unsigned int jvar)
static InputParameters validParams()
const MaterialProperty< Real > & _dprefactor_dphi
virtual Real computeQpResidual()