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: #32971 (54bef8) with base c6cf66 Lines: 42 47 89.4 %
Date: 2026-05-29 20:40:07 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         268 : CZMComputeDisplacementJumpBase<is_ad>::validParams()
      16             : {
      17         268 :   InputParameters params = InterfaceMaterial::validParams();
      18         268 :   params.addClassDescription("Base class used to compute the displacement jump across a czm "
      19             :                              "interface in local coordinates");
      20         536 :   params.addRequiredCoupledVar("displacements",
      21             :                                "The string of displacements suitable for the problem statement");
      22         268 :   params.suppressParameter<bool>("use_displaced_mesh");
      23         536 :   params.addParam<std::string>("base_name", "Material property base name");
      24             : 
      25         268 :   return params;
      26           0 : }
      27             : 
      28             : template <bool is_ad>
      29         134 : CZMComputeDisplacementJumpBase<is_ad>::CZMComputeDisplacementJumpBase(
      30             :     const InputParameters & parameters)
      31             :   : InterfaceMaterial(parameters),
      32         470 :     _base_name(isParamValid("base_name") && !getParam<std::string>("base_name").empty()
      33         134 :                    ? getParam<std::string>("base_name") + "_"
      34             :                    : ""),
      35         134 :     _ndisp(coupledComponents("displacements")),
      36         134 :     _disp(3),
      37         134 :     _disp_neighbor(3),
      38         134 :     _displacement_jump_global(declareGenericPropertyByName<RealVectorValue, is_ad>(
      39         134 :         _base_name + "displacement_jump_global")),
      40         134 :     _interface_displacement_jump(declareGenericPropertyByName<RealVectorValue, is_ad>(
      41             :         _base_name + "interface_displacement_jump")),
      42         134 :     _czm_total_rotation(
      43         268 :         declareGenericPropertyByName<RankTwoTensor, is_ad>(_base_name + "czm_total_rotation"))
      44             : {
      45             :   // Enforce consistency
      46         134 :   if (_ndisp != _mesh.dimension())
      47           0 :     paramError("displacements", "Number of displacements must match problem dimension.");
      48             : 
      49         134 :   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         492 :   for (unsigned int i = 0; i < _ndisp; ++i)
      54             :   {
      55         358 :     _disp[i] = &coupledGenericValue<is_ad>("displacements", i);
      56         716 :     _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         178 :   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          44 :       _disp[i] = &_zero;
      70          44 :       _disp_neighbor[i] = &_zero;
      71             :     }
      72             :   }
      73         134 : }
      74             : 
      75             : template <bool is_ad>
      76             : void
      77        1092 : CZMComputeDisplacementJumpBase<is_ad>::initQpStatefulProperties()
      78             : {
      79             :   // requried to promote _interface_displacement_jump to stateful in case someone needs it
      80        1092 :   _interface_displacement_jump[_qp] = 0;
      81        1092 : }
      82             : 
      83             : template <bool is_ad>
      84             : void
      85       67440 : CZMComputeDisplacementJumpBase<is_ad>::computeQpProperties()
      86             : {
      87             :   // computing the displacement jump
      88      265712 :   for (unsigned int i = 0; i < _ndisp; i++)
      89      237152 :     _displacement_jump_global[_qp](i) = (*_disp_neighbor[i])[_qp] - (*_disp[i])[_qp];
      90       71488 :   for (unsigned int i = _ndisp; i < 3; i++)
      91        4048 :     _displacement_jump_global[_qp](i) = 0;
      92             : 
      93       67440 :   computeRotationMatrices();
      94       67440 :   computeLocalDisplacementJump();
      95       67440 : }
      96             : 
      97             : template <bool is_ad>
      98             : void
      99       34528 : CZMComputeDisplacementJumpBase<is_ad>::computeRotationMatrices()
     100             : {
     101       34528 :   _czm_total_rotation[_qp] =
     102       34528 :       CohesiveZoneModelTools::computeReferenceRotation<is_ad>(_normals[_qp], _mesh.dimension());
     103       34528 : }
     104             : 
     105             : template class CZMComputeDisplacementJumpBase<false>;
     106             : template class CZMComputeDisplacementJumpBase<true>;

Generated by: LCOV version 1.14