https://mooseframework.inl.gov
MechanicsBasePD.C
Go to the documentation of this file.
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 
14 {
16  params.addClassDescription(
17  "Base class for calculating the residual and Jacobian for the peridynamic mechanic kernels");
18 
19  params.addCoupledVar("temperature", "Nonlinear variable name for the temperature");
20  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  return params;
25 }
26 
29  _temp_coupled(isCoupled("temperature")),
30  _temp_var(_temp_coupled ? getVar("temperature", 0) : nullptr),
31  _ndisp(coupledComponents("displacements")),
32  _out_of_plane_strain_coupled(isCoupled("out_of_plane_strain")),
33  _out_of_plane_strain_var(_out_of_plane_strain_coupled ? getVar("out_of_plane_strain", 0)
34  : nullptr),
35  _orientation(nullptr)
36 {
37  if (_ndisp != _dim)
38  mooseError("Number of displacements should be consistent with mesh dimension!");
39 
40  for (unsigned int i = 0; i < _ndisp; ++i)
41  _disp_var.push_back(getVar("displacements", i));
42 }
43 
44 void
46 {
47  _orientation = &_assembly.getFE(FEType(), 1)->get_dxyzdxi();
48 }
49 
50 void
52 {
54 
55  _ivardofs.resize(_nnodes);
56  _weights.resize(_nnodes);
57  for (unsigned int nd = 0; nd < _nnodes; ++nd)
58  {
59  _ivardofs[nd] = _current_elem->node_ptr(nd)->dof_number(_sys.number(), _var.number(), 0);
60  _weights[nd] = _pdmesh.getNeighborWeight(
61  _current_elem->node_id(nd),
62  _pdmesh.getNeighborIndex(_current_elem->node_id(nd), _current_elem->node_id(1 - nd)));
63  }
64 
65  for (unsigned int i = 0; i < _dim; ++i)
66  _current_vec(i) = _origin_vec(i) + _disp_var[i]->getNodalValue(*_current_elem->node_ptr(1)) -
67  _disp_var[i]->getNodalValue(*_current_elem->node_ptr(0));
68 
70 }
71 
72 void
73 MechanicsBasePD::computeOffDiagJacobian(const unsigned int jvar_num)
74 {
75  prepare();
76 
77  if (jvar_num == _var.number())
78  computeJacobian();
79  else
80  {
81  unsigned int coupled_component = 0;
82  bool active = false;
83 
84  for (unsigned int i = 0; i < _dim; ++i)
85  if (jvar_num == _disp_var[i]->number())
86  {
87  coupled_component = i;
88  active = true;
89  }
90 
91  if (_temp_coupled && jvar_num == _temp_var->number())
92  active = true;
93 
95  active = true;
96 
97  if (active)
98  {
99  prepareMatrixTag(_assembly, _var.number(), jvar_num);
100  computeLocalOffDiagJacobian(jvar_num, coupled_component);
101  accumulateTaggedLocalMatrix();
102 
103  if (_use_full_jacobian)
104  computePDNonlocalOffDiagJacobian(jvar_num, coupled_component);
105  }
106  }
107 }
Base kernel class for peridynamic models.
const bool _temp_coupled
Temperature variable.
auto norm() const -> decltype(std::norm(Real()))
void mooseError(Args &&... args)
unsigned int number() const
static InputParameters validParams()
virtual void computeLocalOffDiagJacobian(unsigned int, unsigned int)
Function to compute local contribution to the off-diagonal Jacobian at the current nodes...
RealGradient _current_unit_vec
Unit vector of bond in current configuration.
MechanicsBasePD(const InputParameters &parameters)
const bool _out_of_plane_strain_coupled
Parameters for out-of-plane strain in weak plane stress formulation.
unsigned int _ndisp
number of displacement components
std::vector< Real > _weights
weights used for the current element to obtain the nodal stress
std::vector< MooseVariable * > _disp_var
displacement variables
RealGradient _current_vec
Vector of bond in current configuration.
virtual void initialSetup() override
virtual void computeOffDiagJacobian(unsigned int jvar) override
virtual void prepare() override
static InputParameters validParams()
MooseVariable * _out_of_plane_strain_var
std::vector< dof_id_type > _ivardofs
Current variable dof numbers for nodes i and j.
void addCoupledVar(const std::string &name, const std::string &doc_string)
virtual void prepare()
Function to precalculate data which will be used in the derived classes.
const std::vector< RealGradient > * _orientation
Vector of bond in current configuration.
void addClassDescription(const std::string &doc_string)
virtual void computePDNonlocalOffDiagJacobian(unsigned int, unsigned int)
Function to compute nonlocal contribution to the off-diagonal Jacobian at the current nodes...
MooseVariable * _temp_var