https://mooseframework.inl.gov
Loading...
Searching...
No Matches
ArrayFunctionIC.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 "ArrayFunctionIC.h"
11#include "Function.h"
12
14
17{
19 params.addRequiredParam<std::vector<FunctionName>>("function",
20 "The initial condition functions.");
21 params.addClassDescription("An initial condition that uses a normal function of x, y, z to "
22 "produce values (and optionally gradients) for a field variable.");
23 return params;
24}
25
27 : ArrayInitialCondition(parameters)
28{
29 auto & funcs = getParam<std::vector<FunctionName>>("function");
30 if (_var.count() != funcs.size())
31 mooseError("Number of functions does not agree with the number of array variable components");
32 for (auto & func : funcs)
33 _func.push_back(&getFunctionByName(func));
34}
35
36RealEigenVector
37ArrayFunctionIC::value(const Point & p)
38{
39 RealEigenVector v(_var.count());
40 for (unsigned int i = 0; i < _var.count(); ++i)
41 v(i) = _func[i]->value(_t, p);
42 return v;
43}
44
45RealVectorArrayValue
47{
48 RealVectorArrayValue v(_var.count(), LIBMESH_DIM);
49 for (unsigned int i = 0; i < _var.count(); ++i)
50 {
51 auto gd = _func[i]->gradient(_t, p);
52 for (const auto j : make_range(Moose::dim))
53 v(i, j) = gd(j);
54 }
55 return v;
56}
registerMooseObject("MooseApp", ArrayFunctionIC)
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application.
Definition MooseError.h:311
std::vector< const Function * > _func
virtual RealEigenVector value(const Point &p) override
The value of the variable at a point.
ArrayFunctionIC(const InputParameters &parameters)
virtual RealVectorArrayValue gradient(const Point &p) override
The value of the gradient at a point.
static InputParameters validParams()
const Function & getFunctionByName(const FunctionName &name) const
Get a function with a given name.
This is a template class that implements the workhorse compute and computeNodal methods.
MooseVariableField< T > & _var
The variable that this initial condition is acting upon.
static InputParameters validParams()
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.
unsigned int count() const
Get the number of components Note: For standard and vector variables, the number is one.
static constexpr std::size_t dim
This is the dimension of all vector and tensor datastructures used in MOOSE.
Definition Moose.h:165