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 "LMWeightedVelocitiesUserObject.h" 11 : #include "MooseVariableFE.h" 12 : #include "SystemBase.h" 13 : 14 : registerMooseObject("ContactApp", LMWeightedVelocitiesUserObject); 15 : 16 : InputParameters 17 790 : LMWeightedVelocitiesUserObject::validParams() 18 : { 19 790 : InputParameters params = WeightedVelocitiesUserObject::validParams(); 20 790 : params.addClassDescription("Provides the mortar contact Lagrange multipliers (normal and " 21 : "tangential) for constraint enforcement."); 22 1580 : params.addRequiredCoupledVar( 23 : "lm_variable_normal", 24 : "The Lagrange multiplier variable representing the normal contact pressure value."); 25 1580 : params.addRequiredCoupledVar( 26 : "lm_variable_tangential_one", 27 : "The Lagrange multiplier variable representing the tangential contact pressure along the " 28 : "first tangential direction (the only one in two dimensions)."); 29 1580 : params.addCoupledVar("lm_variable_tangential_two", 30 : "The Lagrange multiplier variable representing the tangential contact " 31 : "pressure along the second tangential direction."); 32 1580 : params.addParam<bool>( 33 1580 : "use_petrov_galerkin", false, "Whether to use the Petrov-Galerkin approach."); 34 1580 : params.addCoupledVar("aux_lm", 35 : "Auxiliary Lagrange multiplier variable that is utilized together with the " 36 : "Petrov-Galerkin approach."); 37 790 : return params; 38 0 : } 39 : 40 395 : LMWeightedVelocitiesUserObject::LMWeightedVelocitiesUserObject(const InputParameters & parameters) 41 : : WeightedGapUserObject(parameters), 42 : WeightedVelocitiesUserObject(parameters), 43 395 : _lm_normal_var(getVar("lm_variable_normal", 0)), 44 395 : _lm_variable_tangential_one(getVar("lm_variable_tangential_one", 0)), 45 395 : _lm_variable_tangential_two(isParamValid("lm_variable_tangential_two") 46 490 : ? getVar("lm_variable_tangential_two", 0) 47 : : nullptr), 48 790 : _use_petrov_galerkin(getParam<bool>("use_petrov_galerkin")), 49 808 : _aux_lm_var(isCoupled("aux_lm") ? getVar("aux_lm", 0) : nullptr) 50 : { 51 : // Check that user inputted a variable 52 885 : auto check_input = [this](const auto var, const auto & var_name) 53 : { 54 1770 : if (isCoupledConstant(var_name)) 55 0 : paramError("lm_variable_normal", 56 : "The Lagrange multiplier variable must be an actual variable and not a constant."); 57 885 : else if (!var) 58 0 : paramError(var_name, 59 : "The Lagrange multiplier variables must be provided and be actual variables."); 60 1280 : }; 61 : 62 395 : check_input(_lm_normal_var, "lm_variable_normal"); 63 395 : check_input(_lm_variable_tangential_one, "lm_variable_tangential_one"); 64 395 : if (_lm_variable_tangential_two) 65 95 : check_input(_lm_variable_tangential_two, "lm_variable_tangential_two"); 66 : 67 : // Check that user inputted the right type of variable 68 885 : auto check_type = [this](const auto & var, const auto & var_name) 69 : { 70 885 : if (!var.isNodal()) 71 0 : paramError(var_name, 72 : "The Lagrange multiplier variables must have degrees of freedom exclusively on " 73 : "nodes, e.g. they should probably be of finite element type 'Lagrange'."); 74 1280 : }; 75 : 76 395 : check_type(*_lm_normal_var, "lm_variable_normal"); 77 395 : check_type(*_lm_variable_tangential_one, "lm_variable_tangential_one"); 78 395 : if (_lm_variable_tangential_two) 79 95 : check_type(*_lm_variable_tangential_two, "lm_variable_tangential_two"); 80 : 81 431 : if (_use_petrov_galerkin && ((!isParamValid("aux_lm")) || _aux_lm_var == nullptr)) 82 0 : paramError("use_petrov_galerkin", 83 : "We need to specify an auxiliary variable `aux_lm` while using the Petrov-Galerkin " 84 : "approach"); 85 : 86 395 : if (_use_petrov_galerkin && _aux_lm_var->useDual()) 87 0 : paramError("aux_lm", 88 : "Auxiliary LM variable needs to use standard shape function, i.e., set `use_dual = " 89 : "false`."); 90 395 : } 91 : 92 : const ADVariableValue & 93 79343440 : LMWeightedVelocitiesUserObject::contactTangentialPressureDirOne() const 94 : { 95 79343440 : return _lm_variable_tangential_one->adSlnLower(); 96 : } 97 : 98 : const ADVariableValue & 99 73766400 : LMWeightedVelocitiesUserObject::contactTangentialPressureDirTwo() const 100 : { 101 73766400 : return _lm_variable_tangential_two->adSlnLower(); 102 : } 103 : 104 : const ADVariableValue & 105 79343440 : LMWeightedVelocitiesUserObject::contactPressure() const 106 : { 107 79343440 : return _lm_normal_var->adSlnLower(); 108 : } 109 : 110 : const VariableTestValue & 111 393 : LMWeightedVelocitiesUserObject::test() const 112 : { 113 393 : return _use_petrov_galerkin ? _aux_lm_var->phiLower() : _lm_normal_var->phiLower(); 114 : }