https://mooseframework.inl.gov
Loading...
Searching...
No Matches
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
11#include "PeridynamicsMesh.h"
12
15{
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
42void
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);
54 }
55
59}
60
61void
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
77
79}
80
81void
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
105}
void addParam(const std::string &name, const std::initializer_list< typename T::value_type > &value, const std::string &doc_string)
void addClassDescription(const std::string &doc_string)
std::vector< MooseVariableFEBase * > _save_in
bool _has_diag_save_in
bool _has_save_in
const Elem *const & _current_elem
std::vector< MooseVariableFEBase * > _diag_save_in
MooseVariable & _var
static InputParameters validParams()
unsigned int number() const
DofValue getElementalValue(const Elem *elem, unsigned int idx=0) const
virtual void computeLocalResidual()=0
Function to compute local contribution to the residual at the current nodes.
virtual void computeLocalJacobian()
Function to compute local contribution to the diagonal Jacobian at the current nodes.
virtual void computeNonlocalResidual()
Function to compute nonlocal contribution to the residual at the current nodes.
static InputParameters validParams()
RealGradient _origin_vec
Vector for current bond under undefored configuration.
virtual void computeResidual() override
std::vector< Real > _node_vol
virtual void prepare()
Function to precalculate data which will be used in the derived classes.
MooseVariable * _bond_status_var
Bond_status variable.
PeridynamicsMesh & _pdmesh
Parameters for peridynamic mesh information.
const bool _use_full_jacobian
Option to use full jacobian including nonlocal constribution or not.
virtual void computeJacobian() override
std::vector< Real > _dg_vol_frac
PeridynamicsKernelBase(const InputParameters &parameters)
std::vector< Real > _horizon_radius
Real _bond_status
Bond status of current bond/edge2.
std::vector< Real > _horizon_vol
Peridynamics mesh class.
Real getNodeVolume(dof_id_type node_id)
Function to return nodal volume for node node_id.
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 getHorizon(dof_id_type node_id)
Function to return horizon size.
Point getNodeCoord(dof_id_type node_id)
Function to return coordinates for node node_id.
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's neighbor list.
Real getHorizonVolume(dof_id_type node_id)
Function to return summation of neighbor nodal volumes for node node_id.
Assembly & _assembly
virtual void computeNonlocalJacobian()
DenseMatrix< Number > _local_ke
void accumulateTaggedLocalMatrix()
void prepareMatrixTag(Assembly &assembly, unsigned int ivar, unsigned int jvar)
void accumulateTaggedLocalResidual()
void prepareVectorTag(Assembly &assembly, unsigned int ivar)
DenseVector< Number > _local_re
unsigned int m() const
virtual void zero() override final
virtual void zero() override final
virtual unsigned int size() const override final