LCOV - code coverage report
Current view: top level - src/kernels - MassMatrix.C (source / functions) Hit Total Coverage
Test: idaholab/moose framework: #31405 (292dce) with base fef103 Lines: 22 29 75.9 %
Date: 2025-09-04 07:52:05 Functions: 4 5 80.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 "Kernel.h"
      11             : #include "MassMatrix.h"
      12             : #include "MaterialProperty.h"
      13             : #include "Registry.h"
      14             : #include "MooseStaticCondensationPreconditioner.h"
      15             : #include "NonlinearSystemBase.h"
      16             : #include "libmesh/system.h"
      17             : 
      18             : registerMooseObject("MooseApp", MassMatrix);
      19             : 
      20             : void
      21       14292 : MassMatrix::setMassMatrixParams(InputParameters & params)
      22             : {
      23       57168 :   params.set<MultiMooseEnum>("vector_tags") = "";
      24       57168 :   params.set<MultiMooseEnum>("matrix_tags") = "";
      25       28584 :   params.suppressParameter<MultiMooseEnum>("vector_tags");
      26       28584 :   params.suppressParameter<std::vector<TagName>>("extra_vector_tags");
      27       28584 :   params.suppressParameter<std::vector<TagName>>("absolute_value_vector_tags");
      28       14292 :   params.set<bool>("matrix_only") = true;
      29       14292 : }
      30             : 
      31             : InputParameters
      32       14292 : MassMatrix::validParams()
      33             : {
      34       14292 :   InputParameters params = Kernel::validParams();
      35       14292 :   params.addClassDescription("Computes a finite element mass matrix");
      36       14292 :   setMassMatrixParams(params);
      37       42876 :   params.addParam<MaterialPropertyName>("density", 1, "The material property defining the density");
      38       14292 :   return params;
      39           0 : }
      40             : 
      41          14 : MassMatrix::MassMatrix(const InputParameters & parameters)
      42          28 :   : Kernel(parameters), _density(getMaterialProperty<Real>("density"))
      43             : {
      44          42 :   if (!isParamValid("matrix_tags") && !isParamValid("extra_matrix_tags"))
      45           0 :     mooseError("One of 'matrix_tags' or 'extra_matrix_tags' must be provided");
      46          14 :   if (_sys.system().has_static_condensation() &&
      47           0 :       dynamic_cast<const MooseStaticCondensationPreconditioner *>(
      48          14 :           cast_ref<NonlinearSystemBase &>(_sys).getPreconditioner()) &&
      49           0 :       _var.getContinuity() == libMesh::DISCONTINUOUS)
      50           0 :     mooseError("Elemental mass matrices likely don't make sense when using static condensation");
      51          14 : }
      52             : 
      53             : Real
      54           0 : MassMatrix::computeQpResidual()
      55             : {
      56           0 :   mooseError("Residual should not be calculated for the MassMatrix kernel");
      57             : }
      58             : 
      59             : Real
      60        2304 : MassMatrix::computeQpJacobian()
      61             : {
      62        2304 :   return _test[_i][_qp] * _density[_qp] * _phi[_j][_qp];
      63             : }

Generated by: LCOV version 1.14