LCOV - code coverage report
Current view: top level - src/auxkernels - WeightedGapVelAux.C (source / functions) Hit Total Coverage
Test: idaholab/moose contact: 8601ad Lines: 44 47 93.6 %
Date: 2025-07-18 13:27:36 Functions: 5 5 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 "WeightedGapVelAux.h"
      11             : #include "MooseVariableFE.h"
      12             : #include "FEProblemBase.h"
      13             : #include "Assembly.h"
      14             : 
      15             : registerMooseObject("ContactApp", WeightedGapVelAux);
      16             : 
      17             : InputParameters
      18         107 : WeightedGapVelAux::validParams()
      19             : {
      20         107 :   InputParameters params = MortarNodalAuxKernel::validParams();
      21         107 :   params.addClassDescription(
      22             :       "Returns the weighted gap velocity at a node. This quantity is useful for mortar contact, "
      23             :       "particularly when dual basis functions are used in contact mechanics");
      24         214 :   params.addCoupledVar("v",
      25             :                        "Optional variable to take the value of. If omitted the value of the "
      26             :                        "`variable` itself is returned.");
      27         214 :   params.addRequiredCoupledVar("disp_x", "The x displacement variable");
      28         214 :   params.addRequiredCoupledVar("disp_y", "The y displacement variable");
      29         214 :   params.addCoupledVar("disp_z", "The z displacement variable");
      30         107 :   params.set<bool>("interpolate_normals") = false;
      31         214 :   params.addParam<bool>("use_displaced_mesh",
      32         214 :                         true,
      33             :                         "Whether to use the displaced mesh to compute the auxiliary kernel value.");
      34         107 :   return params;
      35           0 : }
      36             : 
      37          62 : WeightedGapVelAux::WeightedGapVelAux(const InputParameters & parameters)
      38             :   : MortarNodalAuxKernel(parameters),
      39          62 :     _has_disp_z(isCoupled("disp_z")),
      40          62 :     _disp_x(*getVar("disp_x", 0)),
      41          62 :     _disp_y(*getVar("disp_y", 0)),
      42          62 :     _disp_z(getVar("disp_z", 0)),
      43          62 :     _secondary_x_dot(_disp_x.adUDot()),
      44          62 :     _primary_x_dot(_disp_x.adUDotNeighbor()),
      45          62 :     _secondary_y_dot(_disp_y.adUDot()),
      46          62 :     _primary_y_dot(_disp_y.adUDotNeighbor()),
      47          62 :     _secondary_z_dot(_has_disp_z ? &_disp_z->adUDot() : nullptr),
      48          62 :     _primary_z_dot(_has_disp_z ? &_disp_z->adUDotNeighbor() : nullptr),
      49          62 :     _weighted_gap_velocity(0),
      50          62 :     _qp_gap_velocity(0),
      51          62 :     _qp_gap_velocity_nodal(0)
      52             : {
      53          62 :   if (!_displaced)
      54           0 :     paramWarning(
      55             :         "use_displaced_mesh",
      56             :         "This auxiliary kernel typically requires the use of displaced meshes to compute the "
      57             :         "weighted gap velocity.");
      58          62 : }
      59             : 
      60             : Real
      61       26000 : WeightedGapVelAux::computeValue()
      62             : {
      63       26000 :   _weighted_gap_velocity = 0;
      64       78000 :   for (_qp = 0; _qp < _qrule_msm->n_points(); _qp++)
      65             :   {
      66       52000 :     computeQpProperties();
      67      156000 :     for (_i = 0; _i < _test_lower.size(); ++_i)
      68      104000 :       computeQpIProperties();
      69             :   }
      70             : 
      71       26000 :   return _weighted_gap_velocity;
      72             : }
      73             : 
      74             : void
      75       52000 : WeightedGapVelAux::computeQpProperties()
      76             : {
      77             :   RealVectorValue gap_velocity_vec;
      78       52000 :   gap_velocity_vec(0) = MetaPhysicL::raw_value(_secondary_x_dot[_qp] - _primary_x_dot[_qp]);
      79       52000 :   gap_velocity_vec(1) = MetaPhysicL::raw_value(_secondary_y_dot[_qp] - _primary_y_dot[_qp]);
      80             : 
      81       52000 :   if (_has_disp_z)
      82           0 :     gap_velocity_vec(2) = MetaPhysicL::raw_value((*_secondary_z_dot)[_qp] - (*_primary_z_dot)[_qp]);
      83             : 
      84       52000 :   _qp_gap_velocity_nodal = gap_velocity_vec * (_JxW_msm[_qp] * _coord_msm[_qp]);
      85             : 
      86       52000 :   _msm_volume += _JxW_msm[_qp] * _coord_msm[_qp];
      87       52000 : }
      88             : 
      89             : void
      90      104000 : WeightedGapVelAux::computeQpIProperties()
      91             : {
      92      104000 :   _weighted_gap_velocity += _test_lower[_i][_qp] * _qp_gap_velocity_nodal * _normals[_i];
      93      104000 : }

Generated by: LCOV version 1.14