www.mooseframework.org
FunctionScalarIC.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 "FunctionScalarIC.h"
11 
12 // MOOSE includes
13 #include "Function.h"
14 #include "MooseVariableScalar.h"
15 
17 
20 {
22  params.addClassDescription("Initializes a scalar variable using a function.");
23  params.addRequiredParam<std::vector<FunctionName>>("function", "The initial condition function.");
24  return params;
25 }
26 
28  : ScalarInitialCondition(parameters), _ncomp(_var.order())
29 {
30  std::vector<FunctionName> funcs = getParam<std::vector<FunctionName>>("function");
31  if (funcs.size() != _ncomp)
32  mooseError("number of functions must be equal to the scalar variable order");
33 
34  for (const auto & func_name : funcs)
35  _func.push_back(&getFunctionByName(func_name));
36 }
37 
38 Real
40 {
41  return _func[_i]->value(_t, _point_zero);
42 }
const Point & _point_zero
Zero point.
registerMooseObject("MooseApp", FunctionScalarIC)
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system...
unsigned int _ncomp
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...
InitialConditions are objects that set the initial value of variables.
static InputParameters validParams()
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.
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...
static InputParameters validParams()
virtual Real value() override
The value of the variable.
FunctionScalarIC(const InputParameters &parameters)
std::vector< const Function * > _func