LCOV - code coverage report
Current view: top level - src/interfacekernels - CZMInterfaceKernelBase.C (source / functions) Hit Total Coverage
Test: idaholab/moose tensor_mechanics: d6b47a Lines: 44 48 91.7 %
Date: 2024-02-27 11:53:14 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://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 "CZMInterfaceKernelBase.h"
      11             : 
      12             : InputParameters
      13         829 : CZMInterfaceKernelBase::validParams()
      14             : {
      15         829 :   InputParameters params = InterfaceKernel::validParams();
      16        1658 :   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         829 :   params.suppressParameter<bool>("use_displaced_mesh");
      23        1658 :   params.addRequiredCoupledVar("displacements", "the string containing displacement variables");
      24        1658 :   params.addParam<std::string>("base_name", "Material property base name");
      25         829 :   params.set<std::string>("traction_global_name") = "traction_global";
      26             : 
      27         829 :   return params;
      28           0 : }
      29             : 
      30         246 : CZMInterfaceKernelBase::CZMInterfaceKernelBase(const InputParameters & parameters)
      31             :   : JvarMapKernelInterface<InterfaceKernel>(parameters),
      32         882 :     _base_name(isParamValid("base_name") && !getParam<std::string>("base_name").empty()
      33         246 :                    ? getParam<std::string>("base_name") + "_"
      34             :                    : ""),
      35         492 :     _component(getParam<unsigned int>("component")),
      36         246 :     _ndisp(coupledComponents("displacements")),
      37         246 :     _disp_var(_ndisp),
      38         246 :     _disp_neighbor_var(_ndisp),
      39         246 :     _vars(_ndisp),
      40         246 :     _traction_global(getMaterialPropertyByName<RealVectorValue>(
      41         492 :         _base_name + getParam<std::string>("traction_global_name"))),
      42         246 :     _dtraction_djump_global(
      43         492 :         getMaterialPropertyByName<RankTwoTensor>(_base_name + "dtraction_djump_global"))
      44             : {
      45             :   // Enforce consistency
      46         246 :   if (_ndisp != _mesh.dimension())
      47           0 :     paramError("displacements", "Number of displacements must match problem dimension.");
      48             : 
      49         246 :   if (_ndisp > 3 || _ndisp < 1)
      50           0 :     mooseError("the CZM material requires 1, 2 or 3 displacement variables");
      51             : 
      52         930 :   for (unsigned int i = 0; i < _ndisp; ++i)
      53             :   {
      54         684 :     _disp_var[i] = coupled("displacements", i);
      55         684 :     _disp_neighbor_var[i] = coupled("displacements", i);
      56         684 :     _vars[i] = getVar("displacements", i);
      57             :   }
      58         246 : }
      59             : 
      60             : Real
      61      956720 : CZMInterfaceKernelBase::computeQpResidual(Moose::DGResidualType type)
      62             : {
      63      956720 :   Real r = _traction_global[_qp](_component);
      64             : 
      65      956720 :   switch (type)
      66             :   {
      67             :     // [test_secondary-test_primary]*T where T represents the traction.
      68      478360 :     case Moose::Element:
      69      478360 :       r *= -_test[_i][_qp];
      70      478360 :       break;
      71      478360 :     case Moose::Neighbor:
      72      478360 :       r *= _test_neighbor[_i][_qp];
      73      478360 :       break;
      74             :   }
      75      956720 :   return r;
      76             : }
      77             : 
      78             : Real
      79     9167936 : 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     9167936 :   return computeDResidualDDisplacement(_component, type);
      84             : }
      85             : 
      86             : Real
      87    18199552 : CZMInterfaceKernelBase::computeQpOffDiagJacobian(Moose::DGJacobianType type, unsigned int jvar)
      88             : {
      89             :   // bail out if jvar is not coupled
      90    18199552 :   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    36331008 :   for (unsigned int off_diag_component = 0; off_diag_component < _ndisp; ++off_diag_component)
      96             :   {
      97    36331008 :     if (jvar == _disp_var[off_diag_component])
      98    18199552 :       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