LCOV - code coverage report
Current view: top level - src/materials/cohesive_zone_model - CZMComputeDisplacementJumpBase.C (source / functions) Hit Total Coverage
Test: idaholab/moose tensor_mechanics: d6b47a Lines: 42 47 89.4 %
Date: 2024-02-27 11:53:14 Functions: 10 10 100.0 %
Legend: Lines: hit not hit

          Line data    Source code
       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 "CZMComputeDisplacementJumpBase.h"
      11             : #include "CohesiveZoneModelTools.h"
      12             : 
      13             : template <bool is_ad>
      14             : InputParameters
      15         198 : CZMComputeDisplacementJumpBase<is_ad>::validParams()
      16             : {
      17         198 :   InputParameters params = InterfaceMaterial::validParams();
      18         198 :   params.addClassDescription("Base class used to compute the displacement jump across a czm "
      19             :                              "interface in local coordinates");
      20         396 :   params.addRequiredCoupledVar("displacements",
      21             :                                "The string of displacements suitable for the problem statement");
      22         198 :   params.suppressParameter<bool>("use_displaced_mesh");
      23         396 :   params.addParam<std::string>("base_name", "Material property base name");
      24             : 
      25         198 :   return params;
      26           0 : }
      27             : 
      28             : template <bool is_ad>
      29          99 : CZMComputeDisplacementJumpBase<is_ad>::CZMComputeDisplacementJumpBase(
      30             :     const InputParameters & parameters)
      31             :   : InterfaceMaterial(parameters),
      32         345 :     _base_name(isParamValid("base_name") && !getParam<std::string>("base_name").empty()
      33          99 :                    ? getParam<std::string>("base_name") + "_"
      34             :                    : ""),
      35          99 :     _ndisp(coupledComponents("displacements")),
      36          99 :     _disp(3),
      37          99 :     _disp_neighbor(3),
      38          99 :     _displacement_jump_global(declareGenericPropertyByName<RealVectorValue, is_ad>(
      39          99 :         _base_name + "displacement_jump_global")),
      40          99 :     _interface_displacement_jump(declareGenericPropertyByName<RealVectorValue, is_ad>(
      41             :         _base_name + "interface_displacement_jump")),
      42          99 :     _czm_total_rotation(
      43         198 :         declareGenericPropertyByName<RankTwoTensor, is_ad>(_base_name + "czm_total_rotation"))
      44             : {
      45             :   // Enforce consistency
      46          99 :   if (_ndisp != _mesh.dimension())
      47           0 :     paramError("displacements", "Number of displacements must match problem dimension.");
      48             : 
      49          99 :   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         363 :   for (unsigned int i = 0; i < _ndisp; ++i)
      54             :   {
      55         264 :     _disp[i] = &coupledGenericValue<is_ad>("displacements", i);
      56         528 :     _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         132 :   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          33 :       _disp[i] = &_zero;
      70          33 :       _disp_neighbor[i] = &_zero;
      71             :     }
      72             :   }
      73          99 : }
      74             : 
      75             : template <bool is_ad>
      76             : void
      77        2312 : CZMComputeDisplacementJumpBase<is_ad>::initQpStatefulProperties()
      78             : {
      79             :   // requried to promote _interface_displacement_jump to stateful in case someone needs it
      80        2312 :   _interface_displacement_jump[_qp] = 0;
      81        2312 : }
      82             : 
      83             : template <bool is_ad>
      84             : void
      85       45512 : CZMComputeDisplacementJumpBase<is_ad>::computeQpProperties()
      86             : {
      87             : 
      88             :   // computing the displacement jump
      89      179212 :   for (unsigned int i = 0; i < _ndisp; i++)
      90      159620 :     _displacement_jump_global[_qp](i) = (*_disp_neighbor[i])[_qp] - (*_disp[i])[_qp];
      91       48348 :   for (unsigned int i = _ndisp; i < 3; i++)
      92        2836 :     _displacement_jump_global[_qp](i) = 0;
      93             : 
      94       45512 :   computeRotationMatrices();
      95       45512 :   computeLocalDisplacementJump();
      96       45512 : }
      97             : 
      98             : template <bool is_ad>
      99             : void
     100       23446 : CZMComputeDisplacementJumpBase<is_ad>::computeRotationMatrices()
     101             : {
     102       23446 :   _czm_total_rotation[_qp] =
     103       23446 :       CohesiveZoneModelTools::computeReferenceRotation<is_ad>(_normals[_qp], _mesh.dimension());
     104       23446 : }
     105             : 
     106             : template class CZMComputeDisplacementJumpBase<false>;
     107             : template class CZMComputeDisplacementJumpBase<true>;

Generated by: LCOV version 1.14