Line data Source code
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 : 13 : registerMooseObject("MooseApp", VectorFunctionIC); 14 : 15 : InputParameters 16 14452 : VectorFunctionIC::validParams() 17 : { 18 14452 : InputParameters params = VectorInitialCondition::validParams(); 19 14452 : params.addParam<FunctionName>("function", 20 : "The initial condition vector function. This cannot be supplied " 21 : "with the component parameters."); 22 14452 : params.addParam<FunctionName>( 23 : "function_x", "0", "A function that describes the x-component of the initial condition"); 24 14452 : params.addParam<FunctionName>( 25 : "function_y", "0", "A function that describes the y-component of the initial condition"); 26 14452 : params.addParam<FunctionName>( 27 : "function_z", "0", "A function that describes the z-component of the initial condition"); 28 14452 : params.addClassDescription( 29 : "Sets component values for a vector field variable based on a vector function."); 30 14452 : return params; 31 0 : } 32 : 33 103 : VectorFunctionIC::VectorFunctionIC(const InputParameters & parameters) 34 : : VectorInitialCondition(parameters), 35 103 : _function(isParamValid("function") ? &getFunction("function") : nullptr), 36 103 : _function_x(getFunction("function_x")), 37 103 : _function_y(getFunction("function_y")), 38 206 : _function_z(getFunction("function_z")) 39 : { 40 103 : if (_function && parameters.isParamSetByUser("function_x")) 41 4 : paramError("function_x", "The 'function' and 'function_x' parameters cannot both be set."); 42 99 : if (_function && parameters.isParamSetByUser("function_y")) 43 4 : paramError("function_y", "The 'function' and 'function_y' parameters cannot both be set."); 44 95 : if (_function && parameters.isParamSetByUser("function_z")) 45 4 : paramError("function_z", "The 'function' and 'function_z' parameters cannot both be set."); 46 91 : } 47 : 48 : RealVectorValue 49 12816 : VectorFunctionIC::value(const Point & p) 50 : { 51 12816 : if (_function) 52 11584 : return _function->vectorValue(_t, p); 53 : else 54 : return RealVectorValue( 55 1232 : _function_x.value(_t, p), _function_y.value(_t, p), _function_z.value(_t, p)); 56 : }