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 "CHSplitFlux.h" 11 : 12 : registerMooseObject("PhaseFieldApp", CHSplitFlux); 13 : 14 : InputParameters 15 0 : CHSplitFlux::validParams() 16 : { 17 0 : InputParameters params = Kernel::validParams(); 18 0 : params.addClassDescription("Computes flux $j$ as nodal variable $j = -M\\nabla\\mu$"); 19 0 : params.addRequiredParam<unsigned int>("component", "Flux component"); 20 0 : params.addRequiredParam<MaterialPropertyName>("mobility_name", "Mobility property name"); 21 0 : params.addRequiredCoupledVar("mu", "Chemical Potential"); 22 0 : params.addCoupledVar("c", "Concentration"); 23 0 : return params; 24 0 : } 25 : 26 0 : CHSplitFlux::CHSplitFlux(const InputParameters & parameters) 27 : : DerivativeMaterialInterface<Kernel>(parameters), 28 0 : _component(getParam<unsigned int>("component")), 29 0 : _mu_var(coupled("mu")), 30 0 : _grad_mu(coupledGradient("mu")), 31 0 : _mobility(getMaterialProperty<RealTensorValue>("mobility_name")), 32 0 : _has_coupled_c(isCoupled("c")), 33 0 : _c_var(_has_coupled_c ? coupled("c") : 0), 34 0 : _dmobility_dc(_has_coupled_c ? &getMaterialPropertyDerivative<RealTensorValue>( 35 0 : "mobility_name", coupledName("c", 0)) 36 0 : : NULL) 37 : { 38 0 : } 39 : 40 : Real 41 0 : CHSplitFlux::computeQpResidual() 42 : { 43 0 : return _test[_i][_qp] * (_u[_qp] + _mobility[_qp].row(_component) * _grad_mu[_qp]); 44 : } 45 : 46 : Real 47 0 : CHSplitFlux::computeQpJacobian() 48 : { 49 0 : return _test[_i][_qp] * _phi[_j][_qp]; 50 : } 51 : 52 : Real 53 0 : CHSplitFlux::computeQpOffDiagJacobian(unsigned int jvar) 54 : { 55 0 : if (jvar == _mu_var) 56 0 : return _test[_i][_qp] * _mobility[_qp].row(_component) * _grad_phi[_j][_qp]; 57 0 : else if (_has_coupled_c && jvar == _c_var) 58 0 : return _test[_i][_qp] * (*_dmobility_dc)[_qp].row(_component) * _grad_mu[_qp] * _phi[_j][_qp]; 59 : else 60 : return 0.0; 61 : }