LCOV - code coverage report
Current view: top level - src/auxkernels - WeightedGapVelAux.C (source / functions) Hit Total Coverage
Test: idaholab/moose contact: #31405 (292dce) with base fef103 Lines: 44 47 93.6 %
Date: 2025-09-04 07:52:48 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         117 : WeightedGapVelAux::validParams()
      19             : {
      20         117 :   InputParameters params = MortarNodalAuxKernel::validParams();
      21         117 :   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         234 :   params.addCoupledVar("v",
      25             :                        "Optional variable to take the value of. If omitted the value of the "
      26             :                        "`variable` itself is returned.");
      27         234 :   params.addRequiredCoupledVar("disp_x", "The x displacement variable");
      28         234 :   params.addRequiredCoupledVar("disp_y", "The y displacement variable");
      29         234 :   params.addCoupledVar("disp_z", "The z displacement variable");
      30         117 :   params.set<bool>("interpolate_normals") = false;
      31         234 :   params.addParam<bool>("use_displaced_mesh",
      32         234 :                         true,
      33             :                         "Whether to use the displaced mesh to compute the auxiliary kernel value.");
      34         117 :   return params;
      35           0 : }
      36             : 
      37          67 : WeightedGapVelAux::WeightedGapVelAux(const InputParameters & parameters)
      38             :   : MortarNodalAuxKernel(parameters),
      39          67 :     _has_disp_z(isCoupled("disp_z")),
      40          67 :     _disp_x(*getVar("disp_x", 0)),
      41          67 :     _disp_y(*getVar("disp_y", 0)),
      42          67 :     _disp_z(getVar("disp_z", 0)),
      43          67 :     _secondary_x_dot(_disp_x.adUDot()),
      44          67 :     _primary_x_dot(_disp_x.adUDotNeighbor()),
      45          67 :     _secondary_y_dot(_disp_y.adUDot()),
      46          67 :     _primary_y_dot(_disp_y.adUDotNeighbor()),
      47          67 :     _secondary_z_dot(_has_disp_z ? &_disp_z->adUDot() : nullptr),
      48          67 :     _primary_z_dot(_has_disp_z ? &_disp_z->adUDotNeighbor() : nullptr),
      49          67 :     _weighted_gap_velocity(0),
      50          67 :     _qp_gap_velocity(0),
      51          67 :     _qp_gap_velocity_nodal(0)
      52             : {
      53          67 :   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          67 : }
      59             : 
      60             : Real
      61       32400 : WeightedGapVelAux::computeValue()
      62             : {
      63       32400 :   _weighted_gap_velocity = 0;
      64       97200 :   for (_qp = 0; _qp < _qrule_msm->n_points(); _qp++)
      65             :   {
      66       64800 :     computeQpProperties();
      67      194400 :     for (_i = 0; _i < _test_lower.size(); ++_i)
      68      129600 :       computeQpIProperties();
      69             :   }
      70             : 
      71       32400 :   return _weighted_gap_velocity;
      72             : }
      73             : 
      74             : void
      75       64800 : WeightedGapVelAux::computeQpProperties()
      76             : {
      77             :   RealVectorValue gap_velocity_vec;
      78       64800 :   gap_velocity_vec(0) = MetaPhysicL::raw_value(_secondary_x_dot[_qp] - _primary_x_dot[_qp]);
      79       64800 :   gap_velocity_vec(1) = MetaPhysicL::raw_value(_secondary_y_dot[_qp] - _primary_y_dot[_qp]);
      80             : 
      81       64800 :   if (_has_disp_z)
      82           0 :     gap_velocity_vec(2) = MetaPhysicL::raw_value((*_secondary_z_dot)[_qp] - (*_primary_z_dot)[_qp]);
      83             : 
      84       64800 :   _qp_gap_velocity_nodal = gap_velocity_vec * (_JxW_msm[_qp] * _coord_msm[_qp]);
      85             : 
      86       64800 :   _msm_volume += _JxW_msm[_qp] * _coord_msm[_qp];
      87       64800 : }
      88             : 
      89             : void
      90      129600 : WeightedGapVelAux::computeQpIProperties()
      91             : {
      92      129600 :   _weighted_gap_velocity += _test_lower[_i][_qp] * _qp_gap_velocity_nodal * _normals[_i];
      93      129600 : }

Generated by: LCOV version 1.14