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 "TangentialMortarMechanicalContact.h" 11 : #include "WeightedVelocitiesUserObject.h" 12 : #include "AutomaticMortarGeneration.h" 13 : 14 : registerMooseObject("ContactApp", TangentialMortarMechanicalContact); 15 : 16 : InputParameters 17 2411 : TangentialMortarMechanicalContact::validParams() 18 : { 19 2411 : InputParameters params = ADMortarLagrangeConstraint::validParams(); 20 : 21 4822 : MooseEnum component("x=0 y=1 z=2"); 22 4822 : params.addRequiredParam<MooseEnum>( 23 : "component", component, "The force component constraint that this object is supplying"); 24 : 25 : // This enum is used to pick the proper 'tangent' vector (i.e. tangent or binormal) 26 4822 : MooseEnum direction("direction_1 direction_2", "direction_1"); 27 4822 : params.addParam<MooseEnum>("direction", 28 : direction, 29 : "Tangent direction to compute the residual due to frictional contact"); 30 2411 : params.addClassDescription( 31 : "Used to apply tangential stresses from frictional contact using lagrange multipliers"); 32 4822 : params.addRequiredParam<UserObjectName>("weighted_velocities_uo", 33 : "The weighted velocities user object."); 34 2411 : params.set<bool>("interpolate_normals") = false; 35 2411 : params.set<bool>("compute_lm_residual") = false; 36 2411 : return params; 37 2411 : } 38 : 39 1346 : TangentialMortarMechanicalContact::TangentialMortarMechanicalContact( 40 1346 : const InputParameters & parameters) 41 : : ADMortarLagrangeConstraint(parameters), 42 1346 : _component(getParam<MooseEnum>("component")), 43 2692 : _direction(getParam<MooseEnum>("direction")), 44 1346 : _weighted_velocities_uo(const_cast<WeightedVelocitiesUserObject &>( 45 2692 : getUserObject<WeightedVelocitiesUserObject>("weighted_velocities_uo"))) 46 : { 47 1346 : } 48 : 49 : ADReal 50 161395376 : TangentialMortarMechanicalContact::computeQpResidual(Moose::MortarType type) 51 : { 52 161395376 : const auto & nodal_tangents = amg().getNodalTangents(*_lower_secondary_elem); 53 322790752 : MooseEnum direction("direction_1 direction_2", "direction_1"); 54 : 55 : const auto tangential_pressure = 56 161395376 : _direction.compareCurrent(direction) 57 84183728 : ? _weighted_velocities_uo.contactTangentialPressureDirOne()[_qp] 58 245579104 : : _weighted_velocities_uo.contactTangentialPressureDirTwo()[_qp]; 59 : 60 161395376 : switch (type) 61 : { 62 80697688 : case Moose::MortarType::Secondary: 63 : // We have taken the convention the lagrange multiplier must have the same sign as the 64 : // relative slip velocity of the secondary face. So positive lambda indicates that force is 65 : // being applied in the negative direction, so we want to decrease the momentum in the system, 66 : // which means we want an outflow of momentum, which means we want the residual to be positive 67 : // in that case. Negative lambda means force is being applied in the positive direction, so we 68 : // want to increase momentum in the system, which means we want an inflow of momentum, which 69 : // means we want the residual to be negative in that case. So the sign of this residual should 70 : // be the same as the sign of lambda 71 : { 72 80697688 : const unsigned int tangent_index = libmesh_map_find(_secondary_ip_lowerd_map, _i); 73 80697688 : return _test_secondary[_i][_qp] * tangential_pressure * 74 : nodal_tangents[_direction][tangent_index](_component) / 75 161395376 : nodal_tangents[_direction][tangent_index].norm(); 76 : } 77 80697688 : case Moose::MortarType::Primary: 78 : { 79 80697688 : const unsigned int tangent_index = libmesh_map_find(_primary_ip_lowerd_map, _i); 80 161395376 : return -_test_primary[_i][_qp] * tangential_pressure * 81 80697688 : nodal_tangents[_direction][tangent_index](_component) / 82 161395376 : nodal_tangents[_direction][tangent_index].norm(); 83 : } 84 0 : default: 85 0 : return 0; 86 : } 87 161395376 : }