LCOV - code coverage report
Current view: top level - src/auxkernels - PenaltyMortarUserObjectAux.C (source / functions) Hit Total Coverage
Test: idaholab/moose contact: 8601ad Lines: 42 44 95.5 %
Date: 2025-07-18 13:27:36 Functions: 11 15 73.3 %
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 "PenaltyMortarUserObjectAux.h"
      11             : 
      12             : // supported user objects
      13             : #include "WeightedGapUserObject.h"
      14             : #include "PenaltyWeightedGapUserObject.h"
      15             : #include "WeightedVelocitiesUserObject.h"
      16             : #include "PenaltyFrictionUserObject.h"
      17             : 
      18             : registerMooseObject("ContactApp", PenaltyMortarUserObjectAux);
      19             : 
      20             : const MooseEnum PenaltyMortarUserObjectAux::_contact_quantities(
      21             :     "normal_pressure accumulated_slip_one "
      22             :     "tangential_pressure_one tangential_velocity_one accumulated_slip_two "
      23             :     "tangential_pressure_two tangential_velocity_two normal_gap "
      24             :     "normal_lm delta_tangential_lm_one delta_tangential_lm_two active_set");
      25             : 
      26             : InputParameters
      27         808 : PenaltyMortarUserObjectAux::validParams()
      28             : {
      29         808 :   InputParameters params = AuxKernel::validParams();
      30         808 :   params.addClassDescription(
      31             :       "Populates an auxiliary variable with a contact quantities from penalty mortar contact.");
      32        1616 :   params.addRequiredParam<MooseEnum>(
      33             :       "contact_quantity",
      34             :       _contact_quantities,
      35             :       "The desired contact quantity to output as an auxiliary variable.");
      36        1616 :   params.addRequiredParam<UserObjectName>(
      37             :       "user_object",
      38             :       "The penalty mortar user object to get values from.  Note that the user object "
      39             :       "must implement the corresponding getter function.");
      40        2424 :   params.set<ExecFlagEnum>("execute_on") = {EXEC_TIMESTEP_END};
      41         808 :   params.suppressParameter<ExecFlagEnum>("execute_on");
      42         808 :   return params;
      43         808 : }
      44             : 
      45         452 : PenaltyMortarUserObjectAux::PenaltyMortarUserObjectAux(const InputParameters & parameters)
      46             :   : AuxKernel(parameters),
      47         452 :     _contact_quantity(getParam<MooseEnum>("contact_quantity").getEnum<ContactQuantityEnum>()),
      48         904 :     _user_object(getUserObject<UserObject>("user_object")),
      49         452 :     _wguo(dynamic_cast<const WeightedGapUserObject *>(&_user_object)),
      50         452 :     _pwguo(dynamic_cast<const PenaltyWeightedGapUserObject *>(&_user_object)),
      51         452 :     _wvuo(dynamic_cast<const WeightedVelocitiesUserObject *>(&_user_object)),
      52         452 :     _pfuo(dynamic_cast<const PenaltyFrictionUserObject *>(&_user_object)),
      53        5876 :     _outputs({
      54             :         {ContactQuantityEnum::NORMAL_PRESSURE,
      55             :          {"PenaltyWeightedGapUserObject",
      56         452 :           _pwguo,
      57      130148 :           [&]() { return _pwguo->getNormalContactPressure(_current_node); }}},
      58             : 
      59             :         {ContactQuantityEnum::NORMAL_GAP,
      60      124508 :          {"WeightedGapUserObject", _wguo, [&]() { return _wguo->getNormalGap(_current_node); }}},
      61             : 
      62             :         {ContactQuantityEnum::FRICTIONAL_PRESSURE_ONE,
      63             :          {"PenaltyFrictionUserObject",
      64         452 :           _pfuo,
      65      127328 :           [&]() { return _pfuo->getFrictionalContactPressure(_current_node, 0); }}},
      66             : 
      67             :         {ContactQuantityEnum::ACCUMULATED_SLIP_ONE,
      68             :          {"PenaltyFrictionUserObject",
      69             :           _pfuo,
      70      127328 :           [&]() { return _pfuo->getAccumulatedSlip(_current_node, 0); }}},
      71             : 
      72             :         {ContactQuantityEnum::TANGENTIAL_VELOCITY_ONE,
      73             :          {"WeightedVelocitiesUserObject",
      74         452 :           _wvuo,
      75      124508 :           [&]() { return _wvuo->getTangentialVelocity(_current_node, 0); }}},
      76             : 
      77             :         {ContactQuantityEnum::FRICTIONAL_PRESSURE_TWO,
      78             :          {"PenaltyFrictionUserObject",
      79             :           _pfuo,
      80        3272 :           [&]() { return _pfuo->getFrictionalContactPressure(_current_node, 1); }}},
      81             : 
      82             :         {ContactQuantityEnum::ACCUMULATED_SLIP_TWO,
      83             :          {"PenaltyFrictionUserObject",
      84             :           _pfuo,
      85        3272 :           [&]() { return _pfuo->getAccumulatedSlip(_current_node, 1); }}},
      86             : 
      87             :         {ContactQuantityEnum::TANGENTIAL_VELOCITY_TWO,
      88             :          {"WeightedVelocitiesUserObject",
      89             :           _wvuo,
      90         452 :           [&]() { return _wvuo->getTangentialVelocity(_current_node, 1); }}},
      91             : 
      92             :         {ContactQuantityEnum::NORMAL_LM,
      93             :          {"PenaltyWeightedGapUserObject",
      94             :           _pwguo,
      95        1748 :           [&]() { return _pwguo->getNormalLagrangeMultiplier(_current_node); }}},
      96             : 
      97             :         {ContactQuantityEnum::DELTA_TANGENTIAL_LM_ONE,
      98             :          {"PenaltyFrictionUserObject",
      99             :           _wvuo,
     100         452 :           [&]() { return _pfuo->getDeltaTangentialLagrangeMultiplier(_current_node, 0); }}},
     101             : 
     102             :         {ContactQuantityEnum::DELTA_TANGENTIAL_LM_TWO,
     103             :          {"PenaltyFrictionUserObject",
     104             :           _wvuo,
     105         452 :           [&]() { return _pfuo->getDeltaTangentialLagrangeMultiplier(_current_node, 1); }}},
     106             : 
     107             :         {ContactQuantityEnum::ACTIVE_SET,
     108             :          {"PenaltyWeightedGapUserObject",
     109             :           _wvuo,
     110         452 :           [&]() { return _pwguo->getActiveSetState(_current_node) ? 1.0 : 0.0; }}}
     111             :         // end outputs list
     112         452 :     })
     113             : {
     114         452 :   if (!isNodal())
     115           0 :     mooseError("This auxiliary kernel requires nodal variables to obtain contact pressure values");
     116             : 
     117             :   // error check
     118         452 :   const auto it = _outputs.find(_contact_quantity);
     119         452 :   if (it == _outputs.end())
     120           0 :     mooseError("Internal error: Contact quantity request in PressureMortarUserObjectAux is not "
     121             :                "recognized.");
     122         452 :   if (!std::get<1>(it->second))
     123          48 :     paramError("user_object",
     124             :                "The '",
     125          24 :                _contact_quantities.getNames()[static_cast<int>(it->first)],
     126             :                "' quantity is only provided by a '",
     127             :                std::get<0>(it->second),
     128             :                "' or derived object.");
     129        5852 : }
     130             : 
     131             : Real
     132      638496 : PenaltyMortarUserObjectAux::computeValue()
     133             : {
     134             :   // execute functional to retrieve selected quantity
     135      638496 :   return std::get<2>(_outputs[_contact_quantity])();
     136             : }

Generated by: LCOV version 1.14