LCOV - code coverage report
Current view: top level - src/constraints - TangentialMortarMechanicalContact.C (source / functions) Hit Total Coverage
Test: idaholab/moose contact: #31405 (292dce) with base fef103 Lines: 37 39 94.9 %
Date: 2025-09-04 07:52:48 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        2441 : TangentialMortarMechanicalContact::validParams()
      17             : {
      18        2441 :   InputParameters params = ADMortarLagrangeConstraint::validParams();
      19             : 
      20        4882 :   MooseEnum component("x=0 y=1 z=2");
      21        4882 :   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        4882 :   MooseEnum direction("direction_1 direction_2", "direction_1");
      26        4882 :   params.addParam<MooseEnum>("direction",
      27             :                              direction,
      28             :                              "Tangent direction to compute the residual due to frictional contact");
      29        2441 :   params.addClassDescription(
      30             :       "Used to apply tangential stresses from frictional contact using lagrange multipliers");
      31        4882 :   params.addRequiredParam<UserObjectName>("weighted_velocities_uo",
      32             :                                           "The weighted velocities user object.");
      33        2441 :   params.set<bool>("interpolate_normals") = false;
      34        2441 :   params.set<bool>("compute_lm_residual") = false;
      35        2441 :   return params;
      36        2441 : }
      37             : 
      38        1366 : TangentialMortarMechanicalContact::TangentialMortarMechanicalContact(
      39        1366 :     const InputParameters & parameters)
      40             :   : ADMortarLagrangeConstraint(parameters),
      41        1366 :     _component(getParam<MooseEnum>("component")),
      42        2732 :     _direction(getParam<MooseEnum>("direction")),
      43        1366 :     _weighted_velocities_uo(const_cast<WeightedVelocitiesUserObject &>(
      44        2732 :         getUserObject<WeightedVelocitiesUserObject>("weighted_velocities_uo")))
      45             : {
      46        1366 : }
      47             : 
      48             : ADReal
      49   161600384 : TangentialMortarMechanicalContact::computeQpResidual(Moose::MortarType type)
      50             : {
      51   161600384 :   const auto & nodal_tangents = amg().getNodalTangents(*_lower_secondary_elem);
      52   323200768 :   MooseEnum direction("direction_1 direction_2", "direction_1");
      53             : 
      54             :   const auto tangential_pressure =
      55   161600384 :       _direction.compareCurrent(direction)
      56    84393344 :           ? _weighted_velocities_uo.contactTangentialPressureDirOne()[_qp]
      57   245993728 :           : _weighted_velocities_uo.contactTangentialPressureDirTwo()[_qp];
      58             : 
      59   161600384 :   switch (type)
      60             :   {
      61    80800192 :     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    80800192 :         const unsigned int tangent_index = libmesh_map_find(_secondary_ip_lowerd_map, _i);
      72   161600384 :         return _test_secondary[_i][_qp] * tangential_pressure *
      73    80800192 :                nodal_tangents[_direction][tangent_index](_component) /
      74   242400576 :                nodal_tangents[_direction][tangent_index].norm();
      75             :       }
      76    80800192 :     case Moose::MortarType::Primary:
      77             :     {
      78    80800192 :       const unsigned int tangent_index = libmesh_map_find(_primary_ip_lowerd_map, _i);
      79   161600384 :       return -_test_primary[_i][_qp] * tangential_pressure *
      80    80800192 :              nodal_tangents[_direction][tangent_index](_component) /
      81   161600384 :              nodal_tangents[_direction][tangent_index].norm();
      82             :     }
      83           0 :     default:
      84           0 :       return 0;
      85             :   }
      86   161600384 : }

Generated by: LCOV version 1.14