https://mooseframework.inl.gov
MassMatrix.C
Go to the documentation of this file.
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"
15 #include "NonlinearSystemBase.h"
16 #include "libmesh/system.h"
17 
18 registerMooseObject("MooseApp", MassMatrix);
19 
20 void
22 {
23  params.set<MultiMooseEnum>("vector_tags") = "";
24  params.set<MultiMooseEnum>("matrix_tags") = "";
25  params.suppressParameter<MultiMooseEnum>("vector_tags");
26  params.suppressParameter<std::vector<TagName>>("extra_vector_tags");
27  params.suppressParameter<std::vector<TagName>>("absolute_value_vector_tags");
28  params.set<bool>("matrix_only") = true;
29 }
30 
33 {
35  params.addClassDescription("Computes a finite element mass matrix");
36  setMassMatrixParams(params);
37  params.addParam<MaterialPropertyName>("density", 1, "The material property defining the density");
38  return params;
39 }
40 
42  : Kernel(parameters), _density(getMaterialProperty<Real>("density"))
43 {
44  if (!isParamValid("matrix_tags") && !isParamValid("extra_matrix_tags"))
45  mooseError("One of 'matrix_tags' or 'extra_matrix_tags' must be provided");
47  dynamic_cast<const MooseStaticCondensationPreconditioner *>(
48  cast_ref<NonlinearSystemBase &>(_sys).getPreconditioner()) &&
50  mooseError("Elemental mass matrices likely don't make sense when using static condensation");
51 }
52 
53 Real
55 {
56  mooseError("Residual should not be calculated for the MassMatrix kernel");
57 }
58 
59 Real
61 {
62  return _test[_i][_qp] * _density[_qp] * _phi[_j][_qp];
63 }
static void setMassMatrixParams(InputParameters &params)
Definition: MassMatrix.C:21
static InputParameters validParams()
Definition: Kernel.C:24
MooseVariable & _var
This is a regular kernel so we cast to a regular MooseVariable.
Definition: Kernel.h:72
T & set(const std::string &name, bool quiet_mode=false)
Returns a writable reference to the named parameters.
virtual libMesh::System & system()=0
Get the reference to the libMesh system.
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system...
virtual Real computeQpJacobian() override
Compute this Kernel&#39;s contribution to the Jacobian at the current quadrature point.
Definition: MassMatrix.C:60
bool has_static_condensation() const
void suppressParameter(const std::string &name)
This method suppresses an inherited parameter so that it isn&#39;t required or valid in the derived class...
SystemBase & _sys
Reference to the EquationSystem object.
virtual Real computeQpResidual() override
Compute this Kernel&#39;s contribution to the residual at the current quadrature point.
Definition: MassMatrix.C:54
registerMooseObject("MooseApp", MassMatrix)
const MaterialProperty< Real > & _density
The density of the material.
Definition: MassMatrix.h:31
const VariableTestValue & _test
the current test function
Definition: Kernel.h:75
libMesh::FEContinuity getContinuity() const override
Return the continuity of this variable.
unsigned int _i
current index for the test function
Definition: KernelBase.h:58
MassMatrix(const InputParameters &parameters)
Definition: MassMatrix.C:41
unsigned int _j
current index for the shape function
Definition: KernelBase.h:61
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
Computes a finite element mass matrix.
Definition: MassMatrix.h:17
void mooseError(Args &&... args) const
Emits an error prefixed with object name and type and optionally a file path to the top-level block p...
Definition: MooseBase.h:267
Definition: Kernel.h:15
void addClassDescription(const std::string &doc_string)
This method adds a description of the class that will be displayed in the input file syntax dump...
void addParam(const std::string &name, const S &value, const std::string &doc_string)
These methods add an optional parameter and a documentation string to the InputParameters object...
bool isParamValid(const std::string &name) const
Test if the supplied parameter is valid.
Definition: MooseBase.h:195
This is a "smart" enum class intended to replace many of the shortcomings in the C++ enum type...
const VariablePhiValue & _phi
the current shape functions
Definition: Kernel.h:81
static InputParameters validParams()
Definition: MassMatrix.C:32
unsigned int _qp
The current quadrature point index.
Definition: KernelBase.h:43