https://mooseframework.inl.gov
ArrayBodyForce.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 "ArrayBodyForce.h"
11 
12 #include "Function.h"
13 
15 
18 {
20  params.addRequiredParam<std::vector<FunctionName>>("function", "The body force functions.");
21  params.addClassDescription("Applies body forces specified with functions to an array variable.");
22  return params;
23 }
24 
26 {
27  auto & funcs = getParam<std::vector<FunctionName>>("function");
28  if (_var.count() != funcs.size())
29  paramError("function",
30  "Number of functions must agree with the number of array variable components");
31  for (auto & func : funcs)
32  _func.push_back(&getFunctionByName(func));
33 }
34 
35 void
37 {
38  for (unsigned int p = 0; p < _count; ++p)
39  residual(p) = -_test[_i][_qp] * _func[p]->value(_t, _q_point[_qp]);
40 }
unsigned int count() const
Get the number of components Note: For standard and vector variables, the number is one...
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system...
void addRequiredParam(const std::string &name, const std::string &doc_string)
This method adds a parameter and documentation string to the InputParameters object that will be extr...
static InputParameters validParams()
Definition: ArrayKernel.C:23
registerMooseObject("MooseApp", ArrayBodyForce)
ArrayBodyForce(const InputParameters &parameters)
const ArrayVariableTestValue & _test
the current test function
Definition: ArrayKernel.h:88
unsigned int _i
current index for the test function
Definition: KernelBase.h:58
void paramError(const std::string &param, Args... args) const
Emits an error prefixed with the file and line number of the given param (from the input file) along ...
const unsigned int _count
Number of components of the array variable.
Definition: ArrayKernel.h:107
std::vector< const Function * > _func
const Function & getFunctionByName(const FunctionName &name) const
Get a function with a given name.
virtual void computeQpResidual(RealEigenVector &residual) override
Compute this Kernel&#39;s contribution to the residual at the current quadrature point, to be filled in residual.
static InputParameters validParams()
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...
Eigen::Matrix< Real, Eigen::Dynamic, 1 > RealEigenVector
Definition: MooseTypes.h:146
ArrayMooseVariable & _var
This is an array kernel so we cast to a ArrayMooseVariable.
Definition: ArrayKernel.h:85
const MooseArray< Point > & _q_point
The physical location of the element&#39;s quadrature Points, indexed by _qp.
Definition: KernelBase.h:46
unsigned int _qp
The current quadrature point index.
Definition: KernelBase.h:43