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 "PenaltyEqualValueConstraint.h" 11 : 12 : registerMooseObject("MooseApp", PenaltyEqualValueConstraint); 13 : registerMooseObject("MooseApp", ADPenaltyEqualValueConstraint); 14 : 15 : template <bool is_ad> 16 : InputParameters 17 29124 : PenaltyEqualValueConstraintTempl<is_ad>::validParams() 18 : { 19 29124 : InputParameters params = MortarConstraintTempl<is_ad>::validParams(); 20 29124 : params.addClassDescription( 21 : "PenaltyEqualValueConstraint enforces solution continuity between secondary and " 22 : "primary sides of a mortar interface using a penalty approach (no Lagrange multipliers " 23 : "needed)"); 24 29124 : params.addRequiredRangeCheckedParam<Real>( 25 : "penalty_value", 26 : "penalty_value>0", 27 : "Penalty value used to impose a generalized force capturing the mortar constraint equation"); 28 29124 : return params; 29 0 : } 30 : 31 : template <bool is_ad> 32 295 : PenaltyEqualValueConstraintTempl<is_ad>::PenaltyEqualValueConstraintTempl( 33 : const InputParameters & parameters) 34 : : MortarConstraintTempl<is_ad>(parameters), 35 295 : _penalty_value(this->template getParam<Real>("penalty_value")) 36 : { 37 295 : } 38 : 39 : template <bool is_ad> 40 : GenericReal<is_ad> 41 14884928 : PenaltyEqualValueConstraintTempl<is_ad>::computeQpResidual(Moose::MortarType mortar_type) 42 : { 43 14884928 : switch (mortar_type) 44 : { 45 7442464 : case Moose::MortarType::Secondary: 46 : { 47 7442464 : auto residual = 48 7442464 : -(_u_primary[_qp] - _u_secondary[_qp]) * _penalty_value * _test_secondary[_i][_qp]; 49 : 50 7442464 : return residual; 51 3739616 : } 52 : 53 7442464 : case Moose::MortarType::Primary: 54 : { 55 7442464 : auto residual = 56 7442464 : (_u_primary[_qp] - _u_secondary[_qp]) * _penalty_value * _test_primary[_i][_qp]; 57 : 58 7442464 : return residual; 59 3739616 : } 60 : 61 0 : default: 62 0 : return 0; 63 : } 64 : } 65 : 66 : template <> 67 : ADReal 68 0 : PenaltyEqualValueConstraintTempl<true>::computeQpJacobian( 69 : Moose::ConstraintJacobianType /*jacobian_type*/, unsigned int /*jvar*/) 70 : { 71 0 : mooseError("ADPenaltyEqualValueConstraint does not implement manual Jacobian calculation."); 72 : } 73 : 74 : template <> 75 : Real 76 129592832 : PenaltyEqualValueConstraintTempl<false>::computeQpJacobian( 77 : Moose::ConstraintJacobianType jacobian_type, unsigned int jvar) 78 : { 79 : typedef Moose::ConstraintJacobianType JType; 80 : 81 129592832 : switch (jacobian_type) 82 : { 83 32353408 : case JType::SecondarySecondary: 84 32353408 : if (jvar == _secondary_var.number()) 85 32353408 : return (*_phi)[_j][_qp] * _penalty_value * _test_secondary[_i][_qp]; 86 0 : break; 87 : 88 32353408 : case JType::SecondaryPrimary: 89 32353408 : if (jvar == _primary_var.number()) 90 32353408 : return -(*_phi)[_j][_qp] * _penalty_value * _test_secondary[_i][_qp]; 91 0 : break; 92 : 93 32353408 : case JType::PrimarySecondary: 94 32353408 : if (jvar == _secondary_var.number()) 95 32353408 : return -(*_phi)[_j][_qp] * _penalty_value * _test_primary[_i][_qp]; 96 0 : break; 97 : 98 32353408 : case JType::PrimaryPrimary: 99 32353408 : if (jvar == _primary_var.number()) 100 32353408 : return (*_phi)[_j][_qp] * _penalty_value * _test_primary[_i][_qp]; 101 0 : break; 102 : 103 179200 : default: 104 179200 : return 0; 105 : } 106 : 107 0 : return 0; 108 : } 109 : 110 : template class PenaltyEqualValueConstraintTempl<false>; 111 : template class PenaltyEqualValueConstraintTempl<true>;