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 "KKSACBulkC.h" 11 : 12 : registerMooseObject("PhaseFieldApp", KKSACBulkC); 13 : 14 : InputParameters 15 148 : KKSACBulkC::validParams() 16 : { 17 148 : InputParameters params = KKSACBulkBase::validParams(); 18 148 : params.addClassDescription("KKS model kernel (part 2 of 2) for the Bulk Allen-Cahn. This " 19 : "includes all terms dependent on chemical potential."); 20 296 : params.addRequiredCoupledVar("ca", "a-phase concentration"); 21 296 : params.addRequiredCoupledVar("cb", "b-phase concentration"); 22 148 : return params; 23 0 : } 24 : 25 78 : KKSACBulkC::KKSACBulkC(const InputParameters & parameters) 26 : : KKSACBulkBase(parameters), 27 78 : _ca_name(coupledName("ca", 0)), 28 78 : _ca_var(coupled("ca")), 29 78 : _ca(coupledValue("ca")), 30 78 : _cb_name(coupledName("cb", 0)), 31 78 : _cb_var(coupled("cb")), 32 78 : _cb(coupledValue("cb")), 33 78 : _prop_dFadca(getMaterialPropertyDerivative<Real>("fa_name", _ca_name)), 34 78 : _prop_d2Fadca2(getMaterialPropertyDerivative<Real>("fa_name", _ca_name, _ca_name)), 35 156 : _prop_d2Fadcadarg(_n_args) 36 : { 37 : // get second partial derivatives wrt ca and other coupled variable 38 252 : for (unsigned int i = 0; i < _n_args; ++i) 39 174 : _prop_d2Fadcadarg[i] = &getMaterialPropertyDerivative<Real>("fa_name", _ca_name, i); 40 78 : } 41 : 42 : Real 43 8374780 : KKSACBulkC::computeDFDOP(PFFunctionType type) 44 : { 45 8374780 : const Real A1 = _prop_dFadca[_qp] * (_ca[_qp] - _cb[_qp]); 46 8374780 : switch (type) 47 : { 48 7801180 : case Residual: 49 7801180 : return _prop_dh[_qp] * A1; 50 : 51 573600 : case Jacobian: 52 573600 : return _phi[_j][_qp] * _prop_d2h[_qp] * A1; 53 : } 54 : 55 0 : mooseError("Invalid type passed in"); 56 : } 57 : 58 : Real 59 6030400 : KKSACBulkC::computeQpOffDiagJacobian(unsigned int jvar) 60 : { 61 : // first get dependence of mobility _L on other variables using parent class 62 : // member function 63 6030400 : Real res = ACBulk<Real>::computeQpOffDiagJacobian(jvar); 64 : 65 : // Then add dependence of KKSACBulkF on other variables 66 : // Treat ca and cb specially, as they appear in the residual 67 6030400 : if (jvar == _ca_var) 68 3015200 : return res + _L[_qp] * _prop_dh[_qp] * 69 3015200 : ((_ca[_qp] - _cb[_qp]) * _prop_d2Fadca2[_qp] + _prop_dFadca[_qp]) * 70 3015200 : _phi[_j][_qp] * _test[_i][_qp]; 71 : 72 3015200 : if (jvar == _cb_var) 73 3015200 : return res - _L[_qp] * _prop_dh[_qp] * _prop_dFadca[_qp] * _phi[_j][_qp] * _test[_i][_qp]; 74 : 75 : // for all other vars get the coupled variable jvar is referring to 76 : const unsigned int cvar = mapJvarToCvar(jvar); 77 : 78 0 : res += _L[_qp] * _prop_dh[_qp] * (*_prop_d2Fadcadarg[cvar])[_qp] * (_ca[_qp] - _cb[_qp]) * 79 0 : _phi[_j][_qp] * _test[_i][_qp]; 80 : 81 0 : return res; 82 : }