LCOV - code coverage report
Current view: top level - src/scalarkernels/lagrangian - HomogenizationConstraintScalarKernel.C (source / functions) Hit Total Coverage
Test: idaholab/moose solid_mechanics: f45d79 Lines: 32 34 94.1 %
Date: 2025-07-25 05:00:39 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             : //* This file is part of the MOOSE framework
      11             : //* https://mooseframework.inl.gov
      12             : //*
      13             : //* All rights reserved, see COPYRIGHT for full restrictions
      14             : //* https://github.com/idaholab/moose/blob/master/COPYRIGHT
      15             : //*
      16             : //* Licensed under LGPL 2.1, please see LICENSE for details
      17             : //* https://www.gnu.org/licenses/lgpl-2.1.html
      18             : 
      19             : #include "HomogenizationConstraintScalarKernel.h"
      20             : 
      21             : // MOOSE includes
      22             : #include "Assembly.h"
      23             : #include "MooseVariableScalar.h"
      24             : #include "Function.h"
      25             : 
      26             : registerMooseObject("SolidMechanicsApp", HomogenizationConstraintScalarKernel);
      27             : 
      28             : InputParameters
      29         296 : HomogenizationConstraintScalarKernel::validParams()
      30             : {
      31         296 :   InputParameters params = ScalarKernel::validParams();
      32         296 :   params.addClassDescription("Calculate the scalar equation residual and Jacobian associated with "
      33             :                              "the homogenization constraint.");
      34         592 :   params.addRequiredParam<UserObjectName>("homogenization_constraint",
      35             :                                           "The UserObject defining the homogenization constraint");
      36             : 
      37         296 :   return params;
      38           0 : }
      39             : 
      40         148 : HomogenizationConstraintScalarKernel::HomogenizationConstraintScalarKernel(
      41         148 :     const InputParameters & parameters)
      42             :   : ScalarKernel(parameters),
      43         148 :     _constraint(getUserObject<HomogenizationConstraint>("homogenization_constraint")),
      44         148 :     _residual(_constraint.getResidual()),
      45         148 :     _jacobian(_constraint.getJacobian()),
      46         296 :     _cmap(_constraint.getConstraintMap())
      47             : {
      48         148 :   if (_var.order() != _cmap.size())
      49           0 :     mooseError("Homogenization kernel requires a variable of order ", _cmap.size());
      50         148 : }
      51             : 
      52             : void
      53       23978 : HomogenizationConstraintScalarKernel::reinit()
      54             : {
      55       23978 : }
      56             : 
      57             : void
      58       16020 : HomogenizationConstraintScalarKernel::computeResidual()
      59             : {
      60       16020 :   prepareVectorTag(_assembly, _var.number());
      61       16020 :   _i = 0;
      62      129840 :   for (auto && indices : _cmap)
      63             :   {
      64             :     auto && [i, j] = indices.first;
      65      113820 :     _local_re(_i++) += _residual(i, j);
      66             :   }
      67       16020 :   accumulateTaggedLocalResidual();
      68       16020 : }
      69             : 
      70             : void
      71         684 : HomogenizationConstraintScalarKernel::computeJacobian()
      72             : {
      73         684 :   prepareMatrixTag(_assembly, _var.number(), _var.number());
      74         684 :   _i = 0;
      75        3804 :   for (auto && indices1 : _cmap)
      76             :   {
      77             :     auto && [i, j] = indices1.first;
      78        3120 :     _j = 0;
      79       24264 :     for (auto && indices2 : _cmap)
      80             :     {
      81             :       auto && [a, b] = indices2.first;
      82       21144 :       _local_ke(_i, _j++) += _jacobian(i, j, a, b);
      83             :     }
      84        3120 :     _i++;
      85             :   }
      86         684 :   accumulateTaggedLocalMatrix();
      87         684 : }

Generated by: LCOV version 1.14