https://mooseframework.inl.gov
LinearFVSource.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 "LinearFVSource.h"
11 #include "Assembly.h"
12 #include "SubProblem.h"
13 
15 
18 {
20  params.addClassDescription(
21  "Represents the matrix and right hand side contributions of a "
22  "solution-independent source term in a partial differential equation.");
23  params.addParam<MooseFunctorName>("source_density", 1.0, "The source density.");
24  params.addParam<MooseFunctorName>(
25  "scaling_factor", 1.0, "Coefficient to multiply the body force term with.");
26  return params;
27 }
28 
30  : LinearFVElementalKernel(params),
31  _source_density(getFunctor<Real>("source_density")),
32  _scale(getFunctor<Real>("scaling_factor"))
33 {
34 }
35 
36 Real
38 {
39  // This doesn't contribute to the matrix as we assumed it was independent of
40  // the solution
41  return 0.0;
42 }
43 
44 Real
46 {
47  const auto elem_arg = makeElemArg(_current_elem_info->elem());
48  const auto state_arg = determineState();
49 
50  // The contribution to the right hand side is s_C*V_C
51  return _scale(elem_arg, state_arg) * _source_density(elem_arg, state_arg) * _current_elem_volume;
52 }
const ElemInfo * _current_elem_info
Pointer to the current element info.
virtual Real computeRightHandSideContribution() override
Computes the right hand side contribution for the given variable on the current element.
virtual Real computeMatrixContribution() override
Computes the system matrix contribution for the given variable on the current element.
Kernel that adds contributions from a external source term discretized using the finite volume method...
static InputParameters validParams()
Moose::StateArg determineState() const
Create a functor state argument that corresponds to the implicit state of this object.
const Elem * elem() const
Definition: ElemInfo.h:34
static InputParameters validParams()
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system...
Finite volume kernel that contributes approximations of volumetric integral terms to the matrix and r...
Moose::ElemArg makeElemArg(const Elem *elem, bool correct_skewnewss=false) const
Helper method to create an elemental argument for a functor that includes whether to perform skewness...
const Moose::Functor< Real > & _source_density
The functor for the source density.
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
const Moose::Functor< Real > & _scale
Scale factor.
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...
Real _current_elem_volume
The coordinate-specific element volume.
LinearFVSource(const InputParameters &params)
Class constructor.
registerMooseObject("MooseApp", LinearFVSource)