LCOV - code coverage report
Current view: top level - src/userobjects - LMWeightedGapUserObject.C (source / functions) Hit Total Coverage
Test: idaholab/moose contact: 8601ad Lines: 22 28 78.6 %
Date: 2025-07-18 13:27:36 Functions: 4 4 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 "LMWeightedGapUserObject.h"
      11             : #include "MooseVariableFE.h"
      12             : #include "SystemBase.h"
      13             : 
      14             : registerMooseObject("ContactApp", LMWeightedGapUserObject);
      15             : 
      16             : InputParameters
      17         780 : LMWeightedGapUserObject::validParams()
      18             : {
      19         780 :   InputParameters params = WeightedGapUserObject::validParams();
      20         780 :   params.addClassDescription(
      21             :       "Provides the mortar normal Lagrange multiplier for constraint enforcement.");
      22        1560 :   params.addRequiredCoupledVar(
      23             :       "lm_variable", "The Lagrange multiplier variable representing the contact pressure.");
      24        1560 :   params.addParam<bool>(
      25        1560 :       "use_petrov_galerkin", false, "Whether to use the Petrov-Galerkin approach.");
      26        1560 :   params.addCoupledVar("aux_lm",
      27             :                        "Auxiliary Lagrange multiplier variable that is utilized together with the "
      28             :                        "Petrov-Galerkin approach.");
      29         780 :   return params;
      30           0 : }
      31             : 
      32         390 : LMWeightedGapUserObject::LMWeightedGapUserObject(const InputParameters & parameters)
      33             :   : WeightedGapUserObject(parameters),
      34         390 :     _lm_var(getVar("lm_variable", 0)),
      35         780 :     _use_petrov_galerkin(getParam<bool>("use_petrov_galerkin")),
      36         812 :     _aux_lm_var(isCoupled("aux_lm") ? getVar("aux_lm", 0) : nullptr)
      37             : {
      38         780 :   if (isCoupledConstant("lm_variable"))
      39           0 :     paramError("lm_variable",
      40             :                "The Lagrange multiplier variable must be an actual variable and not a constant.");
      41         390 :   else if (!_lm_var)
      42           0 :     paramError("lm_variable",
      43             :                "The Lagrange multiplier variable must be provided and be an actual variable.");
      44             : 
      45         390 :   if (!_lm_var->isNodal())
      46           0 :     paramError("lm_variable",
      47             :                "The Lagrange multiplier variable must have its degrees of freedom exclusively on "
      48             :                "nodes, e.g. it should probably be of finite element type 'Lagrange'.");
      49             : 
      50         454 :   if (_use_petrov_galerkin && ((!isParamValid("aux_lm")) || _aux_lm_var == nullptr))
      51           0 :     paramError("use_petrov_galerkin",
      52             :                "We need to specify an auxiliary variable `aux_lm` while using the Petrov-Galerkin "
      53             :                "approach");
      54             : 
      55         390 :   if (_use_petrov_galerkin && _aux_lm_var->useDual())
      56           0 :     paramError("aux_lm",
      57             :                "Auxiliary LM variable needs to use standard shape function, i.e., set `use_dual = "
      58             :                "false`.");
      59         390 : }
      60             : 
      61             : const VariableTestValue &
      62         377 : LMWeightedGapUserObject::test() const
      63             : {
      64         377 :   return _use_petrov_galerkin ? _aux_lm_var->phiLower() : _lm_var->phiLower();
      65             : }
      66             : 
      67             : const ADVariableValue &
      68    82796548 : LMWeightedGapUserObject::contactPressure() const
      69             : {
      70    82796548 :   return _lm_var->adSlnLower();
      71             : }

Generated by: LCOV version 1.14