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 
18 template <>
21 {
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 }
std::vector< Function * > _func
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 mooseError(Args &&... args) const
Definition: MooseObject.h:147
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.
virtual Real value() override
The value of the variable.
FunctionScalarIC(const InputParameters &parameters)