https://mooseframework.inl.gov
WeakPlaneStressNOSPD.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 "WeakPlaneStressNOSPD.h"
11 #include "MooseVariable.h"
12 #include "PeridynamicsMesh.h"
13 
14 registerMooseObject("PeridynamicsApp", WeakPlaneStressNOSPD);
15 
18 {
20  params.addClassDescription(
21  "Class for calculating the residual and the Jacobian for the peridynamic plane "
22  "stress model using weak formulation based on peridynamic correspondence models");
23 
24  return params;
25 }
26 
28  : MechanicsBaseNOSPD(parameters)
29 {
30 }
31 
32 void
34 {
35  _local_re(0) = _stress[0](2, 2) * _weights[0] * _node_vol[0] * _bond_status;
36  _local_re(1) = _stress[1](2, 2) * _weights[1] * _node_vol[1] * _bond_status;
37 }
38 
39 void
41 {
42  for (unsigned int i = 0; i < _nnodes; ++i)
43  for (unsigned int j = 0; j < _nnodes; ++j)
44  _local_ke(i, j) += (i == j ? 1 : 0) * _Jacobian_mult[i](2, 2, 2, 2) * _weights[i] *
45  _node_vol[i] * _bond_status;
46 }
47 
48 void
50  unsigned int coupled_component)
51 {
52  _local_ke.zero();
53  if (_temp_coupled && jvar_num == _temp_var->number()) // for coupled temperature variable
54  {
55  std::vector<RankTwoTensor> dSdT(_nnodes);
56  for (unsigned int nd = 0; nd < _nnodes; nd++)
57  for (unsigned int es = 0; es < _deigenstrain_dT.size(); es++)
58  dSdT[nd] = -_Jacobian_mult[nd] * (*_deigenstrain_dT[es])[nd];
59 
60  for (unsigned int i = 0; i < _nnodes; ++i)
61  for (unsigned int j = 0; j < _nnodes; ++j)
62  _local_ke(i, j) +=
63  (i == j ? 1 : 0) * dSdT[i](2, 2) * _weights[i] * _node_vol[i] * _bond_status;
64  }
65  else // for coupled displacement variables
66  {
67  // dSidUi and dSjdUj are considered as local off-diagonal Jacobian
68  // contributions to their neighbors are considered as nonlocal off-diagonal
69  for (unsigned int i = 0; i < _nnodes; ++i)
70  for (unsigned int j = 0; j < _nnodes; ++j)
71  _local_ke(i, j) += (i == j ? 1 : 0) * computeDSDU(coupled_component, j)(2, 2) *
72  _weights[j] * _node_vol[j] * _bond_status;
73  }
74 }
75 
76 void
78  unsigned int coupled_component)
79 {
80  if (_temp_coupled && jvar_num == _temp_var->number())
81  {
82  // no nonlocal contribution from temperature
83  }
84  else
85  {
86  for (unsigned int nd = 0; nd < _nnodes; nd++)
87  {
88  // calculation of jacobian contribution to current_node's neighbors
89  // NOT including the contribution to nodes i and j, which is considered as local
90  // off-diagonal
91  std::vector<dof_id_type> jvardofs(_nnodes);
92  jvardofs[0] = _current_elem->node_ptr(nd)->dof_number(_sys.number(), jvar_num, 0);
93  std::vector<dof_id_type> neighbors = _pdmesh.getNeighbors(_current_elem->node_id(nd));
94  std::vector<dof_id_type> bonds = _pdmesh.getBonds(_current_elem->node_id(nd));
95 
96  dof_id_type nb_index =
97  std::find(neighbors.begin(), neighbors.end(), _current_elem->node_id(1 - nd)) -
98  neighbors.begin();
99  std::vector<dof_id_type> dg_neighbors =
100  _pdmesh.getBondDeformationGradientNeighbors(_current_elem->node_id(nd), nb_index);
101 
102  Real vol_nb, weight_nb;
103  RealGradient origin_vec_nb;
104  RankTwoTensor dFdUk, dPdUk;
105 
106  for (unsigned int nb = 0; nb < dg_neighbors.size(); nb++)
107  if (_bond_status_var->getElementalValue(_pdmesh.elemPtr(bonds[dg_neighbors[nb]])) > 0.5)
108  {
109  jvardofs[1] =
110  _pdmesh.nodePtr(neighbors[dg_neighbors[nb]])->dof_number(_sys.number(), jvar_num, 0);
111  vol_nb = _pdmesh.getNodeVolume(neighbors[dg_neighbors[nb]]);
112 
113  origin_vec_nb = _pdmesh.getNodeCoord(neighbors[dg_neighbors[nb]]) -
114  _pdmesh.getNodeCoord(_current_elem->node_id(nd));
115 
116  weight_nb = _horizon_radius[nd] / origin_vec_nb.norm();
117 
118  dFdUk.zero();
119  for (unsigned int i = 0; i < _dim; ++i)
120  dFdUk(coupled_component, i) = weight_nb * origin_vec_nb(i) * vol_nb;
121 
122  dFdUk *= _shape2[nd].inverse();
123 
124  dPdUk = _Jacobian_mult[nd] * 0.5 *
125  (dFdUk.transpose() * _dgrad[nd] + _dgrad[nd].transpose() * dFdUk);
126 
127  _local_ke.zero();
128  _local_ke(nd, 1) = dPdUk(2, 2) * _weights[nd] * _node_vol[nd] * _bond_status;
129 
130  addJacobian(_assembly, _local_ke, _ivardofs, jvardofs, _var.scalingFactor());
131  }
132  }
133  }
134 }
const bool _temp_coupled
Temperature variable.
virtual void computeLocalJacobian() override
virtual RankTwoTensor computeDSDU(unsigned int component, unsigned int nd)
Function to compute derivative of stress with respect to displacements for small strain problems...
auto norm() const -> decltype(std::norm(Real()))
const MaterialProperty< RankFourTensor > & _Jacobian_mult
Kernel class for weak plane stress formulation based on Form I of the horizon-stabilized peridynamic ...
unsigned int number() const
const MaterialProperty< RankTwoTensor > & _stress
virtual void computeLocalResidual() override
WeakPlaneStressNOSPD(const InputParameters &parameters)
registerMooseObject("PeridynamicsApp", WeakPlaneStressNOSPD)
std::vector< const MaterialProperty< RankTwoTensor > * > _deigenstrain_dT
virtual void computeLocalOffDiagJacobian(unsigned int jvar_num, unsigned int coupled_component) override
Function to compute local contribution to the off-diagonal Jacobian at the current nodes...
std::vector< Real > _weights
weights used for the current element to obtain the nodal stress
static InputParameters validParams()
virtual void computePDNonlocalOffDiagJacobian(unsigned int jvar_num, unsigned int coupled_component) override
Function to compute nonlocal contribution to the off-diagonal Jacobian at the current nodes...
std::vector< dof_id_type > _ivardofs
Current variable dof numbers for nodes i and j.
const MaterialProperty< RankTwoTensor > & _shape2
RankTwoTensorTempl< Real > transpose() const
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
void addClassDescription(const std::string &doc_string)
static InputParameters validParams()
static const std::complex< double > j(0, 1)
Complex number "j" (also known as "i")
MooseVariable * _temp_var
Base kernel class for bond-associated correspondence material models.
uint8_t dof_id_type
const MaterialProperty< RankTwoTensor > & _dgrad