LCOV - code coverage report
Current view: top level - src/auxkernels - ContactPressureAux.C (source / functions) Hit Total Coverage
Test: idaholab/moose contact: 8601ad Lines: 31 32 96.9 %
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 "ContactPressureAux.h"
      11             : 
      12             : #include "NodalArea.h"
      13             : #include "PenetrationLocator.h"
      14             : 
      15             : #include "libmesh/string_to_enum.h"
      16             : 
      17             : registerMooseObject("ContactApp", ContactPressureAux);
      18             : 
      19             : InputParameters
      20        5033 : ContactPressureAux::validParams()
      21             : {
      22        5033 :   InputParameters params = AuxKernel::validParams();
      23       10066 :   params.addRequiredCoupledVar("nodal_area", "The nodal area");
      24       10066 :   params.addRequiredParam<std::vector<BoundaryName>>(
      25             :       "paired_boundary",
      26             :       "The set of boundaries in contact with those specified in 'boundary'. Ordering must be "
      27             :       "consistent with that in 'boundary'.");
      28        5033 :   params.set<ExecFlagEnum>("execute_on") = EXEC_NONLINEAR;
      29       10066 :   MooseEnum orders("FIRST SECOND THIRD FOURTH", "FIRST");
      30       10066 :   params.addParam<MooseEnum>("order", orders, "The finite element order: " + orders.getRawNames());
      31             : 
      32        5033 :   params.addClassDescription("Computes the contact pressure from the contact force and nodal area");
      33             : 
      34        5033 :   return params;
      35        5033 : }
      36             : 
      37        2707 : ContactPressureAux::ContactPressureAux(const InputParameters & params)
      38             :   : AuxKernel(params),
      39        2707 :     _nodal_area(coupledValue("nodal_area")),
      40        5414 :     _number_pairs(getParam<std::vector<BoundaryName>>("paired_boundary").size()),
      41        5414 :     _penetration_locators(_number_pairs)
      42             : {
      43        5414 :   if (_number_pairs != getParam<std::vector<BoundaryName>>("boundary").size())
      44           0 :     paramError("boundary",
      45             :                "Boundary and paired boundary vectors are not the same size in the contact pressure "
      46             :                "auxiliary kernel. Please check your input");
      47             : 
      48        5763 :   for (const auto i : make_range(_number_pairs))
      49        3056 :     _penetration_locators[i] =
      50       12224 :         &getPenetrationLocator(getParam<std::vector<BoundaryName>>("paired_boundary")[i],
      51        6112 :                                getParam<std::vector<BoundaryName>>("boundary")[i],
      52        6112 :                                Utility::string_to_enum<Order>(getParam<MooseEnum>("order")));
      53        2707 : }
      54             : 
      55        5414 : ContactPressureAux::~ContactPressureAux() {}
      56             : 
      57             : Real
      58      434280 : ContactPressureAux::computeValue()
      59             : {
      60             :   Real value(0);
      61      434280 :   const Real area = _nodal_area[_qp];
      62             :   const PenetrationInfo * penetration_info(nullptr);
      63             : 
      64      982912 :   for (const auto i : make_range(_number_pairs))
      65             :   {
      66      548632 :     const auto it = _penetration_locators[i]->_penetration_info.find(_current_node->id());
      67      548632 :     if (it != _penetration_locators[i]->_penetration_info.end())
      68      457107 :       penetration_info = it->second;
      69             : 
      70      457107 :     if (penetration_info && area != 0)
      71      430758 :       value -= (penetration_info->_contact_force * penetration_info->_normal) / area;
      72             : 
      73             :     penetration_info = nullptr;
      74             :   }
      75             : 
      76      434280 :   return value;
      77             : }

Generated by: LCOV version 1.14