https://mooseframework.inl.gov
Loading...
Searching...
No Matches
FunctionScalarIC.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 "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
38Real
40{
41 return _func[_i]->value(_t, _point_zero);
42}
registerMooseObject("MooseApp", FunctionScalarIC)
const Function & getFunctionByName(const FunctionName &name) const
Get a function with a given name.
unsigned int _ncomp
static InputParameters validParams()
FunctionScalarIC(const InputParameters &parameters)
std::vector< const Function * > _func
virtual Real value() override
The value of the variable.
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.
void mooseError(Args &&... args) const
Emits an error prefixed with object name and type and optionally a file path to the top-level block p...
Definition MooseBase.h:271
const Point & _point_zero
Zero point.
InitialConditions are objects that set the initial value of variables.
static InputParameters validParams()