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 "EqualValueConstraint.h" 11 : #include "SubProblem.h" 12 : #include "FEProblem.h" 13 : #include "Assembly.h" 14 : 15 : registerMooseObject("MooseApp", EqualValueConstraint); 16 : 17 : InputParameters 18 15013 : EqualValueConstraint::validParams() 19 : { 20 15013 : InputParameters params = ADMortarConstraint::validParams(); 21 15013 : params.addClassDescription( 22 : "EqualValueConstraint enforces solution continuity between secondary and " 23 : "primary sides of a mortar interface using lagrange multipliers"); 24 15013 : params.addRangeCheckedParam<Real>( 25 : "delta", 0, "0<=delta<=1", "The coefficient for stabilizing terms"); 26 45039 : params.addParam<MaterialPropertyName>( 27 30026 : "diff_secondary", 1, "The diffusivity on the secondary side"); 28 15013 : params.addParam<MaterialPropertyName>("diff_primary", 1, "The diffusivity on the primary side"); 29 15013 : return params; 30 0 : } 31 : 32 374 : EqualValueConstraint::EqualValueConstraint(const InputParameters & parameters) 33 : : ADMortarConstraint(parameters), 34 748 : _lower_secondary_volume(_assembly.lowerDElemVolume()), 35 374 : _lower_primary_volume(_assembly.neighborLowerDElemVolume()), 36 374 : _delta(getParam<Real>("delta")), 37 374 : _diff_secondary(getADMaterialProperty<Real>("diff_secondary")), 38 374 : _diff_primary(getADMaterialProperty<Real>("diff_primary")), 39 374 : _stabilize(_delta > TOLERANCE * TOLERANCE) 40 : { 41 374 : } 42 : 43 : ADReal 44 20551020 : EqualValueConstraint::computeQpResidual(Moose::MortarType mortar_type) 45 : { 46 20551020 : switch (mortar_type) 47 : { 48 9245964 : case Moose::MortarType::Secondary: 49 : { 50 : // The sign choice here makes it so that for the true solution: lambda = normals_secondary * 51 : // diff_secondary * grad_u_secondary 52 9245964 : auto residual = -_lambda[_qp] * _test_secondary[_i][_qp]; 53 : 54 9245964 : if (_stabilize) 55 856576 : residual += _delta * _lower_secondary_volume * 56 1713152 : (_diff_secondary[_qp] * _grad_test_secondary[_i][_qp] * _normals[_qp]) * 57 1284864 : (_lambda[_qp] - _diff_secondary[_qp] * _grad_u_secondary[_qp] * _normals[_qp]); 58 : 59 9245964 : return residual; 60 9245964 : } 61 : 62 9260748 : case Moose::MortarType::Primary: 63 : { 64 : // The sign choice here makes it so that for the true solution: lambda = -normals_primary * 65 : // diff_primary * grad_u_primary 66 9260748 : auto residual = _lambda[_qp] * _test_primary[_i][_qp]; 67 : 68 9260748 : if (_stabilize) 69 868864 : residual -= _delta * _lower_primary_volume * 70 1737728 : (_diff_primary[_qp] * _grad_test_primary[_i][_qp] * _normals[_qp]) * 71 1303296 : (_diff_primary[_qp] * _grad_u_primary[_qp] * _normals[_qp] - _lambda[_qp]); 72 : 73 9260748 : return residual; 74 9260748 : } 75 : 76 2044308 : case Moose::MortarType::Lower: 77 : { 78 2044308 : auto residual = (_u_primary[_qp] - _u_secondary[_qp]) * _test[_i][_qp]; 79 : 80 2044308 : if (_stabilize) 81 : { 82 : // secondary 83 438272 : residual -= _delta * _lower_secondary_volume * _test[_i][_qp] * 84 657408 : (_lambda[_qp] - _diff_secondary[_qp] * _grad_u_secondary[_qp] * _normals[_qp]); 85 : 86 : // primary 87 438272 : residual -= _delta * _lower_primary_volume * _test[_i][_qp] * 88 657408 : (_lambda[_qp] - _diff_primary[_qp] * _grad_u_primary[_qp] * _normals[_qp]); 89 : } 90 : 91 2044308 : return residual; 92 2044308 : } 93 : 94 0 : default: 95 0 : return 0; 96 : } 97 : }