LCOV - code coverage report
Current view: top level - src/interfacekernels - CZMInterfaceKernelBase.C (source / functions) Hit Total Coverage
Test: idaholab/moose solid_mechanics: f45d79 Lines: 44 48 91.7 %
Date: 2025-07-25 05:00:39 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 "CZMInterfaceKernelBase.h"
      11             : 
      12             : InputParameters
      13        1658 : CZMInterfaceKernelBase::validParams()
      14             : {
      15        1658 :   InputParameters params = InterfaceKernel::validParams();
      16        3316 :   params.addRequiredParam<unsigned int>("component",
      17             :                                         "the component of the "
      18             :                                         "displacement vector this kernel is working on:"
      19             :                                         " component == 0, ==> X"
      20             :                                         " component == 1, ==> Y"
      21             :                                         " component == 2, ==> Z");
      22        1658 :   params.suppressParameter<bool>("use_displaced_mesh");
      23        3316 :   params.addRequiredCoupledVar("displacements", "the string containing displacement variables");
      24        3316 :   params.addParam<std::string>("base_name", "Material property base name");
      25        1658 :   params.set<std::string>("traction_global_name") = "traction_global";
      26             : 
      27        1658 :   return params;
      28           0 : }
      29             : 
      30         492 : CZMInterfaceKernelBase::CZMInterfaceKernelBase(const InputParameters & parameters)
      31             :   : JvarMapKernelInterface<InterfaceKernel>(parameters),
      32        1764 :     _base_name(isParamValid("base_name") && !getParam<std::string>("base_name").empty()
      33         492 :                    ? getParam<std::string>("base_name") + "_"
      34             :                    : ""),
      35         984 :     _component(getParam<unsigned int>("component")),
      36         492 :     _ndisp(coupledComponents("displacements")),
      37         492 :     _disp_var(_ndisp),
      38         492 :     _disp_neighbor_var(_ndisp),
      39         492 :     _vars(_ndisp),
      40         492 :     _traction_global(getMaterialPropertyByName<RealVectorValue>(
      41         984 :         _base_name + getParam<std::string>("traction_global_name"))),
      42         492 :     _dtraction_djump_global(
      43         984 :         getMaterialPropertyByName<RankTwoTensor>(_base_name + "dtraction_djump_global"))
      44             : {
      45             :   // Enforce consistency
      46         492 :   if (_ndisp != _mesh.dimension())
      47           0 :     paramError("displacements", "Number of displacements must match problem dimension.");
      48             : 
      49         492 :   if (_ndisp > 3 || _ndisp < 1)
      50           0 :     mooseError("the CZM material requires 1, 2 or 3 displacement variables");
      51             : 
      52        1860 :   for (unsigned int i = 0; i < _ndisp; ++i)
      53             :   {
      54        1368 :     _disp_var[i] = coupled("displacements", i);
      55        1368 :     _disp_neighbor_var[i] = coupled("displacements", i);
      56        1368 :     _vars[i] = getVar("displacements", i);
      57             :   }
      58         492 : }
      59             : 
      60             : Real
      61     1538240 : CZMInterfaceKernelBase::computeQpResidual(Moose::DGResidualType type)
      62             : {
      63     1538240 :   Real r = _traction_global[_qp](_component);
      64             : 
      65     1538240 :   switch (type)
      66             :   {
      67             :     // [test_secondary-test_primary]*T where T represents the traction.
      68      769120 :     case Moose::Element:
      69      769120 :       r *= -_test[_i][_qp];
      70      769120 :       break;
      71      769120 :     case Moose::Neighbor:
      72      769120 :       r *= _test_neighbor[_i][_qp];
      73      769120 :       break;
      74             :   }
      75     1538240 :   return r;
      76             : }
      77             : 
      78             : Real
      79    18335872 : CZMInterfaceKernelBase::computeQpJacobian(Moose::DGJacobianType type)
      80             : {
      81             :   // retrieve the diagonal Jacobian coefficient dependning on the displacement
      82             :   // component (_component) this kernel is working on
      83    18335872 :   return computeDResidualDDisplacement(_component, type);
      84             : }
      85             : 
      86             : Real
      87    36399104 : CZMInterfaceKernelBase::computeQpOffDiagJacobian(Moose::DGJacobianType type, unsigned int jvar)
      88             : {
      89             :   // bail out if jvar is not coupled
      90    36399104 :   if (getJvarMap()[jvar] < 0)
      91             :     return 0.0;
      92             : 
      93             :   // Jacobian of the residul[_component] w.r.t to the coupled displacement
      94             :   // component[off_diag_component]
      95    72662016 :   for (unsigned int off_diag_component = 0; off_diag_component < _ndisp; ++off_diag_component)
      96             :   {
      97    72662016 :     if (jvar == _disp_var[off_diag_component])
      98    36399104 :       return computeDResidualDDisplacement(off_diag_component, type);
      99             :   }
     100             :   // this is the place where one should implement derivatives of the residual w.r.t. other variables
     101           0 :   return 0.0;
     102             : }

Generated by: LCOV version 1.14