https://mooseframework.inl.gov
VectorFunctionIC.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 "VectorFunctionIC.h"
11 #include "libmesh/point.h"
12 
14 
17 {
19  params.addParam<FunctionName>("function",
20  "The initial condition vector function. This cannot be supplied "
21  "with the component parameters.");
22  params.addParam<FunctionName>(
23  "function_x", "0", "A function that describes the x-component of the initial condition");
24  params.addParam<FunctionName>(
25  "function_y", "0", "A function that describes the y-component of the initial condition");
26  params.addParam<FunctionName>(
27  "function_z", "0", "A function that describes the z-component of the initial condition");
28  params.addClassDescription(
29  "Sets component values for a vector field variable based on a vector function.");
30  return params;
31 }
32 
34  : VectorInitialCondition(parameters),
35  _function(isParamValid("function") ? &getFunction("function") : nullptr),
36  _function_x(getFunction("function_x")),
37  _function_y(getFunction("function_y")),
38  _function_z(getFunction("function_z"))
39 {
40  if (_function && parameters.isParamSetByUser("function_x"))
41  paramError("function_x", "The 'function' and 'function_x' parameters cannot both be set.");
42  if (_function && parameters.isParamSetByUser("function_y"))
43  paramError("function_y", "The 'function' and 'function_y' parameters cannot both be set.");
44  if (_function && parameters.isParamSetByUser("function_z"))
45  paramError("function_z", "The 'function' and 'function_z' parameters cannot both be set.");
46 }
47 
49 VectorFunctionIC::value(const Point & p)
50 {
51  if (_function)
52  return _function->vectorValue(_t, p);
53  else
54  return RealVectorValue(
56 }
const Function & _function_z
registerMooseObject("MooseApp", VectorFunctionIC)
virtual RealVectorValue 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.
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system...
static InputParameters validParams()
IC that calls vectorValue method of a Function object.
void paramError(const std::string &param, Args... args) const
Emits an error prefixed with the file and line number of the given param (from the input file) along ...
static InputParameters validParams()
bool isParamSetByUser(const std::string &name) const
Method returns true if the parameter was set by the user.
const Function & _function_x
Optional component function value.
virtual RealVectorValue vectorValue(Real t, const Point &p) const
Override this to evaluate the vector function at a point (t,x,y,z), by default this returns a zero ve...
Definition: Function.C:96
const Function *const _function
Optional vectorValue function.
VectorFunctionIC(const InputParameters &parameters)
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...
const InputParameters & parameters() const
Get the parameters of the object.
void addParam(const std::string &name, const S &value, const std::string &doc_string)
These methods add an optional parameter and a documentation string to the InputParameters object...
const Function & _function_y
virtual Real value(Real t, const Point &p) const
Override this to evaluate the scalar function at point (t,x,y,z), by default this returns zero...
Definition: Function.C:44