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

Generated by: LCOV version 1.14