LCOV - code coverage report
Current view: top level - src/constraints - EqualValueConstraint.C (source / functions) Hit Total Coverage
Test: idaholab/moose framework: 419b9d Lines: 43 46 93.5 %
Date: 2025-08-08 20:01:16 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       15065 : EqualValueConstraint::validParams()
      19             : {
      20       15065 :   InputParameters params = ADMortarConstraint::validParams();
      21       15065 :   params.addClassDescription(
      22             :       "EqualValueConstraint enforces solution continuity between secondary and "
      23             :       "primary sides of a mortar interface using lagrange multipliers");
      24       15065 :   params.addRangeCheckedParam<Real>(
      25             :       "delta", 0, "0<=delta<=1", "The coefficient for stabilizing terms");
      26       45195 :   params.addParam<MaterialPropertyName>(
      27       30130 :       "diff_secondary", 1, "The diffusivity on the secondary side");
      28       15065 :   params.addParam<MaterialPropertyName>("diff_primary", 1, "The diffusivity on the primary side");
      29       15065 :   return params;
      30           0 : }
      31             : 
      32         400 : EqualValueConstraint::EqualValueConstraint(const InputParameters & parameters)
      33             :   : ADMortarConstraint(parameters),
      34         800 :     _lower_secondary_volume(_assembly.lowerDElemVolume()),
      35         400 :     _lower_primary_volume(_assembly.neighborLowerDElemVolume()),
      36         400 :     _delta(getParam<Real>("delta")),
      37         400 :     _diff_secondary(getADMaterialProperty<Real>("diff_secondary")),
      38         400 :     _diff_primary(getADMaterialProperty<Real>("diff_primary")),
      39         400 :     _stabilize(_delta > TOLERANCE * TOLERANCE)
      40             : {
      41         400 : }
      42             : 
      43             : ADReal
      44    20943872 : EqualValueConstraint::computeQpResidual(Moose::MortarType mortar_type)
      45             : {
      46    20943872 :   switch (mortar_type)
      47             :   {
      48     9403340 :     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     9403340 :       auto residual = -_lambda[_qp] * _test_secondary[_i][_qp];
      53             : 
      54     9403340 :       if (_stabilize)
      55      940800 :         residual += _delta * _lower_secondary_volume *
      56     1881600 :                     (_diff_secondary[_qp] * _grad_test_secondary[_i][_qp] * _normals[_qp]) *
      57     1411200 :                     (_lambda[_qp] - _diff_secondary[_qp] * _grad_u_secondary[_qp] * _normals[_qp]);
      58             : 
      59     9403340 :       return residual;
      60     9403340 :     }
      61             : 
      62     9419972 :     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     9419972 :       auto residual = _lambda[_qp] * _test_primary[_i][_qp];
      67             : 
      68     9419972 :       if (_stabilize)
      69      954624 :         residual -= _delta * _lower_primary_volume *
      70     1909248 :                     (_diff_primary[_qp] * _grad_test_primary[_i][_qp] * _normals[_qp]) *
      71     1431936 :                     (_diff_primary[_qp] * _grad_u_primary[_qp] * _normals[_qp] - _lambda[_qp]);
      72             : 
      73     9419972 :       return residual;
      74     9419972 :     }
      75             : 
      76     2120560 :     case Moose::MortarType::Lower:
      77             :     {
      78     2120560 :       auto residual = (_u_primary[_qp] - _u_secondary[_qp]) * _test[_i][_qp];
      79             : 
      80     2120560 :       if (_stabilize)
      81             :       {
      82             :         // secondary
      83      480960 :         residual -= _delta * _lower_secondary_volume * _test[_i][_qp] *
      84      721440 :                     (_lambda[_qp] - _diff_secondary[_qp] * _grad_u_secondary[_qp] * _normals[_qp]);
      85             : 
      86             :         // primary
      87      480960 :         residual -= _delta * _lower_primary_volume * _test[_i][_qp] *
      88      721440 :                     (_lambda[_qp] - _diff_primary[_qp] * _grad_u_primary[_qp] * _normals[_qp]);
      89             :       }
      90             : 
      91     2120560 :       return residual;
      92     2120560 :     }
      93             : 
      94           0 :     default:
      95           0 :       return 0;
      96             :   }
      97             : }

Generated by: LCOV version 1.14