LCOV - code coverage report
Current view: top level - src/functions - MooseParsedVectorFunction.C (source / functions) Hit Total Coverage
Test: idaholab/moose framework: 2bf808 Lines: 44 47 93.6 %
Date: 2025-07-17 01:28:37 Functions: 6 7 85.7 %
Legend: Lines: hit not hit

          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       15147 : MooseParsedVectorFunction::validParams()
      17             : {
      18       15147 :   InputParameters params = Function::validParams();
      19       15147 :   params += MooseParsedFunctionBase::validParams();
      20       15147 :   params.addClassDescription(
      21             :       "Returns a vector function based on string descriptions for each component.");
      22       15147 :   params.addDeprecatedParam<std::string>(
      23             :       "value_x", "x-component of function.", "value_x is deprecated, use expression_x");
      24       15147 :   params.addDeprecatedParam<std::string>(
      25             :       "value_y", "y-component of function.", "value_y is deprecated, use expression_y");
      26       15147 :   params.addDeprecatedParam<std::string>(
      27             :       "value_z", "z-component of function.", "value_z is deprecated, use expression_z");
      28       15147 :   params.addParam<std::string>("expression_x", "0", "x-component of function.");
      29       15147 :   params.addParam<std::string>("expression_y", "0", "y-component of function.");
      30       15147 :   params.addParam<std::string>("expression_z", "0", "z-component of function.");
      31       15147 :   params.addParam<std::string>("curl_x", "0", "x-component of curl of function.");
      32       15147 :   params.addParam<std::string>("curl_y", "0", "y-component of curl of function.");
      33       15147 :   params.addParam<std::string>("curl_z", "0", "z-component of curl of function.");
      34       15147 :   params.addParam<std::string>("div", "0", "divergence of function.");
      35       15147 :   return params;
      36           0 : }
      37             : 
      38         460 : MooseParsedVectorFunction::MooseParsedVectorFunction(const InputParameters & parameters)
      39             :   : Function(parameters),
      40             :     MooseParsedFunctionBase(parameters),
      41        1380 :     _vector_value(verifyFunction(std::string("{") +
      42        1840 :                                  getRenamedParam<std::string>("value_x", "expression_x") + "}{" +
      43        1840 :                                  getRenamedParam<std::string>("value_y", "expression_y") + "}{" +
      44         920 :                                  getRenamedParam<std::string>("value_z", "expression_z") + "}")),
      45        1380 :     _curl_value(verifyFunction(std::string("{") + getParam<std::string>("curl_x") + "}{" +
      46        1840 :                                getParam<std::string>("curl_y") + "}{" +
      47         920 :                                getParam<std::string>("curl_z") + "}")),
      48         920 :     _div_value(verifyFunction(getParam<std::string>("div")))
      49             : {
      50         460 : }
      51             : 
      52             : RealVectorValue
      53     8366159 : MooseParsedVectorFunction::vectorValue(Real t, const Point & p) const
      54             : {
      55     8366159 :   return _function_ptr->evaluate<RealVectorValue>(t, p);
      56             : }
      57             : 
      58             : RealVectorValue
      59       49280 : MooseParsedVectorFunction::curl(Real t, const Point & p) const
      60             : {
      61       49280 :   return _curl_function_ptr->evaluate<RealVectorValue>(t, p);
      62             : }
      63             : 
      64             : Real
      65      456192 : MooseParsedVectorFunction::div(Real t, const Point & p) const
      66             : {
      67      456192 :   return _div_function_ptr->evaluate<Real>(t, p);
      68             : }
      69             : 
      70             : RealGradient
      71           0 : MooseParsedVectorFunction::gradient(Real /*t*/, const Point & /*p*/) const
      72             : {
      73           0 :   mooseError("The gradient method is not defined in MooseParsedVectorFunction");
      74             : }
      75             : 
      76             : void
      77         443 : MooseParsedVectorFunction::initialSetup()
      78             : {
      79         443 :   THREAD_ID tid = 0;
      80         443 :   if (isParamValid("_tid"))
      81         443 :     tid = getParam<THREAD_ID>("_tid");
      82             : 
      83         443 :   if (!_function_ptr)
      84         443 :     _function_ptr = std::make_unique<MooseParsedFunctionWrapper>(
      85         443 :         _pfb_feproblem, _vector_value, _vars, _vals, tid);
      86             : 
      87         443 :   if (!_curl_function_ptr)
      88         443 :     _curl_function_ptr = std::make_unique<MooseParsedFunctionWrapper>(
      89         443 :         _pfb_feproblem, _curl_value, _vars, _vals, tid);
      90             : 
      91         443 :   if (!_div_function_ptr)
      92             :     _div_function_ptr =
      93         443 :         std::make_unique<MooseParsedFunctionWrapper>(_pfb_feproblem, _div_value, _vars, _vals, tid);
      94         443 : }

Generated by: LCOV version 1.14