LCOV - code coverage report
Current view: top level - src/constraints - TangentialMortarMechanicalContact.C (source / functions) Hit Total Coverage
Test: idaholab/moose contact: 8601ad Lines: 37 39 94.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 "TangentialMortarMechanicalContact.h"
      11             : #include "WeightedVelocitiesUserObject.h"
      12             : 
      13             : registerMooseObject("ContactApp", TangentialMortarMechanicalContact);
      14             : 
      15             : InputParameters
      16        2338 : TangentialMortarMechanicalContact::validParams()
      17             : {
      18        2338 :   InputParameters params = ADMortarLagrangeConstraint::validParams();
      19             : 
      20        4676 :   MooseEnum component("x=0 y=1 z=2");
      21        4676 :   params.addRequiredParam<MooseEnum>(
      22             :       "component", component, "The force component constraint that this object is supplying");
      23             : 
      24             :   // This enum is used to pick the proper 'tangent' vector (i.e. tangent or binormal)
      25        4676 :   MooseEnum direction("direction_1 direction_2", "direction_1");
      26        4676 :   params.addParam<MooseEnum>("direction",
      27             :                              direction,
      28             :                              "Tangent direction to compute the residual due to frictional contact");
      29        2338 :   params.addClassDescription(
      30             :       "Used to apply tangential stresses from frictional contact using lagrange multipliers");
      31        4676 :   params.addRequiredParam<UserObjectName>("weighted_velocities_uo",
      32             :                                           "The weighted velocities user object.");
      33        2338 :   params.set<bool>("interpolate_normals") = false;
      34        2338 :   params.set<bool>("compute_lm_residual") = false;
      35        2338 :   return params;
      36        2338 : }
      37             : 
      38        1314 : TangentialMortarMechanicalContact::TangentialMortarMechanicalContact(
      39        1314 :     const InputParameters & parameters)
      40             :   : ADMortarLagrangeConstraint(parameters),
      41        1314 :     _component(getParam<MooseEnum>("component")),
      42        2628 :     _direction(getParam<MooseEnum>("direction")),
      43        1314 :     _weighted_velocities_uo(const_cast<WeightedVelocitiesUserObject &>(
      44        2628 :         getUserObject<WeightedVelocitiesUserObject>("weighted_velocities_uo")))
      45             : {
      46        1314 : }
      47             : 
      48             : ADReal
      49   127286928 : TangentialMortarMechanicalContact::computeQpResidual(Moose::MortarType type)
      50             : {
      51   127286928 :   const auto & nodal_tangents = amg().getNodalTangents(*_lower_secondary_elem);
      52   254573856 :   MooseEnum direction("direction_1 direction_2", "direction_1");
      53             : 
      54             :   const auto tangential_pressure =
      55   127286928 :       _direction.compareCurrent(direction)
      56    67015056 :           ? _weighted_velocities_uo.contactTangentialPressureDirOne()[_qp]
      57   194301984 :           : _weighted_velocities_uo.contactTangentialPressureDirTwo()[_qp];
      58             : 
      59   127286928 :   switch (type)
      60             :   {
      61    63643464 :     case Moose::MortarType::Secondary:
      62             :       // We have taken the convention the lagrange multiplier must have the same sign as the
      63             :       // relative slip velocity of the secondary face. So positive lambda indicates that force is
      64             :       // being applied in the negative direction, so we want to decrease the momentum in the system,
      65             :       // which means we want an outflow of momentum, which means we want the residual to be positive
      66             :       // in that case. Negative lambda means force is being applied in the positive direction, so we
      67             :       // want to increase momentum in the system, which means we want an inflow of momentum, which
      68             :       // means we want the residual to be negative in that case. So the sign of this residual should
      69             :       // be the same as the sign of lambda
      70             :       {
      71    63643464 :         const unsigned int tangent_index = libmesh_map_find(_secondary_ip_lowerd_map, _i);
      72   127286928 :         return _test_secondary[_i][_qp] * tangential_pressure *
      73    63643464 :                nodal_tangents[_direction][tangent_index](_component) /
      74   190930392 :                nodal_tangents[_direction][tangent_index].norm();
      75             :       }
      76    63643464 :     case Moose::MortarType::Primary:
      77             :     {
      78    63643464 :       const unsigned int tangent_index = libmesh_map_find(_primary_ip_lowerd_map, _i);
      79   127286928 :       return -_test_primary[_i][_qp] * tangential_pressure *
      80    63643464 :              nodal_tangents[_direction][tangent_index](_component) /
      81   127286928 :              nodal_tangents[_direction][tangent_index].norm();
      82             :     }
      83           0 :     default:
      84           0 :       return 0;
      85             :   }
      86   127286928 : }

Generated by: LCOV version 1.14