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