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 "SplitCHParsed.h" 11 : 12 : registerMooseObject("PhaseFieldApp", SplitCHParsed); 13 : 14 : InputParameters 15 1003 : SplitCHParsed::validParams() 16 : { 17 1003 : InputParameters params = SplitCHCRes::validParams(); 18 1003 : params.addClassDescription( 19 : "Split formulation Cahn-Hilliard Kernel that uses a DerivativeMaterial Free Energy"); 20 2006 : params.addRequiredParam<MaterialPropertyName>( 21 : "f_name", "Base name of the free energy function F defined in a DerivativeParsedMaterial"); 22 2006 : params.addCoupledVar("coupled_variables", "Vector of additional variable arguments to F"); 23 : 24 1003 : return params; 25 0 : } 26 : 27 525 : SplitCHParsed::SplitCHParsed(const InputParameters & parameters) 28 : : DerivativeMaterialInterface<JvarMapKernelInterface<SplitCHCRes>>(parameters), 29 525 : _dFdc(getMaterialPropertyDerivative<Real>("f_name", _var.name())), 30 525 : _d2Fdc2(getMaterialPropertyDerivative<Real>("f_name", _var.name(), _var.name())), 31 1050 : _d2Fdcdarg(_n_args) 32 : { 33 : // Iterate over all coupled variables 34 1311 : for (unsigned int i = 0; i < _n_args; ++i) 35 786 : _d2Fdcdarg[i] = &getMaterialPropertyDerivative<Real>("f_name", _var.name(), i); 36 525 : } 37 : 38 : void 39 417 : SplitCHParsed::initialSetup() 40 : { 41 : /** 42 : * We are only interested if the necessary non-linear variables are coupled, 43 : * as those are thge ones used in constructing the Jacobian. The AuxVariables 44 : * do not have Jacobian entries. 45 : */ 46 1668 : validateNonlinearCoupling<Real>("f_name", _var.name()); 47 417 : validateDerivativeMaterialPropertyBase<Real>("f_name"); 48 417 : } 49 : 50 : Real 51 234378015 : SplitCHParsed::computeDFDC(PFFunctionType type) 52 : { 53 234378015 : switch (type) 54 : { 55 54209639 : case Residual: 56 54209639 : return _dFdc[_qp]; 57 : 58 180168376 : case Jacobian: 59 180168376 : return _d2Fdc2[_qp] * _phi[_j][_qp]; 60 : } 61 : 62 0 : mooseError("Internal error"); 63 : } 64 : 65 : Real 66 217761272 : SplitCHParsed::computeQpOffDiagJacobian(unsigned int jvar) 67 : { 68 217761272 : if (jvar == _w_var) 69 180168376 : return SplitCHCRes::computeQpOffDiagJacobian(jvar); 70 : 71 : // get the coupled variable jvar is referring to 72 : const unsigned int cvar = mapJvarToCvar(jvar); 73 : 74 37592896 : return (*_d2Fdcdarg[cvar])[_qp] * _phi[_j][_qp] * _test[_i][_qp]; 75 : }