LCOV - code coverage report
Current view: top level - src/constraints - NormalMortarMechanicalContact.C (source / functions) Hit Total Coverage
Test: idaholab/moose contact: 8601ad Lines: 27 27 100.0 %
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 "NormalMortarMechanicalContact.h"
      11             : #include "WeightedGapUserObject.h"
      12             : 
      13             : registerMooseObject("ContactApp", NormalMortarMechanicalContact);
      14             : 
      15             : InputParameters
      16        4275 : NormalMortarMechanicalContact::validParams()
      17             : {
      18        4275 :   InputParameters params = ADMortarLagrangeConstraint::validParams();
      19             : 
      20        8550 :   MooseEnum component("x=0 y=1 z=2");
      21        8550 :   params.addRequiredParam<MooseEnum>(
      22             :       "component", component, "The force component constraint that this object is supplying");
      23        4275 :   params.addClassDescription(
      24             :       "This class is used to apply normal contact forces using lagrange multipliers");
      25        4275 :   params.set<bool>("compute_lm_residual") = false;
      26        4275 :   params.set<bool>("interpolate_normals") = false;
      27        8550 :   params.addRequiredParam<UserObjectName>("weighted_gap_uo", "The weighted gap user object.");
      28        4275 :   return params;
      29        4275 : }
      30             : 
      31        2390 : NormalMortarMechanicalContact::NormalMortarMechanicalContact(const InputParameters & parameters)
      32             :   : ADMortarLagrangeConstraint(parameters),
      33        2390 :     _component(getParam<MooseEnum>("component")),
      34        2390 :     _weighted_gap_uo(const_cast<WeightedGapUserObject &>(
      35        4780 :         getUserObject<WeightedGapUserObject>("weighted_gap_uo")))
      36             : {
      37        2390 : }
      38             : 
      39             : ADReal
      40   153214004 : NormalMortarMechanicalContact::computeQpResidual(Moose::MortarType type)
      41             : {
      42   153214004 :   switch (type)
      43             :   {
      44    76583402 :     case Moose::MortarType::Secondary:
      45             :       // If normals is positive, then this residual is positive, indicating that we have an outflow
      46             :       // of momentum, which in turn indicates that the momentum will tend to decrease at this
      47             :       // location with time, which is what we want because the force vector is in the negative
      48             :       // direction (always opposite of the normals). Conversely, if the normals is negative, then
      49             :       // this residual is negative, indicating that we have an inflow of momentum, which in turn
      50             :       // indicates the momentum will tend to increase at this location with time, which is what we
      51             :       // want because the force vector is in the positive direction (always opposite of the
      52             :       // normals).
      53             :       // Get the _dof_to_weighted_gap map
      54             :       {
      55    76583402 :         const auto normal_index = libmesh_map_find(_secondary_ip_lowerd_map, _i);
      56   153166804 :         return _test_secondary[_i][_qp] * _weighted_gap_uo.contactPressure()[_qp] *
      57    76583402 :                _normals[normal_index](_component);
      58             :       }
      59             : 
      60    76583402 :     case Moose::MortarType::Primary:
      61             :       // The normal vector is signed according to the secondary face, so we need to introduce a
      62             :       // negative sign here
      63             :       {
      64    76583402 :         const auto normal_index = libmesh_map_find(_primary_ip_lowerd_map, _i);
      65   153166804 :         return -_test_primary[_i][_qp] * _weighted_gap_uo.contactPressure()[_qp] *
      66    76583402 :                _normals[normal_index](_component);
      67             :       }
      68       47200 :     default:
      69       47200 :       return 0;
      70             :   }
      71             : }

Generated by: LCOV version 1.14