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 4798 : MooseParsedVectorFunction::validParams() 17 : { 18 4798 : InputParameters params = Function::validParams(); 19 4798 : params += MooseParsedFunctionBase::validParams(); 20 9596 : params.addClassDescription( 21 : "Returns a vector function based on string descriptions for each component."); 22 19192 : params.addParam<std::string>("expression_x", "0", "x-component of function."); 23 19192 : params.addParam<std::string>("expression_y", "0", "y-component of function."); 24 19192 : params.addParam<std::string>("expression_z", "0", "z-component of function."); 25 19192 : params.addParam<std::string>("curl_x", "0", "x-component of curl of function."); 26 19192 : params.addParam<std::string>("curl_y", "0", "y-component of curl of function."); 27 19192 : params.addParam<std::string>("curl_z", "0", "z-component of curl of function."); 28 14394 : params.addParam<std::string>("div", "0", "divergence of function."); 29 4798 : return params; 30 0 : } 31 : 32 892 : MooseParsedVectorFunction::MooseParsedVectorFunction(const InputParameters & parameters) 33 : : Function(parameters), 34 : MooseParsedFunctionBase(parameters), 35 6244 : _vector_value(verifyFunction(std::string("{") + getParam<std::string>("expression_x") + "}{" + 36 3568 : getParam<std::string>("expression_y") + "}{" + 37 1784 : getParam<std::string>("expression_z") + "}")), 38 6244 : _curl_value(verifyFunction(std::string("{") + getParam<std::string>("curl_x") + "}{" + 39 4460 : getParam<std::string>("curl_y") + "}{" + 40 1784 : getParam<std::string>("curl_z") + "}")), 41 3568 : _div_value(verifyFunction(getParam<std::string>("div"))) 42 : { 43 892 : } 44 : 45 : RealVectorValue 46 9207521 : MooseParsedVectorFunction::vectorValue(Real t, const Point & p) const 47 : { 48 9207521 : 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 876 : MooseParsedVectorFunction::initialSetup() 71 : { 72 3504 : THREAD_ID tid = isParamValid("_tid") ? getParam<THREAD_ID>("_tid") : 0; 73 : 74 876 : if (!_function_ptr) 75 876 : _function_ptr = std::make_unique<MooseParsedFunctionWrapper>( 76 876 : _pfb_feproblem, _vector_value, _vars, _vals, tid); 77 : 78 876 : if (!_curl_function_ptr) 79 876 : _curl_function_ptr = std::make_unique<MooseParsedFunctionWrapper>( 80 876 : _pfb_feproblem, _curl_value, _vars, _vals, tid); 81 : 82 876 : if (!_div_function_ptr) 83 : _div_function_ptr = 84 876 : std::make_unique<MooseParsedFunctionWrapper>(_pfb_feproblem, _div_value, _vars, _vals, tid); 85 876 : }