Line data Source code
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 "SusceptibilityTimeDerivative.h" 11 : 12 : registerMooseObject("PhaseFieldApp", SusceptibilityTimeDerivative); 13 : registerMooseObject("PhaseFieldApp", ADSusceptibilityTimeDerivative); 14 : 15 : template <bool is_ad> 16 : InputParameters 17 181 : SusceptibilityTimeDerivativeTempl<is_ad>::validParams() 18 : { 19 181 : InputParameters params = SusceptibilityTimeDerivativeBase<is_ad>::validParams(); 20 181 : params.addClassDescription( 21 : "A modified time derivative Kernel that multiplies the time derivative " 22 : "of a variable by a generalized susceptibility"); 23 362 : params.addRequiredParam<MaterialPropertyName>( 24 : "f_name", "Susceptibility function F defined in a FunctionMaterial"); 25 362 : params.addCoupledVar("coupled_variables", "Vector of variable arguments of the susceptibility"); 26 181 : return params; 27 0 : } 28 : 29 : template <bool is_ad> 30 97 : SusceptibilityTimeDerivativeTempl<is_ad>::SusceptibilityTimeDerivativeTempl( 31 : const InputParameters & parameters) 32 : : DerivativeMaterialInterface<JvarMapKernelInterface<SusceptibilityTimeDerivativeBase<is_ad>>>( 33 : parameters), 34 194 : _Chi(this->template getGenericMaterialProperty<Real, is_ad>("f_name")) 35 : { 36 97 : } 37 : 38 77 : SusceptibilityTimeDerivative::SusceptibilityTimeDerivative(const InputParameters & parameters) 39 : : SusceptibilityTimeDerivativeTempl<false>(parameters), 40 77 : _dChidu(getMaterialPropertyDerivative<Real>("f_name", _var.name())), 41 154 : _dChidarg(_n_args) 42 : { 43 : // fetch derivatives 44 209 : for (unsigned int i = 0; i < _n_args; ++i) 45 132 : _dChidarg[i] = &getMaterialPropertyDerivative<Real>("f_name", i); 46 77 : } 47 : 48 : void 49 56 : SusceptibilityTimeDerivative::initialSetup() 50 : { 51 168 : validateNonlinearCoupling<Real>("f_name"); 52 56 : } 53 : 54 : Real 55 3173664 : SusceptibilityTimeDerivative::computeQpResidual() 56 : { 57 3173664 : return TimeDerivative::computeQpResidual() * _Chi[_qp]; 58 : } 59 : 60 : ADReal 61 145340 : ADSusceptibilityTimeDerivative::precomputeQpResidual() 62 : { 63 145340 : return _u_dot[_qp] * _Chi[_qp]; 64 : } 65 : 66 : Real 67 3824672 : SusceptibilityTimeDerivative::computeQpJacobian() 68 : { 69 3824672 : return TimeDerivative::computeQpJacobian() * _Chi[_qp] + 70 3824672 : TimeDerivative::computeQpResidual() * _dChidu[_qp] * _phi[_j][_qp]; 71 : } 72 : 73 : Real 74 1342400 : SusceptibilityTimeDerivative::computeQpOffDiagJacobian(unsigned int jvar) 75 : { 76 : // get the coupled variable jvar is referring to 77 : const unsigned int cvar = mapJvarToCvar(jvar); 78 : 79 1342400 : return TimeDerivative::computeQpResidual() * (*_dChidarg[cvar])[_qp] * _phi[_j][_qp]; 80 : }