LCOV - code coverage report
Current view: top level - src/kernels - MechanicsBPD.C (source / functions) Hit Total Coverage
Test: idaholab/moose peridynamics: #31405 (292dce) with base fef103 Lines: 37 38 97.4 %
Date: 2025-09-04 07:55:08 Functions: 5 5 100.0 %
Legend: Lines: hit not hit

          Line data    Source code
       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 "MechanicsBPD.h"
      11             : 
      12             : registerMooseObject("PeridynamicsApp", MechanicsBPD);
      13             : 
      14             : InputParameters
      15         181 : MechanicsBPD::validParams()
      16             : {
      17         181 :   InputParameters params = MechanicsBasePD::validParams();
      18         181 :   params.addClassDescription("Class for calculating the residual and Jacobian for the bond-based "
      19             :                              "peridynamic mechanics formulation");
      20             : 
      21         362 :   params.addRequiredParam<unsigned int>(
      22             :       "component",
      23             :       "An integer corresponding to the variable this kernel acts on (0 for x, 1 for y, 2 for z)");
      24             : 
      25         181 :   return params;
      26           0 : }
      27             : 
      28         130 : MechanicsBPD::MechanicsBPD(const InputParameters & parameters)
      29             :   : MechanicsBasePD(parameters),
      30         130 :     _bond_local_force(getMaterialProperty<Real>("bond_local_force")),
      31         260 :     _bond_local_dfdU(getMaterialProperty<Real>("bond_dfdU")),
      32         260 :     _bond_local_dfdT(getMaterialProperty<Real>("bond_dfdT")),
      33         390 :     _component(getParam<unsigned int>("component"))
      34             : {
      35         130 : }
      36             : 
      37             : void
      38      905867 : MechanicsBPD::computeLocalResidual()
      39             : {
      40      905867 :   _local_re(0) = -_bond_local_force[0] * _current_unit_vec(_component) * _bond_status;
      41      905867 :   _local_re(1) = -_local_re(0);
      42      905867 : }
      43             : 
      44             : void
      45       82864 : MechanicsBPD::computeLocalJacobian()
      46             : {
      47       82864 :   Real diag = _current_unit_vec(_component) * _current_unit_vec(_component) * _bond_local_dfdU[0] +
      48       82864 :               _bond_local_force[0] *
      49      165728 :                   (1.0 - _current_unit_vec(_component) * _current_unit_vec(_component)) /
      50       82864 :                   _current_vec.norm();
      51             : 
      52      248592 :   for (unsigned int i = 0; i < _nnodes; ++i)
      53      497184 :     for (unsigned int j = 0; j < _nnodes; ++j)
      54      497184 :       _local_ke(i, j) += (i == j ? 1 : -1) * diag * _bond_status;
      55       82864 : }
      56             : 
      57             : void
      58       84040 : MechanicsBPD::computeLocalOffDiagJacobian(unsigned int jvar_num, unsigned int coupled_component)
      59             : {
      60       84040 :   if (_temp_coupled && jvar_num == _temp_var->number())
      61             :   {
      62        3528 :     for (unsigned int i = 0; i < _nnodes; ++i)
      63        7056 :       for (unsigned int j = 0; j < _nnodes; ++j)
      64        4704 :         _local_ke(i, j) +=
      65        7056 :             (i == 1 ? 1 : -1) * _current_unit_vec(_component) * _bond_local_dfdT[j] * _bond_status;
      66             :   }
      67             :   else
      68             :   {
      69             :     Real val =
      70       82864 :         _current_unit_vec(_component) * _current_unit_vec(coupled_component) * _bond_local_dfdU[0] -
      71       82864 :         _bond_local_force[0] * _current_unit_vec(_component) *
      72       82864 :             _current_unit_vec(coupled_component) / _current_vec.norm();
      73      248592 :     for (unsigned int i = 0; i < _nnodes; ++i)
      74      497184 :       for (unsigned int j = 0; j < _nnodes; ++j)
      75      497184 :         _local_ke(i, j) += (i == j ? 1 : -1) * val * _bond_status;
      76             :   }
      77       84040 : }

Generated by: LCOV version 1.14