LCOV - code coverage report
Current view: top level - src/kernels - MassMatrix.C (source / functions) Hit Total Coverage
Test: idaholab/moose framework: 99787a Lines: 22 29 75.9 %
Date: 2025-10-14 20:01:24 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       14855 : MassMatrix::setMassMatrixParams(InputParameters & params)
      22             : {
      23       59420 :   params.set<MultiMooseEnum>("vector_tags") = "";
      24       59420 :   params.set<MultiMooseEnum>("matrix_tags") = "";
      25       29710 :   params.suppressParameter<MultiMooseEnum>("vector_tags");
      26       29710 :   params.suppressParameter<std::vector<TagName>>("extra_vector_tags");
      27       29710 :   params.suppressParameter<std::vector<TagName>>("absolute_value_vector_tags");
      28       14855 :   params.set<bool>("matrix_only") = true;
      29       14855 : }
      30             : 
      31             : InputParameters
      32       14855 : MassMatrix::validParams()
      33             : {
      34       14855 :   InputParameters params = Kernel::validParams();
      35       14855 :   params.addClassDescription("Computes a finite element mass matrix");
      36       14855 :   setMassMatrixParams(params);
      37       44565 :   params.addParam<MaterialPropertyName>("density", 1, "The material property defining the density");
      38       14855 :   return params;
      39           0 : }
      40             : 
      41          56 : MassMatrix::MassMatrix(const InputParameters & parameters)
      42         112 :   : Kernel(parameters), _density(getMaterialProperty<Real>("density"))
      43             : {
      44         168 :   if (!isParamValid("matrix_tags") && !isParamValid("extra_matrix_tags"))
      45           0 :     mooseError("One of 'matrix_tags' or 'extra_matrix_tags' must be provided");
      46          56 :   if (_sys.system().has_static_condensation() &&
      47           0 :       dynamic_cast<const MooseStaticCondensationPreconditioner *>(
      48          56 :           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          56 : }
      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