www.mooseframework.org
FunctionScalarIC.C
Go to the documentation of this file.
1 /****************************************************************/
2 /* DO NOT MODIFY THIS HEADER */
3 /* MOOSE - Multiphysics Object Oriented Simulation Environment */
4 /* */
5 /* (c) 2010 Battelle Energy Alliance, LLC */
6 /* ALL RIGHTS RESERVED */
7 /* */
8 /* Prepared by Battelle Energy Alliance, LLC */
9 /* Under Contract No. DE-AC07-05ID14517 */
10 /* With the U. S. Department of Energy */
11 /* */
12 /* See COPYRIGHT for full restrictions */
13 /****************************************************************/
14 
15 #include "FunctionScalarIC.h"
16 
17 // MOOSE includes
18 #include "Function.h"
19 #include "MooseVariableScalar.h"
20 
21 template <>
24 {
26  params.addRequiredParam<std::vector<FunctionName>>("function", "The initial condition function.");
27  return params;
28 }
29 
31  : ScalarInitialCondition(parameters), _ncomp(_var.order())
32 {
33  std::vector<FunctionName> funcs = getParam<std::vector<FunctionName>>("function");
34  if (funcs.size() != _ncomp)
35  mooseError("number of functions must be equal to the scalar variable order");
36 
37  for (const auto & func_name : funcs)
38  _func.push_back(&getFunctionByName(func_name));
39 }
40 
41 Real
43 {
44  return _func[_i]->value(_t, Point(0, 0, 0));
45 }
std::vector< Function * > _func
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...
InputParameters validParams< FunctionScalarIC >()
InitialConditions are objects that set the initial value of variables.
InputParameters validParams< ScalarInitialCondition >()
Function & getFunctionByName(const FunctionName &name)
Get a function with a given name.
void mooseError(Args &&...args) const
Definition: MooseObject.h:80
virtual Real value() override
The value of the variable.
FunctionScalarIC(const InputParameters &parameters)