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 "ACInterface2DMultiPhase1.h" 11 : 12 : registerMooseObject("PhaseFieldApp", ACInterface2DMultiPhase1); 13 : 14 : InputParameters 15 92 : ACInterface2DMultiPhase1::validParams() 16 : { 17 92 : InputParameters params = ACInterface::validParams(); 18 92 : params.addClassDescription( 19 : "Gradient energy Allen-Cahn Kernel where the derivative of interface parameter kappa " 20 : "wrt the gradient of order parameter is considered."); 21 184 : params.addParam<MaterialPropertyName>("dkappadgrad_etaa_name", 22 : "dkappadgrad_etaa", 23 : "The derivative of the kappa with respect to grad_etaa"); 24 184 : params.addParam<MaterialPropertyName>( 25 : "d2kappadgrad_etaa_name", 26 : "d2kappadgrad_etaa", 27 : "The second derivative of the kappa with respect to grad_etaa"); 28 184 : params.addRequiredCoupledVar( 29 : "etas", "All other coupled order parameters eta_i of the multiphase problem"); 30 92 : return params; 31 0 : } 32 : 33 48 : ACInterface2DMultiPhase1::ACInterface2DMultiPhase1(const InputParameters & parameters) 34 : : ACInterface(parameters), 35 48 : _dkappadgrad_etaa(getMaterialProperty<RealGradient>("dkappadgrad_etaa_name")), 36 96 : _d2kappadgrad_etaa(getMaterialProperty<RealTensorValue>("d2kappadgrad_etaa_name")), 37 48 : _num_etas(coupledComponents("etas")), 38 48 : _eta(_num_etas), 39 96 : _grad_eta(_num_etas) 40 : { 41 48 : } 42 : 43 : Real 44 14558400 : ACInterface2DMultiPhase1::sumSquareGradEta() 45 : { 46 : // get the sum of square of gradients of all order parameters 47 14558400 : Real SumSquareGradOp = _grad_u[_qp] * _grad_u[_qp]; 48 29116800 : for (unsigned int i = 0; i < _num_etas; ++i) 49 : { 50 14558400 : _grad_eta[i] = &coupledGradient("etas", i); 51 14558400 : SumSquareGradOp += (*_grad_eta[i])[_qp] * (*_grad_eta[i])[_qp]; 52 : } 53 14558400 : return SumSquareGradOp; 54 : } 55 : 56 : Real 57 3499200 : ACInterface2DMultiPhase1::computeQpResidual() 58 : { 59 3499200 : return 0.5 * nablaLPsi() * _dkappadgrad_etaa[_qp] * sumSquareGradEta(); 60 : } 61 : 62 : Real 63 2764800 : ACInterface2DMultiPhase1::computeQpJacobian() 64 : { 65 : // dsum is the derivative \f$ \frac\partial{\partial \eta} \left( \nabla (L\psi) \right) \f$ 66 2764800 : RealGradient dsum = _dLdop[_qp] * _phi[_j][_qp] * _grad_test[_i][_qp]; 67 : 68 : // compute the derivative of the gradient of the mobility 69 2764800 : if (_variable_L) 70 : { 71 : RealGradient dgradL = 72 2764800 : _grad_phi[_j][_qp] * _dLdop[_qp] + _grad_u[_qp] * _phi[_j][_qp] * _d2Ldop2[_qp]; 73 : 74 5529600 : for (unsigned int i = 0; i < _n_args; ++i) 75 2764800 : dgradL += (*_gradarg[i])[_qp] * _phi[_j][_qp] * (*_d2Ldargdop[i])[_qp]; 76 : 77 2764800 : dsum += dgradL * _test[_i][_qp]; 78 : } 79 2764800 : Real jac1 = 0.5 * dsum * _dkappadgrad_etaa[_qp] * sumSquareGradEta(); 80 : Real jac2 = 81 2764800 : 0.5 * nablaLPsi() * (_d2kappadgrad_etaa[_qp] * _grad_phi[_j][_qp]) * sumSquareGradEta(); 82 2764800 : Real jac3 = nablaLPsi() * _dkappadgrad_etaa[_qp] * _grad_u[_qp] * _grad_phi[_j][_qp]; 83 2764800 : return jac1 + jac2 + jac3; 84 : } 85 : 86 : Real 87 2764800 : ACInterface2DMultiPhase1::computeQpOffDiagJacobian(unsigned int jvar) 88 : { 89 : // get the coupled variable jvar is referring to 90 : const unsigned int cvar = mapJvarToCvar(jvar); 91 : 92 : // dsum is the derivative \f$ \frac\partial{\partial \eta} \left( \nabla (L\psi) \right) \f$ 93 2764800 : RealGradient dsum = (*_dLdarg[cvar])[_qp] * _phi[_j][_qp] * _grad_test[_i][_qp]; 94 : 95 : // compute the derivative of the gradient of the mobility 96 2764800 : if (_variable_L) 97 : { 98 2764800 : RealGradient dgradL = _grad_phi[_j][_qp] * (*_dLdarg[cvar])[_qp] + 99 2764800 : _grad_u[_qp] * _phi[_j][_qp] * (*_d2Ldargdop[cvar])[_qp]; 100 : 101 5529600 : for (unsigned int i = 0; i < _n_args; ++i) 102 2764800 : dgradL += (*_gradarg[i])[_qp] * _phi[_j][_qp] * (*_d2Ldarg2[cvar][i])[_qp]; 103 : 104 2764800 : dsum += dgradL * _test[_i][_qp]; 105 : } 106 : 107 : // the gradient of coupled variable etab 108 2764800 : _grad_eta[0] = &coupledGradient("etas", 0); 109 : 110 2764800 : Real jac1 = 0.5 * dsum * _dkappadgrad_etaa[_qp] * sumSquareGradEta(); 111 : Real jac2 = 112 2764800 : -0.5 * nablaLPsi() * (_d2kappadgrad_etaa[_qp] * _grad_phi[_j][_qp]) * sumSquareGradEta(); 113 2764800 : Real jac3 = nablaLPsi() * _dkappadgrad_etaa[_qp] * (*_grad_eta[0])[_qp] * _grad_phi[_j][_qp]; 114 2764800 : return jac1 + jac2 + jac3; 115 : }