LCOV - code coverage report
Current view: top level - src/materials/cohesive_zone_model - CZMComputeDisplacementJumpBase.C (source / functions) Hit Total Coverage
Test: idaholab/moose solid_mechanics: f45d79 Lines: 42 47 89.4 %
Date: 2025-07-25 05:00:39 Functions: 9 10 90.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 "CZMComputeDisplacementJumpBase.h"
      11             : #include "CohesiveZoneModelTools.h"
      12             : 
      13             : template <bool is_ad>
      14             : InputParameters
      15         396 : CZMComputeDisplacementJumpBase<is_ad>::validParams()
      16             : {
      17         396 :   InputParameters params = InterfaceMaterial::validParams();
      18         396 :   params.addClassDescription("Base class used to compute the displacement jump across a czm "
      19             :                              "interface in local coordinates");
      20         792 :   params.addRequiredCoupledVar("displacements",
      21             :                                "The string of displacements suitable for the problem statement");
      22         396 :   params.suppressParameter<bool>("use_displaced_mesh");
      23         792 :   params.addParam<std::string>("base_name", "Material property base name");
      24             : 
      25         396 :   return params;
      26           0 : }
      27             : 
      28             : template <bool is_ad>
      29         198 : CZMComputeDisplacementJumpBase<is_ad>::CZMComputeDisplacementJumpBase(
      30             :     const InputParameters & parameters)
      31             :   : InterfaceMaterial(parameters),
      32         690 :     _base_name(isParamValid("base_name") && !getParam<std::string>("base_name").empty()
      33         198 :                    ? getParam<std::string>("base_name") + "_"
      34             :                    : ""),
      35         198 :     _ndisp(coupledComponents("displacements")),
      36         198 :     _disp(3),
      37         198 :     _disp_neighbor(3),
      38         198 :     _displacement_jump_global(declareGenericPropertyByName<RealVectorValue, is_ad>(
      39         198 :         _base_name + "displacement_jump_global")),
      40         198 :     _interface_displacement_jump(declareGenericPropertyByName<RealVectorValue, is_ad>(
      41             :         _base_name + "interface_displacement_jump")),
      42         198 :     _czm_total_rotation(
      43         396 :         declareGenericPropertyByName<RankTwoTensor, is_ad>(_base_name + "czm_total_rotation"))
      44             : {
      45             :   // Enforce consistency
      46         198 :   if (_ndisp != _mesh.dimension())
      47           0 :     paramError("displacements", "Number of displacements must match problem dimension.");
      48             : 
      49         198 :   if (_ndisp > 3 || _ndisp < 1)
      50           0 :     mooseError("the CZM material requires 1, 2 or 3 displacement variables");
      51             : 
      52             :   // initializing the displacement vectors
      53         726 :   for (unsigned int i = 0; i < _ndisp; ++i)
      54             :   {
      55         528 :     _disp[i] = &coupledGenericValue<is_ad>("displacements", i);
      56        1056 :     _disp_neighbor[i] = &coupledGenericNeighborValue<is_ad>("displacements", i);
      57             :   }
      58             : 
      59             :   // All others zero (so this will work naturally for 2D and 1D problems)
      60         264 :   for (unsigned int i = _ndisp; i < 3; i++)
      61             :   {
      62             :     if constexpr (is_ad)
      63             :     {
      64           0 :       _disp[i] = &_ad_zero;
      65           0 :       _disp_neighbor[i] = &_ad_zero;
      66             :     }
      67             :     else
      68             :     {
      69          66 :       _disp[i] = &_zero;
      70          66 :       _disp_neighbor[i] = &_zero;
      71             :     }
      72             :   }
      73         198 : }
      74             : 
      75             : template <bool is_ad>
      76             : void
      77        1456 : CZMComputeDisplacementJumpBase<is_ad>::initQpStatefulProperties()
      78             : {
      79             :   // requried to promote _interface_displacement_jump to stateful in case someone needs it
      80        1456 :   _interface_displacement_jump[_qp] = 0;
      81        1456 : }
      82             : 
      83             : template <bool is_ad>
      84             : void
      85       81104 : CZMComputeDisplacementJumpBase<is_ad>::computeQpProperties()
      86             : {
      87             : 
      88             :   // computing the displacement jump
      89      319312 :   for (unsigned int i = 0; i < _ndisp; i++)
      90      284864 :     _displacement_jump_global[_qp](i) = (*_disp_neighbor[i])[_qp] - (*_disp[i])[_qp];
      91       86208 :   for (unsigned int i = _ndisp; i < 3; i++)
      92        5104 :     _displacement_jump_global[_qp](i) = 0;
      93             : 
      94       81104 :   computeRotationMatrices();
      95       81104 :   computeLocalDisplacementJump();
      96       81104 : }
      97             : 
      98             : template <bool is_ad>
      99             : void
     100       41200 : CZMComputeDisplacementJumpBase<is_ad>::computeRotationMatrices()
     101             : {
     102       41200 :   _czm_total_rotation[_qp] =
     103       41200 :       CohesiveZoneModelTools::computeReferenceRotation<is_ad>(_normals[_qp], _mesh.dimension());
     104       41200 : }
     105             : 
     106             : template class CZMComputeDisplacementJumpBase<false>;
     107             : template class CZMComputeDisplacementJumpBase<true>;

Generated by: LCOV version 1.14