https://mooseframework.inl.gov
PeridynamicsKernelBase.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 "PeridynamicsKernelBase.h"
11 #include "PeridynamicsMesh.h"
12 
15 {
17  params.addClassDescription(
18  "Base class for calculating the residual and Jacobian for the peridynamic kernels");
19 
20  params.addParam<bool>("full_jacobian",
21  false,
22  "Whether to include coupling terms with nodes connected to neighbors in "
23  "the Jacobian matrix for state based formulations");
24 
25  return params;
26 }
27 
29  : Kernel(parameters),
30  _bond_status_var(&_subproblem.getStandardVariable(_tid, "bond_status")),
31  _use_full_jacobian(getParam<bool>("full_jacobian")),
32  _pdmesh(dynamic_cast<PeridynamicsMesh &>(_mesh)),
33  _dim(_pdmesh.dimension()),
34  _nnodes(2),
35  _node_vol(_nnodes),
36  _dg_vol_frac(_nnodes),
37  _horizon_radius(_nnodes),
38  _horizon_vol(_nnodes)
39 {
40 }
41 
42 void
44 {
45  for (unsigned int nd = 0; nd < _nnodes; ++nd)
46  {
47  _node_vol[nd] = _pdmesh.getNodeVolume(_current_elem->node_id(nd));
48  dof_id_type id_ji_in_ij =
49  _pdmesh.getNeighborIndex(_current_elem->node_id(nd), _current_elem->node_id(1 - nd));
50  _dg_vol_frac[nd] =
51  _pdmesh.getHorizonSubsetVolumeFraction(_current_elem->node_id(nd), id_ji_in_ij);
52  _horizon_radius[nd] = _pdmesh.getHorizon(_current_elem->node_id(nd));
54  }
55 
57  _pdmesh.getNodeCoord(_current_elem->node_id(0));
59 }
60 
61 void
63 {
64  prepare();
65 
67  mooseAssert(_local_re.size() == _nnodes,
68  "PeridynamicsKernelBase is designed to only work with EDGE2 elements");
71 
72  if (_has_save_in)
73  for (unsigned int i = 0; i < _save_in.size(); ++i)
74  _save_in[i]->sys().solution().add_vector(_local_re, _save_in[i]->dofIndices());
75 
76  _local_re.zero();
77 
79 }
80 
81 void
83 {
84  prepare();
85 
89 
91  {
92  unsigned int rows = _local_ke.m();
93  DenseVector<Number> diag(rows);
94  for (unsigned int i = 0; i < rows; ++i)
95  diag(i) = _local_ke(i, i);
96 
97  for (unsigned int i = 0; i < _diag_save_in.size(); ++i)
98  _diag_save_in[i]->sys().solution().add_vector(diag, _diag_save_in[i]->dofIndices());
99  }
100 
101  _local_ke.zero();
102 
103  if (_use_full_jacobian)
105 }
static InputParameters validParams()
virtual void zero() override final
void accumulateTaggedLocalResidual()
std::vector< Real > _node_vol
MooseVariable & _var
std::vector< MooseVariableFEBase *> _save_in
void addParam(const std::string &name, const std::initializer_list< typename T::value_type > &value, const std::string &doc_string)
Real _bond_status
Bond status of current bond/edge2.
virtual void zero() override final
unsigned int number() const
Peridynamics mesh class.
virtual void computeNonlocalResidual()
Function to compute nonlocal contribution to the residual at the current nodes.
std::vector< Real > _horizon_radius
std::vector< Real > _dg_vol_frac
unsigned int m() const
virtual void computeNonlocalJacobian()
bool _has_diag_save_in
DenseMatrix< Number > _local_ke
dof_id_type getNeighborIndex(dof_id_type node_i, dof_id_type node_j)
Function to return the local neighbor index of node_j from node_i&#39;s neighbor list.
virtual void computeLocalJacobian()
Function to compute local contribution to the diagonal Jacobian at the current nodes.
OutputData getElementalValue(const Elem *elem, unsigned int idx=0) const
PeridynamicsKernelBase(const InputParameters &parameters)
Real getHorizonVolume(dof_id_type node_id)
Function to return summation of neighbor nodal volumes for node node_id.
std::vector< MooseVariableFEBase *> _diag_save_in
static InputParameters validParams()
bool _has_save_in
const bool _use_full_jacobian
Option to use full jacobian including nonlocal constribution or not.
virtual void computeLocalResidual()=0
Function to compute local contribution to the residual at the current nodes.
void accumulateTaggedLocalMatrix()
Real getHorizonSubsetVolumeFraction(dof_id_type node_id, dof_id_type neighbor_id)
Function to return the volume fraction of a horizon subset used for bond-associated deformation gradi...
Real getNodeVolume(dof_id_type node_id)
Function to return nodal volume for node node_id.
Assembly & _assembly
virtual void prepare()
Function to precalculate data which will be used in the derived classes.
virtual void computeJacobian() override
Point getNodeCoord(dof_id_type node_id)
Function to return coordinates for node node_id.
DenseVector< Number > _local_re
std::vector< Real > _horizon_vol
virtual unsigned int size() const override final
RealGradient _origin_vec
Vector for current bond under undefored configuration.
void addClassDescription(const std::string &doc_string)
const Elem *const & _current_elem
MooseVariable * _bond_status_var
Bond_status variable.
void prepareVectorTag(Assembly &assembly, unsigned int ivar)
void prepareMatrixTag(Assembly &assembly, unsigned int ivar, unsigned int jvar)
virtual void computeResidual() override
uint8_t dof_id_type
Real getHorizon(dof_id_type node_id)
Function to return horizon size.
PeridynamicsMesh & _pdmesh
Parameters for peridynamic mesh information.