LCOV - code coverage report
Current view: top level - src/auxkernels - MortarFrictionalStateAux.C (source / functions) Hit Total Coverage
Test: idaholab/moose contact: 8601ad Lines: 32 36 88.9 %
Date: 2025-07-18 13:27:36 Functions: 3 3 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 "MortarFrictionalStateAux.h"
      11             : #include "SystemBase.h"
      12             : 
      13             : registerMooseObject("ContactApp", MortarFrictionalStateAux);
      14             : 
      15             : InputParameters
      16          21 : MortarFrictionalStateAux::validParams()
      17             : {
      18          21 :   InputParameters params = AuxKernel::validParams();
      19          21 :   params.set<ExecFlagEnum>("execute_on") = EXEC_NONLINEAR;
      20          21 :   params.addClassDescription("This class creates discrete states for nodes into frictional "
      21             :                              "contact, including contact/no-contact and stick/slip.");
      22          42 :   params.addRequiredCoupledVar("tangent_one",
      23             :                                "First tangent vector Lagrange multiplier for computing the mortar "
      24             :                                "frictional pressure vector.");
      25          42 :   params.addCoupledVar("tangent_two",
      26             :                        "Second tangent vector Lagrange multiplier for computing the mortar "
      27             :                        "frictional pressure vector.");
      28          42 :   params.addRequiredCoupledVar(
      29             :       "contact_pressure",
      30             :       "Normal contact pressure Lagrange multiplier from the mortar contact enforcement.");
      31          42 :   params.addRequiredParam<Real>("mu", "Friction coefficient to compute nodal states");
      32          42 :   params.addParam<Real>("tolerance", 1.0e-3, "Tolerance value used to determine the states");
      33          42 :   params.addParam<bool>(
      34          42 :       "use_displaced_mesh", true, "Whether to use the displaced mesh to get the mortar interface.");
      35          21 :   return params;
      36           0 : }
      37             : 
      38          13 : MortarFrictionalStateAux::MortarFrictionalStateAux(const InputParameters & params)
      39             :   : AuxKernel(params),
      40          13 :     _tangent_one(coupledValueLower("tangent_one")),
      41          37 :     _tangent_two(isParamValid("tangent_two") ? coupledValueLower("tangent_two") : _zero),
      42          13 :     _contact_pressure(coupledValueLower("contact_pressure")),
      43          26 :     _use_displaced_mesh(getParam<bool>("use_displaced_mesh")),
      44          26 :     _mu(getParam<Real>("mu")),
      45          39 :     _tolerance(getParam<Real>("tolerance"))
      46             : {
      47             :   // Only consider nodal quantities
      48          13 :   if (!isNodal())
      49           0 :     mooseError("MortarFrictionalStateAux auxiliary kernel can only be used with nodal kernels.");
      50             : 
      51          13 :   if (!_use_displaced_mesh)
      52           0 :     paramError("use_displaced_mesh",
      53             :                "This auxiliary kernel requires the use of displaced meshes to compute the "
      54             :                "frictional pressure vector.");
      55             : 
      56             :   // Kernel need to be boundary restricted
      57          13 :   if (!this->_bnd)
      58           0 :     paramError("boundary",
      59             :                "MortarFrictionalStateAux auxiliary kernel must be restricted to a boundary.");
      60             : 
      61          13 :   const auto mortar_dimension = _subproblem.mesh().dimension() - 1;
      62          50 :   if (mortar_dimension == 2 && !isParamValid("tangent_two"))
      63           2 :     paramError("tangent_two",
      64             :                "MortarFrictionalStateAux auxiliary kernel requires a second tangent Lagrange "
      65             :                "multiplier for three-dimensional problems");
      66          11 : }
      67             : 
      68             : Real
      69        2070 : MortarFrictionalStateAux::computeValue()
      70             : {
      71             :   // 0-NaN: Error
      72             :   // 1: Node is not in contact
      73             :   // 2: Node is in contact and sticking
      74             :   // 3: Node is in contact and sliding
      75             : 
      76             :   Real status = 1;
      77             : 
      78        2070 :   if (_contact_pressure[_qp] > _tolerance)
      79             :     status = 2;
      80             : 
      81             :   const Real tangential_pressure =
      82        2070 :       std::sqrt(_tangent_one[_qp] * _tangent_one[_qp] + _tangent_two[_qp] * _tangent_two[_qp]);
      83             : 
      84        2070 :   const Real tangential_pressure_sat = _mu * _contact_pressure[_qp];
      85             : 
      86        2070 :   if (status == 2 && tangential_pressure * (1.0 + _tolerance) > tangential_pressure_sat)
      87             :     status = 3;
      88             : 
      89        2070 :   return status;
      90             : }

Generated by: LCOV version 1.14