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 "MooseParsedVectorFunction.h" 11 : #include "MooseParsedFunctionWrapper.h" 12 : 13 : registerMooseObjectAliased("MooseApp", MooseParsedVectorFunction, "ParsedVectorFunction"); 14 : 15 : InputParameters 16 4848 : MooseParsedVectorFunction::validParams() 17 : { 18 4848 : InputParameters params = Function::validParams(); 19 4848 : params += MooseParsedFunctionBase::validParams(); 20 9696 : params.addClassDescription( 21 : "Returns a vector function based on string descriptions for each component."); 22 19392 : params.addParam<std::string>("expression_x", "0", "x-component of function."); 23 19392 : params.addParam<std::string>("expression_y", "0", "y-component of function."); 24 19392 : params.addParam<std::string>("expression_z", "0", "z-component of function."); 25 19392 : params.addParam<std::string>("curl_x", "0", "x-component of curl of function."); 26 19392 : params.addParam<std::string>("curl_y", "0", "y-component of curl of function."); 27 19392 : params.addParam<std::string>("curl_z", "0", "z-component of curl of function."); 28 14544 : params.addParam<std::string>("div", "0", "divergence of function."); 29 4848 : return params; 30 0 : } 31 : 32 917 : MooseParsedVectorFunction::MooseParsedVectorFunction(const InputParameters & parameters) 33 : : Function(parameters), 34 : MooseParsedFunctionBase(parameters), 35 6419 : _vector_value(verifyFunction(std::string("{") + getParam<std::string>("expression_x") + "}{" + 36 3668 : getParam<std::string>("expression_y") + "}{" + 37 1834 : getParam<std::string>("expression_z") + "}")), 38 6419 : _curl_value(verifyFunction(std::string("{") + getParam<std::string>("curl_x") + "}{" + 39 4585 : getParam<std::string>("curl_y") + "}{" + 40 1834 : getParam<std::string>("curl_z") + "}")), 41 3668 : _div_value(verifyFunction(getParam<std::string>("div"))) 42 : { 43 917 : } 44 : 45 : RealVectorValue 46 9554601 : MooseParsedVectorFunction::vectorValue(Real t, const Point & p) const 47 : { 48 9554601 : return _function_ptr->evaluate<RealVectorValue>(t, p); 49 : } 50 : 51 : RealVectorValue 52 49280 : MooseParsedVectorFunction::curl(Real t, const Point & p) const 53 : { 54 49280 : return _curl_function_ptr->evaluate<RealVectorValue>(t, p); 55 : } 56 : 57 : Real 58 599040 : MooseParsedVectorFunction::div(Real t, const Point & p) const 59 : { 60 599040 : return _div_function_ptr->evaluate<Real>(t, p); 61 : } 62 : 63 : RealGradient 64 0 : MooseParsedVectorFunction::gradient(Real /*t*/, const Point & /*p*/) const 65 : { 66 0 : mooseError("The gradient method is not defined in MooseParsedVectorFunction"); 67 : } 68 : 69 : void 70 901 : MooseParsedVectorFunction::initialSetup() 71 : { 72 3604 : THREAD_ID tid = isParamValid("_tid") ? getParam<THREAD_ID>("_tid") : 0; 73 : 74 901 : if (!_function_ptr) 75 901 : _function_ptr = std::make_unique<MooseParsedFunctionWrapper>( 76 901 : _pfb_feproblem, _vector_value, _vars, _vals, tid); 77 : 78 901 : if (!_curl_function_ptr) 79 901 : _curl_function_ptr = std::make_unique<MooseParsedFunctionWrapper>( 80 901 : _pfb_feproblem, _curl_value, _vars, _vals, tid); 81 : 82 901 : if (!_div_function_ptr) 83 : _div_function_ptr = 84 901 : std::make_unique<MooseParsedFunctionWrapper>(_pfb_feproblem, _div_value, _vars, _vals, tid); 85 901 : }