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 "CZMInterfaceKernelBase.h" 11 : 12 : InputParameters 13 1933 : CZMInterfaceKernelBase::validParams() 14 : { 15 1933 : InputParameters params = InterfaceKernel::validParams(); 16 3866 : params.addRequiredParam<unsigned int>("component", 17 : "the component of the " 18 : "displacement vector this kernel is working on:" 19 : " component == 0, ==> X" 20 : " component == 1, ==> Y" 21 : " component == 2, ==> Z"); 22 1933 : params.suppressParameter<bool>("use_displaced_mesh"); 23 3866 : params.addRequiredCoupledVar("displacements", "the string containing displacement variables"); 24 3866 : params.addParam<std::string>("base_name", "Material property base name"); 25 1933 : params.set<std::string>("traction_global_name") = "traction_global"; 26 : 27 1933 : return params; 28 0 : } 29 : 30 574 : CZMInterfaceKernelBase::CZMInterfaceKernelBase(const InputParameters & parameters) 31 : : JvarMapKernelInterface<InterfaceKernel>(parameters), 32 2058 : _base_name(isParamValid("base_name") && !getParam<std::string>("base_name").empty() 33 574 : ? getParam<std::string>("base_name") + "_" 34 : : ""), 35 1148 : _component(getParam<unsigned int>("component")), 36 574 : _ndisp(coupledComponents("displacements")), 37 574 : _disp_var(_ndisp), 38 574 : _disp_neighbor_var(_ndisp), 39 574 : _vars(_ndisp), 40 574 : _traction_global(getMaterialPropertyByName<RealVectorValue>( 41 1148 : _base_name + getParam<std::string>("traction_global_name"))), 42 574 : _dtraction_djump_global( 43 1148 : getMaterialPropertyByName<RankTwoTensor>(_base_name + "dtraction_djump_global")) 44 : { 45 : // Enforce consistency 46 574 : if (_ndisp != _mesh.dimension()) 47 0 : paramError("displacements", "Number of displacements must match problem dimension."); 48 : 49 574 : if (_ndisp > 3 || _ndisp < 1) 50 0 : mooseError("the CZM material requires 1, 2 or 3 displacement variables"); 51 : 52 2170 : for (unsigned int i = 0; i < _ndisp; ++i) 53 : { 54 1596 : _disp_var[i] = coupled("displacements", i); 55 1596 : _disp_neighbor_var[i] = coupled("displacements", i); 56 1596 : _vars[i] = getVar("displacements", i); 57 : } 58 574 : } 59 : 60 : Real 61 2040672 : CZMInterfaceKernelBase::computeQpResidual(Moose::DGResidualType type) 62 : { 63 2040672 : Real r = _traction_global[_qp](_component); 64 : 65 2040672 : switch (type) 66 : { 67 : // [test_secondary-test_primary]*T where T represents the traction. 68 1020336 : case Moose::Element: 69 1020336 : r *= -_test[_i][_qp]; 70 1020336 : break; 71 1020336 : case Moose::Neighbor: 72 1020336 : r *= _test_neighbor[_i][_qp]; 73 1020336 : break; 74 : } 75 2040672 : return r; 76 : } 77 : 78 : Real 79 24324800 : CZMInterfaceKernelBase::computeQpJacobian(Moose::DGJacobianType type) 80 : { 81 : // retrieve the diagonal Jacobian coefficient dependning on the displacement 82 : // component (_component) this kernel is working on 83 24324800 : return computeDResidualDDisplacement(_component, type); 84 : } 85 : 86 : Real 87 48298496 : CZMInterfaceKernelBase::computeQpOffDiagJacobian(Moose::DGJacobianType type, unsigned int jvar) 88 : { 89 : // bail out if jvar is not coupled 90 48298496 : if (getJvarMap()[jvar] < 0) 91 : return 0.0; 92 : 93 : // Jacobian of the residul[_component] w.r.t to the coupled displacement 94 : // component[off_diag_component] 95 96421632 : for (unsigned int off_diag_component = 0; off_diag_component < _ndisp; ++off_diag_component) 96 : { 97 96421632 : if (jvar == _disp_var[off_diag_component]) 98 48298496 : return computeDResidualDDisplacement(off_diag_component, type); 99 : } 100 : // this is the place where one should implement derivatives of the residual w.r.t. other variables 101 0 : return 0.0; 102 : }