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 "KKSPhaseConcentration.h" 11 : 12 : registerMooseObject("PhaseFieldApp", KKSPhaseConcentration); 13 : 14 : InputParameters 15 148 : KKSPhaseConcentration::validParams() 16 : { 17 148 : InputParameters params = Kernel::validParams(); 18 148 : params.addClassDescription("KKS model kernel to enforce the decomposition of concentration into " 19 : "phase concentration $(1-h(\\eta))c_a + h(\\eta)c_b - c = 0$. The " 20 : "non-linear variable of this kernel is $c_b$."); 21 296 : params.addRequiredCoupledVar("ca", "Phase a concentration"); 22 296 : params.addRequiredCoupledVar("c", "Real concentration"); 23 296 : params.addRequiredCoupledVar("eta", "Phase a/b order parameter"); 24 296 : params.addParam<MaterialPropertyName>( 25 : "h_name", "h", "Base name for the switching function h(eta)"); 26 148 : return params; 27 0 : } 28 : 29 : // Phase interpolation func 30 78 : KKSPhaseConcentration::KKSPhaseConcentration(const InputParameters & parameters) 31 : : DerivativeMaterialInterface<Kernel>(parameters), 32 78 : _ca(coupledValue("ca")), 33 78 : _ca_var(coupled("ca")), 34 78 : _c(coupledValue("c")), 35 78 : _c_var(coupled("c")), 36 78 : _eta(coupledValue("eta")), 37 78 : _eta_var(coupled("eta")), 38 156 : _prop_h(getMaterialProperty<Real>("h_name")), 39 234 : _prop_dh(getMaterialPropertyDerivative<Real>("h_name", coupledName("eta", 0))) 40 : { 41 78 : } 42 : 43 : Real 44 5328160 : KKSPhaseConcentration::computeQpResidual() 45 : { 46 : // R = (1-h(eta))*ca + h(eta)*cb - c 47 5328160 : return _test[_i][_qp] * ((1.0 - _prop_h[_qp]) * _ca[_qp] + _prop_h[_qp] * _u[_qp] - _c[_qp]); 48 : } 49 : 50 : Real 51 3015200 : KKSPhaseConcentration::computeQpJacobian() 52 : { 53 3015200 : return _test[_i][_qp] * _prop_h[_qp] * _phi[_j][_qp]; 54 : } 55 : 56 : Real 57 11036800 : KKSPhaseConcentration::computeQpOffDiagJacobian(unsigned int jvar) 58 : { 59 11036800 : if (jvar == _ca_var) 60 3015200 : return _test[_i][_qp] * (1.0 - _prop_h[_qp]) * _phi[_j][_qp]; 61 : 62 8021600 : else if (jvar == _c_var) 63 3015200 : return -_test[_i][_qp] * _phi[_j][_qp]; 64 : 65 5006400 : else if (jvar == _eta_var) 66 3015200 : return _test[_i][_qp] * (_u[_qp] - _ca[_qp]) * _prop_dh[_qp] * _phi[_j][_qp]; 67 : 68 : return 0.0; 69 : }