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 "MechanicsBasePD.h" 11 : 12 : InputParameters 13 1139 : MechanicsBasePD::validParams() 14 : { 15 1139 : InputParameters params = PeridynamicsKernelBase::validParams(); 16 1139 : params.addClassDescription( 17 : "Base class for calculating the residual and Jacobian for the peridynamic mechanic kernels"); 18 : 19 2278 : params.addCoupledVar("temperature", "Nonlinear variable name for the temperature"); 20 2278 : params.addCoupledVar("out_of_plane_strain", 21 : "Nonlinear variable name for the out_of_plane strain for " 22 : "plane stress analysis using NOSPD formulation"); 23 : 24 1139 : return params; 25 0 : } 26 : 27 816 : MechanicsBasePD::MechanicsBasePD(const InputParameters & parameters) 28 : : DerivativeMaterialInterface<PeridynamicsKernelBase>(parameters), 29 816 : _temp_coupled(isCoupled("temperature")), 30 816 : _temp_var(_temp_coupled ? getVar("temperature", 0) : nullptr), 31 816 : _ndisp(coupledComponents("displacements")), 32 816 : _out_of_plane_strain_coupled(isCoupled("out_of_plane_strain")), 33 816 : _out_of_plane_strain_var(_out_of_plane_strain_coupled ? getVar("out_of_plane_strain", 0) 34 : : nullptr), 35 1632 : _orientation(nullptr) 36 : { 37 816 : if (_ndisp != _dim) 38 0 : mooseError("Number of displacements should be consistent with mesh dimension!"); 39 : 40 2508 : for (unsigned int i = 0; i < _ndisp; ++i) 41 3384 : _disp_var.push_back(getVar("displacements", i)); 42 816 : } 43 : 44 : void 45 816 : MechanicsBasePD::initialSetup() 46 : { 47 816 : _orientation = &_assembly.getFE(FEType(), 1)->get_dxyzdxi(); 48 816 : } 49 : 50 : void 51 6064446 : MechanicsBasePD::prepare() 52 : { 53 6064446 : PeridynamicsKernelBase::prepare(); 54 : 55 6064446 : _ivardofs.resize(_nnodes); 56 6064446 : _weights.resize(_nnodes); 57 18193338 : for (unsigned int nd = 0; nd < _nnodes; ++nd) 58 : { 59 12128892 : _ivardofs[nd] = _current_elem->node_ptr(nd)->dof_number(_sys.number(), _var.number(), 0); 60 12128892 : _weights[nd] = _pdmesh.getNeighborWeight( 61 12128892 : _current_elem->node_id(nd), 62 12128892 : _pdmesh.getNeighborIndex(_current_elem->node_id(nd), _current_elem->node_id(1 - nd))); 63 : } 64 : 65 18689028 : for (unsigned int i = 0; i < _dim; ++i) 66 12624582 : _current_vec(i) = _origin_vec(i) + _disp_var[i]->getNodalValue(*_current_elem->node_ptr(1)) - 67 12624582 : _disp_var[i]->getNodalValue(*_current_elem->node_ptr(0)); 68 : 69 6064446 : _current_unit_vec = _current_vec / _current_vec.norm(); 70 6064446 : } 71 : 72 : void 73 625953 : MechanicsBasePD::computeOffDiagJacobian(const unsigned int jvar_num) 74 : { 75 625953 : prepare(); 76 : 77 625953 : if (jvar_num == _var.number()) 78 293739 : computeJacobian(); 79 : else 80 : { 81 : unsigned int coupled_component = 0; 82 : bool active = false; 83 : 84 1006632 : for (unsigned int i = 0; i < _dim; ++i) 85 674418 : if (jvar_num == _disp_var[i]->number()) 86 : { 87 : coupled_component = i; 88 : active = true; 89 : } 90 : 91 332214 : if (_temp_coupled && jvar_num == _temp_var->number()) 92 : active = true; 93 : 94 332214 : if (_out_of_plane_strain_coupled && jvar_num == _out_of_plane_strain_var->number()) 95 : active = true; 96 : 97 318518 : if (active) 98 : { 99 329862 : prepareMatrixTag(_assembly, _var.number(), jvar_num); 100 329862 : computeLocalOffDiagJacobian(jvar_num, coupled_component); 101 329862 : accumulateTaggedLocalMatrix(); 102 : 103 329862 : if (_use_full_jacobian) 104 41742 : computePDNonlocalOffDiagJacobian(jvar_num, coupled_component); 105 : } 106 : } 107 625953 : }