https://mooseframework.inl.gov
Loading...
Searching...
No Matches
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
35void
36ArrayBodyForce::computeQpResidual(RealEigenVector & residual)
37{
38 for (unsigned int p = 0; p < _count; ++p)
39 residual(p) = -_test[_i][_qp] * _func[p]->value(_t, _q_point[_qp]);
40}
registerMooseObject("MooseApp", ArrayBodyForce)
ArrayBodyForce(const InputParameters &parameters)
std::vector< const Function * > _func
static InputParameters validParams()
virtual void computeQpResidual(RealEigenVector &residual) override
Compute this Kernel's contribution to the residual at the current quadrature point,...
const ArrayVariableTestValue & _test
the current test function
Definition ArrayKernel.h:88
static InputParameters validParams()
Definition ArrayKernel.C:23
const unsigned int _count
Number of components of the array variable.
ArrayMooseVariable & _var
This is an array kernel so we cast to a ArrayMooseVariable.
Definition ArrayKernel.h:85
const Function & getFunctionByName(const FunctionName &name) const
Get a function with a given name.
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...
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.
unsigned int _qp
The current quadrature point index.
Definition KernelBase.h:43
const MooseArray< Point > & _q_point
The physical location of the element's quadrature Points, indexed by _qp.
Definition KernelBase.h:46
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 ...
Definition MooseBase.h:457
unsigned int count() const
Get the number of components Note: For standard and vector variables, the number is one.
virtual const OutputTools< T >::VariableValue & value()
The value of the variable this object is operating on.