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 1135 : MechanicsBasePD::validParams() 14 : { 15 1135 : InputParameters params = PeridynamicsKernelBase::validParams(); 16 1135 : params.addClassDescription( 17 : "Base class for calculating the residual and Jacobian for the peridynamic mechanic kernels"); 18 : 19 2270 : params.addCoupledVar("temperature", "Nonlinear variable name for the temperature"); 20 2270 : 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 1135 : return params; 25 0 : } 26 : 27 813 : MechanicsBasePD::MechanicsBasePD(const InputParameters & parameters) 28 : : DerivativeMaterialInterface<PeridynamicsKernelBase>(parameters), 29 813 : _temp_coupled(isCoupled("temperature")), 30 813 : _temp_var(_temp_coupled ? getVar("temperature", 0) : nullptr), 31 813 : _ndisp(coupledComponents("displacements")), 32 813 : _out_of_plane_strain_coupled(isCoupled("out_of_plane_strain")), 33 813 : _out_of_plane_strain_var(_out_of_plane_strain_coupled ? getVar("out_of_plane_strain", 0) 34 : : nullptr), 35 1626 : _orientation(nullptr) 36 : { 37 813 : if (_ndisp != _dim) 38 0 : mooseError("Number of displacements should be consistent with mesh dimension!"); 39 : 40 2496 : for (unsigned int i = 0; i < _ndisp; ++i) 41 3366 : _disp_var.push_back(getVar("displacements", i)); 42 813 : } 43 : 44 : void 45 813 : MechanicsBasePD::initialSetup() 46 : { 47 813 : _orientation = &_assembly.getFE(FEType(), 1)->get_dxyzdxi(); 48 813 : } 49 : 50 : void 51 6012723 : MechanicsBasePD::prepare() 52 : { 53 6012723 : PeridynamicsKernelBase::prepare(); 54 : 55 6012723 : _ivardofs.resize(_nnodes); 56 6012723 : _weights.resize(_nnodes); 57 18038169 : for (unsigned int nd = 0; nd < _nnodes; ++nd) 58 : { 59 12025446 : _ivardofs[nd] = _current_elem->node_ptr(nd)->dof_number(_sys.number(), _var.number(), 0); 60 12025446 : _weights[nd] = _pdmesh.getNeighborWeight( 61 12025446 : _current_elem->node_id(nd), 62 12025446 : _pdmesh.getNeighborIndex(_current_elem->node_id(nd), _current_elem->node_id(1 - nd))); 63 : } 64 : 65 18484464 : for (unsigned int i = 0; i < _dim; ++i) 66 12471741 : _current_vec(i) = _origin_vec(i) + _disp_var[i]->getNodalValue(*_current_elem->node_ptr(1)) - 67 12471741 : _disp_var[i]->getNodalValue(*_current_elem->node_ptr(0)); 68 : 69 6012723 : _current_unit_vec = _current_vec / _current_vec.norm(); 70 6012723 : } 71 : 72 : void 73 624288 : MechanicsBasePD::computeOffDiagJacobian(const unsigned int jvar_num) 74 : { 75 624288 : prepare(); 76 : 77 624288 : if (jvar_num == _var.number()) 78 293184 : computeJacobian(); 79 : else 80 : { 81 : unsigned int coupled_component = 0; 82 : bool active = false; 83 : 84 1002192 : for (unsigned int i = 0; i < _dim; ++i) 85 671088 : if (jvar_num == _disp_var[i]->number()) 86 : { 87 : coupled_component = i; 88 : active = true; 89 : } 90 : 91 331104 : if (_temp_coupled && jvar_num == _temp_var->number()) 92 : active = true; 93 : 94 331104 : if (_out_of_plane_strain_coupled && jvar_num == _out_of_plane_strain_var->number()) 95 : active = true; 96 : 97 317408 : if (active) 98 : { 99 328752 : prepareMatrixTag(_assembly, _var.number(), jvar_num); 100 328752 : computeLocalOffDiagJacobian(jvar_num, coupled_component); 101 328752 : accumulateTaggedLocalMatrix(); 102 : 103 328752 : if (_use_full_jacobian) 104 40632 : computePDNonlocalOffDiagJacobian(jvar_num, coupled_component); 105 : } 106 : } 107 624288 : }