LCOV - code coverage report
Current view: top level - src/constraints - EqualValueConstraint.C (source / functions) Hit Total Coverage
Test: idaholab/moose framework: #32971 (54bef8) with base c6cf66 Lines: 43 46 93.5 %
Date: 2026-05-29 20:35:17 Functions: 3 3 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 "EqualValueConstraint.h"
      11             : #include "SubProblem.h"
      12             : #include "FEProblem.h"
      13             : #include "Assembly.h"
      14             : 
      15             : registerMooseObject("MooseApp", EqualValueConstraint);
      16             : 
      17             : InputParameters
      18        3877 : EqualValueConstraint::validParams()
      19             : {
      20        3877 :   InputParameters params = ADMortarConstraint::validParams();
      21        7754 :   params.addClassDescription(
      22             :       "EqualValueConstraint enforces solution continuity between secondary and "
      23             :       "primary sides of a mortar interface using lagrange multipliers");
      24       23262 :   params.addRangeCheckedParam<Real>(
      25             :       "delta", 0, "0<=delta<=1", "The coefficient for stabilizing terms");
      26       11631 :   params.addParam<MaterialPropertyName>(
      27        7754 :       "diff_secondary", 1, "The diffusivity on the secondary side");
      28       11631 :   params.addParam<MaterialPropertyName>("diff_primary", 1, "The diffusivity on the primary side");
      29        3877 :   return params;
      30           0 : }
      31             : 
      32         408 : EqualValueConstraint::EqualValueConstraint(const InputParameters & parameters)
      33             :   : ADMortarConstraint(parameters),
      34         816 :     _lower_secondary_volume(_assembly.lowerDElemVolume()),
      35         408 :     _lower_primary_volume(_assembly.neighborLowerDElemVolume()),
      36         816 :     _delta(getParam<Real>("delta")),
      37         816 :     _diff_secondary(getADMaterialProperty<Real>("diff_secondary")),
      38         816 :     _diff_primary(getADMaterialProperty<Real>("diff_primary")),
      39         408 :     _stabilize(_delta > TOLERANCE * TOLERANCE)
      40             : {
      41         408 : }
      42             : 
      43             : ADReal
      44    20871668 : EqualValueConstraint::computeQpResidual(Moose::MortarType mortar_type)
      45             : {
      46    20871668 :   switch (mortar_type)
      47             :   {
      48     9396080 :     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     9396080 :       auto residual = -_lambda[_qp] * _test_secondary[_i][_qp];
      53             : 
      54     9396080 :       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     9396080 :       return residual;
      60     9396080 :     }
      61             : 
      62     9410864 :     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     9410864 :       auto residual = _lambda[_qp] * _test_primary[_i][_qp];
      67             : 
      68     9410864 :       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     9410864 :       return residual;
      74     9410864 :     }
      75             : 
      76     2064724 :     case Moose::MortarType::Lower:
      77             :     {
      78     2064724 :       auto residual = (_u_primary[_qp] - _u_secondary[_qp]) * _test[_i][_qp];
      79             : 
      80     2064724 :       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     2064724 :       return residual;
      92     2064724 :     }
      93             : 
      94           0 :     default:
      95           0 :       return 0;
      96             :   }
      97             : }

Generated by: LCOV version 1.14