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 "CoupledAllenCahn.h" 11 : 12 : registerMooseObject("PhaseFieldApp", CoupledAllenCahn); 13 : 14 : InputParameters 15 69 : CoupledAllenCahn::validParams() 16 : { 17 69 : InputParameters params = ACBulk<Real>::validParams(); 18 69 : params.addClassDescription( 19 : "Coupled Allen-Cahn Kernel that uses a DerivativeMaterial Free Energy"); 20 138 : params.addRequiredCoupledVar("v", "Coupled variable"); 21 138 : params.addRequiredParam<MaterialPropertyName>( 22 : "f_name", "Base name of the free energy function F defined in a DerivativeParsedMaterial"); 23 69 : return params; 24 0 : } 25 : 26 36 : CoupledAllenCahn::CoupledAllenCahn(const InputParameters & parameters) 27 : : ACBulk<Real>(parameters), 28 36 : _v_name(coupledName("v", 0)), 29 36 : _dFdV(getMaterialPropertyDerivative<Real>("f_name", _v_name)), 30 36 : _d2FdVdEta(getMaterialPropertyDerivative<Real>("f_name", _v_name, _var.name())), 31 72 : _d2FdVdarg(_n_args) 32 : { 33 : // Iterate over all coupled variables 34 72 : for (unsigned int i = 0; i < _n_args; ++i) 35 36 : _d2FdVdarg[i] = &getMaterialPropertyDerivative<Real>("f_name", _v_name, i); 36 36 : } 37 : 38 : void 39 36 : CoupledAllenCahn::initialSetup() 40 : { 41 36 : ACBulk<Real>::initialSetup(); 42 108 : validateNonlinearCoupling<Real>("f_name"); 43 36 : } 44 : 45 : Real 46 4004500 : CoupledAllenCahn::computeDFDOP(PFFunctionType type) 47 : { 48 4004500 : switch (type) 49 : { 50 3475700 : case Residual: 51 3475700 : return _dFdV[_qp]; 52 : 53 528800 : case Jacobian: 54 528800 : return _d2FdVdEta[_qp] * _phi[_j][_qp]; 55 : } 56 : 57 0 : mooseError("Internal error"); 58 : } 59 : 60 : Real 61 2115200 : CoupledAllenCahn::computeQpOffDiagJacobian(unsigned int jvar) 62 : { 63 : // get the coupled variable jvar is referring to 64 : const unsigned int cvar = mapJvarToCvar(jvar); 65 : 66 2115200 : return ACBulk<Real>::computeQpOffDiagJacobian(jvar) + 67 2115200 : _L[_qp] * (*_d2FdVdarg[cvar])[_qp] * _phi[_j][_qp] * _test[_i][_qp]; 68 : }