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