https://mooseframework.inl.gov
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 
37 ArrayFunctionIC::value(const Point & p)
38 {
40  for (unsigned int i = 0; i < _var.count(); ++i)
41  v(i) = _func[i]->value(_t, p);
42  return v;
43 }
44 
46 ArrayFunctionIC::gradient(const Point & p)
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)
std::vector< const Function * > _func
virtual RealEigenVector value(const Point &p) override
The value of the variable at a point.
This is a template class that implements the workhorse compute and computeNodal methods.
unsigned int count() const
Get the number of components Note: For standard and vector variables, the number is one...
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system...
static constexpr std::size_t dim
This is the dimension of all vector and tensor datastructures used in MOOSE.
Definition: Moose.h:154
static InputParameters validParams()
virtual RealVectorArrayValue gradient(const Point &p) override
The value of the gradient at a point.
MooseVariableField< T > & _var
The variable that this initial condition is acting upon.
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...
static InputParameters validParams()
ArrayFunctionIC(const InputParameters &parameters)
Eigen::Matrix< Real, Eigen::Dynamic, Moose::dim > RealVectorArrayValue
Definition: MooseTypes.h:147
const Function & getFunctionByName(const FunctionName &name) const
Get a function with a given name.
IntRange< T > make_range(T beg, T end)
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...
Eigen::Matrix< Real, Eigen::Dynamic, 1 > RealEigenVector
Definition: MooseTypes.h:146