www.mooseframework.org
RBMPresetOldValuePD.C
Go to the documentation of this file.
1 //* This file is part of the MOOSE framework
2 //* https://www.mooseframework.org
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 "RBMPresetOldValuePD.h"
11 
12 registerMooseObject("PeridynamicsApp", RBMPresetOldValuePD);
13 
14 template <>
15 InputParameters
17 {
18  InputParameters params = validParams<DirichletBCBase>();
19  params.addClassDescription("Class to apply a preset BC to nodes with rigid body motion (RBM).");
20 
21  // Forcefully preset the BC
22  params.set<bool>("preset") = true;
23  params.suppressParameter<bool>("preset");
24 
25  return params;
26 }
27 
28 RBMPresetOldValuePD::RBMPresetOldValuePD(const InputParameters & parameters)
29  : DirichletBCBase(parameters),
30  _pdmesh(dynamic_cast<PeridynamicsMesh &>(_mesh)),
31  _u_old(_var.dofValuesOld()),
32  _bond_status_var(&_subproblem.getStandardVariable(_tid, "bond_status"))
33 {
34 }
35 
36 Real
38 {
39  return _u_old[_qp];
40 }
41 
42 bool
44 {
45  bool should_apply = true;
46 
47  // check whether the node shape tensor is singular
48  unsigned int dim = _pdmesh.dimension();
49  Real horiz_size = _pdmesh.getHorizon(_current_node->id());
50  std::vector<dof_id_type> neighbors = _pdmesh.getNeighbors(_current_node->id());
51  std::vector<dof_id_type> bonds = _pdmesh.getBonds(_current_node->id());
52 
53  RankTwoTensor shape_tensor;
54  if (dim == 2)
55  shape_tensor(2, 2) = 1.0;
56 
57  RealGradient ori_vec(dim);
58  for (unsigned int i = 0; i < neighbors.size(); ++i)
59  if (_bond_status_var->getElementalValue(_pdmesh.elemPtr(bonds[i])) > 0.5)
60  {
61  Real vol_i = _pdmesh.getPDNodeVolume(neighbors[i]);
62  ori_vec = *(_pdmesh.nodePtr(neighbors[i])) - *_current_node;
63  for (unsigned int j = 0; j < dim; ++j)
64  for (unsigned int k = 0; k < dim; ++k)
65  shape_tensor(j, k) += horiz_size / ori_vec.norm() * ori_vec(j) * ori_vec(k) * vol_i;
66  }
67 
68  if (!MooseUtils::absoluteFuzzyEqual(shape_tensor.det(), 0.0))
69  should_apply = false;
70 
71  return should_apply;
72 }
RBMPresetOldValuePD::_u_old
const VariableValue & _u_old
Value of the unknown variable this BC is acting on at last time step.
Definition: RBMPresetOldValuePD.h:37
RBMPresetOldValuePD::shouldApply
virtual bool shouldApply() override
Definition: RBMPresetOldValuePD.C:43
PeridynamicsMesh::getPDNodeVolume
Real getPDNodeVolume(dof_id_type node_id)
Function to return nodal volume for node node_id.
Definition: PeridynamicsMesh.C:435
RBMPresetOldValuePD::RBMPresetOldValuePD
RBMPresetOldValuePD(const InputParameters &parameters)
Definition: RBMPresetOldValuePD.C:28
RBMPresetOldValuePD::_bond_status_var
MooseVariable * _bond_status_var
AuxVariable for number of intact bonds associated with each material point.
Definition: RBMPresetOldValuePD.h:40
libMesh::RealGradient
VectorValue< Real > RealGradient
Definition: GrainForceAndTorqueInterface.h:17
RBMPresetOldValuePD::_pdmesh
PeridynamicsMesh & _pdmesh
Peridynamic mesh.
Definition: RBMPresetOldValuePD.h:34
PeridynamicsMesh::dimension
virtual unsigned int dimension() const override
Definition: PeridynamicsMesh.C:120
registerMooseObject
registerMooseObject("PeridynamicsApp", RBMPresetOldValuePD)
PeridynamicsMesh
Peridynamics mesh class.
Definition: PeridynamicsMesh.h:25
RBMPresetOldValuePD::computeQpValue
virtual Real computeQpValue() override
Definition: RBMPresetOldValuePD.C:37
validParams< RBMPresetOldValuePD >
InputParameters validParams< RBMPresetOldValuePD >()
Definition: RBMPresetOldValuePD.C:16
RBMPresetOldValuePD
Class to apply preset BC of old variable solution based on the singularity of nodal shape tensor.
Definition: RBMPresetOldValuePD.h:24
PeridynamicsMesh::getNeighbors
std::vector< dof_id_type > getNeighbors(dof_id_type node_id)
Function to return neighbor nodes indices for node node_id.
Definition: PeridynamicsMesh.C:362
PeridynamicsMesh::getHorizon
Real getHorizon(dof_id_type node_id)
Function to return horizon size.
Definition: PeridynamicsMesh.C:471
PeridynamicsMesh::getBonds
std::vector< dof_id_type > getBonds(dof_id_type node_id)
Function to return the bond number connected with node node_id.
Definition: PeridynamicsMesh.C:382
RankTwoTensorTempl< Real >
RBMPresetOldValuePD.h