www.mooseframework.org
FunctionScalarAux.C
Go to the documentation of this file.
1 //* This file is part of the MOOSE framework
2 //* https://www.mooseframework.org
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 "FunctionScalarAux.h"
11 #include "Function.h"
12 
14 
17 {
19  params.addClassDescription("Sets a value of a scalar variable based on a function.");
20  params.addRequiredParam<std::vector<FunctionName>>(
21  "function", "The functions to set the scalar variable components.");
22 
23  return params;
24 }
25 
27  : AuxScalarKernel(parameters)
28 {
29  std::vector<FunctionName> funcs = getParam<std::vector<FunctionName>>("function");
30  if (funcs.size() != _var.order())
31  mooseError("number of functions is not equal to the number of scalar variable components");
32 
33  for (const auto & func : funcs)
34  _functions.push_back(&getFunctionByName(func));
35 }
36 
37 Real
39 {
40  return _functions[_i]->value(_t, _point_zero);
41 }
std::vector< const Function * > _functions
MooseVariableScalar & _var
static InputParameters validParams()
const Point & _point_zero
Zero point.
virtual Real computeValue() override
Compute the value of this kernel.
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system...
registerMooseObject("MooseApp", FunctionScalarAux)
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...
Base class for making kernels that work on auxiliary scalar variables.
Order order() const
Get the order of this variable Note: Order enum can be implicitly converted to unsigned int...
FunctionScalarAux(const InputParameters &parameters)
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
const Function & getFunctionByName(const FunctionName &name) const
Get a function with a given name.
static InputParameters validParams()
void mooseError(Args &&... args) const
Emits an error prefixed with object name and type.
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 _i
Sets a value of a scalar variable based on the function.