LCOV - code coverage report
Current view: top level - src/materials - ParametricMaterialBasePD.C (source / functions) Hit Total Coverage
Test: idaholab/moose peridynamics: #31405 (292dce) with base fef103 Lines: 55 58 94.8 %
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 "ParametricMaterialBasePD.h"
      11             : #include "ElasticityTensorTools.h"
      12             : 
      13             : #include "libmesh/quadrature.h"
      14             : 
      15             : InputParameters
      16         619 : ParametricMaterialBasePD::validParams()
      17             : {
      18         619 :   InputParameters params = MechanicsMaterialBasePD::validParams();
      19         619 :   params.addClassDescription("Base class for peridynamic models based on derived micro moduli");
      20             : 
      21        1238 :   params.addParam<bool>("plane_stress", false, "Plane stress problem or not");
      22        1238 :   params.addCoupledVar("scalar_out_of_plane_strain",
      23             :                        "Scalar variable for strain in the out-of-plane direction");
      24        1238 :   params.addParam<Real>("stress_free_temperature", "Stress free temperature");
      25        1238 :   params.addParam<Real>("thermal_expansion_coeff",
      26             :                         "Value of material thermal expansion coefficient");
      27             : 
      28         619 :   return params;
      29           0 : }
      30             : 
      31         486 : ParametricMaterialBasePD::ParametricMaterialBasePD(const InputParameters & parameters)
      32             :   : MechanicsMaterialBasePD(parameters),
      33         486 :     _plane_stress(getParam<bool>("plane_stress")),
      34         486 :     _scalar_out_of_plane_strain_coupled(isCoupledScalar("scalar_out_of_plane_strain")),
      35         972 :     _scalar_out_of_plane_strain(_scalar_out_of_plane_strain_coupled
      36         486 :                                     ? coupledScalarValue("scalar_out_of_plane_strain")
      37             :                                     : _zero),
      38         486 :     _temp(2),
      39         666 :     _temp_ref(_has_temp ? getParam<Real>("stress_free_temperature") : 0.0),
      40         666 :     _tec(_has_temp ? getParam<Real>("thermal_expansion_coeff") : 0.0),
      41         486 :     _bond_local_force(declareProperty<Real>("bond_local_force")),
      42         486 :     _bond_local_dfdU(declareProperty<Real>("bond_dfdU")),
      43         486 :     _bond_local_dfdT(declareProperty<Real>("bond_dfdT")),
      44         486 :     _bond_local_dfdE(declareProperty<Real>("bond_local_dfdE")),
      45         486 :     _thermal_expansion_coeff(declareProperty<Real>("thermal_expansion_coeff")),
      46        1458 :     _Cijkl(getMaterialProperty<RankFourTensor>("elasticity_tensor"))
      47             : {
      48         486 :   if (_dim != 2 && _scalar_out_of_plane_strain_coupled)
      49           0 :     mooseError("scalar strain can ONLY be specified for 2D analysis!");
      50             : 
      51         486 :   if (_plane_stress && _scalar_out_of_plane_strain_coupled)
      52           0 :     mooseError("Scalar strain can ONLY be specified for generalized plane strain case!");
      53         486 : }
      54             : 
      55             : void
      56     1184163 : ParametricMaterialBasePD::computeProperties()
      57             : {
      58     1184163 :   setupMeshRelatedData();     // function from base class
      59     1184163 :   computeBondCurrentLength(); // current length of a bond from base class
      60             : 
      61     1184163 :   _temp[0] = _has_temp ? _temp_var->getNodalValue(*_current_elem->node_ptr(0)) : 0.0;
      62     1184163 :   _temp[1] = _has_temp ? _temp_var->getNodalValue(*_current_elem->node_ptr(1)) : 0.0;
      63             : 
      64     1184163 :   computeMaterialConstants();
      65     1184163 :   computePeridynamicsParams();
      66             : 
      67     3552489 :   for (_qp = 0; _qp < _nnodes; ++_qp)
      68             :   {
      69     2368326 :     computeBondStretch();
      70     2368326 :     computeBondForce();
      71             :   }
      72     1184163 : }
      73             : 
      74             : void
      75     1184163 : ParametricMaterialBasePD::computeMaterialConstants()
      76             : {
      77             :   /// get material constants from elasticity tensor
      78     1184163 :   _youngs_modulus = ElasticityTensorTools::getIsotropicYoungsModulus(_Cijkl[0]);
      79     1184163 :   _poissons_ratio = ElasticityTensorTools::getIsotropicPoissonsRatio(_Cijkl[0]);
      80     1184163 :   _shear_modulus = 0.5 * _youngs_modulus / (1.0 + _poissons_ratio);
      81     1184163 :   if (_dim == 3 || _scalar_out_of_plane_strain_coupled) // general 3D and generalized plane strain
      82      420401 :     _bulk_modulus = _youngs_modulus / 3.0 / (1.0 - 2.0 * _poissons_ratio);
      83      763762 :   else if (_plane_stress) // plane stress case
      84       61974 :     _bulk_modulus = _youngs_modulus / 2.0 / (1.0 - _poissons_ratio);
      85             :   else // plane strain case
      86      701788 :     _bulk_modulus = _youngs_modulus / 2.0 / (1.0 + _poissons_ratio) / (1.0 - 2.0 * _poissons_ratio);
      87             : 
      88     1184163 :   if (_dim == 2 && !_plane_stress && !_scalar_out_of_plane_strain_coupled) // plane strain case
      89      701788 :     _alpha = _tec * (1.0 + _poissons_ratio);
      90             :   else
      91      482375 :     _alpha = _tec;
      92     1184163 : }
      93             : 
      94             : void
      95     2368326 : ParametricMaterialBasePD::computeBondStretch()
      96             : {
      97     2368326 :   _thermal_expansion_coeff[_qp] = _alpha;
      98             : 
      99     2368326 :   _total_stretch[_qp] = _current_len / _origin_vec.norm() - 1.0;
     100     2368326 :   _mechanical_stretch[_qp] =
     101     2368326 :       _total_stretch[_qp] - _alpha * (0.5 * (_temp[0] + _temp[1]) - _temp_ref);
     102     2368326 : }

Generated by: LCOV version 1.14