LCOV - code coverage report
Current view: top level - include/userobjects - PenaltyWeightedGapUserObject.h (source / functions) Hit Total Coverage
Test: idaholab/moose contact: 8601ad Lines: 1 5 20.0 %
Date: 2025-07-18 13:27:36 Functions: 1 3 33.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             : #pragma once
      11             : 
      12             : #include "WeightedGapUserObject.h"
      13             : #include "AugmentedLagrangeInterface.h"
      14             : 
      15             : template <typename>
      16             : class MooseVariableFE;
      17             : class AugmentedLagrangianContactProblemInterface;
      18             : 
      19             : /**
      20             :  * User object for computing weighted gaps and contact pressure for penalty based
      21             :  * mortar constraints
      22             :  */
      23             : class PenaltyWeightedGapUserObject : virtual public WeightedGapUserObject,
      24             :                                      public AugmentedLagrangeInterface
      25             : {
      26             : public:
      27             :   static InputParameters validParams();
      28             : 
      29             :   PenaltyWeightedGapUserObject(const InputParameters & parameters);
      30             : 
      31             :   virtual void timestepSetup() override;
      32             : 
      33             :   virtual const ADVariableValue & contactPressure() const override;
      34             :   virtual void initialize() override;
      35             :   virtual void finalize() override;
      36             :   virtual void reinit() override;
      37             : 
      38             :   virtual Real getNormalContactPressure(const Node * const node) const override;
      39             :   virtual Real getNormalLagrangeMultiplier(const Node * const node) const;
      40             : 
      41           0 :   virtual Real getDeltaTangentialLagrangeMultiplier(const Node * const, const unsigned int) const
      42             :   {
      43           0 :     return 0.0;
      44             :   };
      45           0 :   virtual bool getActiveSetState(const Node * const node) const
      46             :   {
      47           0 :     return _dof_to_normal_pressure.find(_subproblem.mesh().nodePtr(node->id()))->second > 0;
      48             :   }
      49             : 
      50             :   virtual bool isAugmentedLagrangianConverged() override;
      51             :   virtual void augmentedLagrangianSetup() override;
      52             :   virtual void updateAugmentedLagrangianMultipliers() override;
      53             : 
      54             : protected:
      55             :   virtual const VariableTestValue & test() const override;
      56       13362 :   virtual bool constrainedByOwner() const override { return false; }
      57             : 
      58             :   void selfInitialize();
      59             :   void selfFinalize();
      60             :   void selfTimestepSetup();
      61             : 
      62             :   /**
      63             :    * Adaptive, local penalty for AL. See 'The adapted augmented Lagrangian method: a new method for
      64             :    * the resolution of the mechanical frictional contact problem', Comput Mech (2012) 49: 259-275
      65             :    */
      66             :   void
      67             :   bussettaAdaptivePenalty(const Real previous_gap, const Real gap, Real & penalty, Real & eval_tn);
      68             : 
      69             :   /**
      70             :    * See Algorithm 3 of 'The adapted augmented Lagrangian method: a new method for
      71             :    * the resolution of the mechanical frictional contact problem', Comput Mech (2012) 49: 259-275
      72             :    */
      73             :   void adaptiveNormalPenalty(const Real previous_gap, const Real gap, Real & penalty);
      74             : 
      75             :   /// The penalty factor
      76             :   const Real _penalty;
      77             : 
      78             :   /// penalty growth factor for augmented Lagrange
      79             :   const Real _penalty_multiplier;
      80             : 
      81             :   /// penetration tolerance for augmented Lagrange contact
      82             :   const Real _penetration_tolerance;
      83             : 
      84             :   /// The contact pressure on the mortar segument quadrature points
      85             :   ADVariableValue _contact_pressure;
      86             : 
      87             :   /// Map from degree of freedom to normal pressure for reporting
      88             :   std::unordered_map<const DofObject *, ADReal> _dof_to_normal_pressure;
      89             : 
      90             :   ///@{ augmented Lagrange problem and iteration number
      91             :   AugmentedLagrangianContactProblemInterface * const _augmented_lagrange_problem;
      92             :   const static unsigned int _no_iterations;
      93             :   const unsigned int & _lagrangian_iteration_number;
      94             :   ///@}
      95             : 
      96             :   /// Map from degree of freedom to augmented lagrange multiplier
      97             :   std::unordered_map<const DofObject *, Real> _dof_to_lagrange_multiplier;
      98             : 
      99             :   /// Map from degree of freedom to local penalty value
     100             :   std::unordered_map<const DofObject *, Real> _dof_to_local_penalty;
     101             : 
     102             :   /// Map from degree of freedom to previous AL iteration gap values
     103             :   std::unordered_map<const DofObject *, Real> _dof_to_previous_gap;
     104             : 
     105             :   /// Current delta t... or timestep size.
     106             :   const Real & _dt;
     107             : 
     108             :   /// previous timestep size
     109             :   Real _dt_old;
     110             : 
     111             :   /// Use scaled or physical gap
     112             :   const bool _use_physical_gap;
     113             : 
     114             :   /// The auxiliary Lagrange multiplier variable (used together whith the Petrov-Galerkin approach)
     115             :   const MooseVariable * const _aux_lm_var;
     116             : 
     117             :   /// Maximum multiplier applied to the initial penalty factor in AL
     118             :   const Real _max_penalty_multiplier;
     119             : 
     120             :   /// The adaptivity method for the penalty factor at augmentations
     121             :   const enum class AdaptivityNormalPenalty { SIMPLE, BUSSETTA } _adaptivity_normal;
     122             : };

Generated by: LCOV version 1.14