LCOV - code coverage report
Current view: top level - src/constraints - ADMortarConstraint.C (source / functions) Hit Total Coverage
Test: idaholab/moose framework: #33390 (250e9c) with base 846a5c Lines: 64 64 100.0 %
Date: 2026-07-31 18:15:22 Functions: 5 5 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 "ADMortarConstraint.h"
      11             : 
      12             : // MOOSE includes
      13             : #include "MooseVariable.h"
      14             : #include "Assembly.h"
      15             : #include "SystemBase.h"
      16             : #include "ADUtils.h"
      17             : 
      18             : InputParameters
      19       32863 : ADMortarConstraint::validParams()
      20             : {
      21       32863 :   InputParameters params = MortarConstraintBase::validParams();
      22       32863 :   return params;
      23             : }
      24             : 
      25        1001 : ADMortarConstraint::ADMortarConstraint(const InputParameters & parameters)
      26             :   : MortarConstraintBase(parameters),
      27         992 :     _lambda_dummy(),
      28         992 :     _lambda(_var ? _var->adSlnLower() : _lambda_dummy),
      29         992 :     _u_secondary(_secondary_var.adSln()),
      30         992 :     _u_primary(_primary_var.adSlnNeighbor()),
      31         992 :     _grad_u_secondary(_secondary_var.adGradSln()),
      32        1993 :     _grad_u_primary(_primary_var.adGradSlnNeighbor())
      33             : {
      34         992 :   _subproblem.haveADObjects(true);
      35         992 : }
      36             : 
      37             : void
      38      935882 : ADMortarConstraint::computeResidual(Moose::MortarType mortar_type)
      39             : {
      40      935882 :   unsigned int test_space_size = 0;
      41      935882 :   switch (mortar_type)
      42             :   {
      43      326462 :     case Moose::MortarType::Secondary:
      44      326462 :       prepareVectorTag(_assembly, _secondary_var.number());
      45      326462 :       test_space_size = _test_secondary.size();
      46      326462 :       break;
      47             : 
      48      326462 :     case Moose::MortarType::Primary:
      49      326462 :       prepareVectorTagNeighbor(_assembly, _primary_var.number());
      50      326462 :       test_space_size = _test_primary.size();
      51      326462 :       break;
      52             : 
      53      282958 :     case Moose::MortarType::Lower:
      54             :       mooseAssert(_var, "LM variable is null");
      55      282958 :       prepareVectorTagLower(_assembly, _var->number());
      56      282958 :       test_space_size = _test.size();
      57      282958 :       break;
      58             :   }
      59             : 
      60     6018234 :   for (_qp = 0; _qp < _qrule_msm->n_points(); _qp++)
      61    71387488 :     for (_i = 0; _i < test_space_size; _i++)
      62    66305136 :       _local_re(_i) += raw_value(_JxW_msm[_qp] * _coord[_qp] * computeQpResidual(mortar_type));
      63             : 
      64      935882 :   accumulateTaggedLocalResidual();
      65      935882 : }
      66             : 
      67             : void
      68      461332 : ADMortarConstraint::computeJacobian(Moose::MortarType mortar_type)
      69             : {
      70      461332 :   std::vector<ADReal> residuals;
      71      461332 :   std::size_t test_space_size = 0;
      72             :   typedef Moose::ConstraintJacobianType JType;
      73             :   typedef Moose::MortarType MType;
      74      461332 :   std::vector<JType> jacobian_types;
      75      461332 :   std::vector<dof_id_type> dof_indices;
      76      461332 :   Real scaling_factor = 1;
      77             : 
      78      461332 :   switch (mortar_type)
      79             :   {
      80      157300 :     case MType::Secondary:
      81      157300 :       dof_indices = _secondary_var.dofIndices();
      82      157300 :       jacobian_types = {JType::SecondarySecondary, JType::SecondaryPrimary, JType::SecondaryLower};
      83      157300 :       scaling_factor = _secondary_var.scalingFactor();
      84      157300 :       break;
      85             : 
      86      157300 :     case MType::Primary:
      87      157300 :       dof_indices = _primary_var.dofIndicesNeighbor();
      88      157300 :       jacobian_types = {JType::PrimarySecondary, JType::PrimaryPrimary, JType::PrimaryLower};
      89      157300 :       scaling_factor = _primary_var.scalingFactor();
      90      157300 :       break;
      91             : 
      92      146732 :     case MType::Lower:
      93             :       mooseAssert(_var, "The Lagrange Multiplier should be non-null if this is getting called");
      94      146732 :       dof_indices = _var->dofIndicesLower();
      95      146732 :       jacobian_types = {JType::LowerSecondary, JType::LowerPrimary, JType::LowerLower};
      96      146732 :       scaling_factor = _var->scalingFactor();
      97      146732 :       break;
      98             :   }
      99      461332 :   test_space_size = dof_indices.size();
     100             : 
     101      461332 :   residuals.resize(test_space_size, 0);
     102     3153564 :   for (_qp = 0; _qp < _qrule_msm->n_points(); _qp++)
     103    39000864 :     for (_i = 0; _i < test_space_size; _i++)
     104    36308632 :       residuals[_i] += _JxW_msm[_qp] * _coord[_qp] * computeQpResidual(mortar_type);
     105             : 
     106      461332 :   addResidualsAndJacobianWithoutConstraints(_assembly, residuals, dof_indices, scaling_factor);
     107      461332 : }
     108             : 
     109             : void
     110        2848 : ADMortarConstraint::computeResidualAndJacobian()
     111             : {
     112        2848 :   computeJacobian();
     113        2848 : }

Generated by: LCOV version 1.14