LCOV - code coverage report
Current view: top level - src/meshgenerators - ParsedNodeTransformGenerator.C (source / functions) Hit Total Coverage
Test: idaholab/moose framework: 419b9d Lines: 28 30 93.3 %
Date: 2025-08-08 20:01:16 Functions: 3 3 100.0 %
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 "ParsedNodeTransformGenerator.h"
      11             : #include "CastUniquePointer.h"
      12             : 
      13             : #include <libmesh/int_range.h>
      14             : 
      15             : registerMooseObject("MooseApp", ParsedNodeTransformGenerator);
      16             : 
      17             : const std::string ParsedNodeTransformGenerator::_func_name[] = {
      18             :     "x_function", "y_function", "z_function"};
      19             : 
      20             : InputParameters
      21       14877 : ParsedNodeTransformGenerator::validParams()
      22             : {
      23       14877 :   InputParameters params = MeshGenerator::validParams();
      24       14877 :   params += FunctionParserUtils<false>::validParams();
      25             : 
      26       14877 :   params.addRequiredParam<MeshGeneratorName>("input", "The mesh we want to modify");
      27       14877 :   params.addClassDescription("Applies a transform to a the x,y,z coordinates of a Mesh");
      28       14877 :   params.addParam<ParsedFunctionExpression>(
      29             :       _func_name[0], "x", "Function for the updated x component of the node");
      30       14877 :   params.addParam<ParsedFunctionExpression>(
      31             :       _func_name[1], "y", "Function for the updated y component of the node");
      32       14877 :   params.addParam<ParsedFunctionExpression>(
      33             :       _func_name[2], "z", "Function for the updated z component of the node");
      34             : 
      35       14877 :   params.addParam<std::vector<std::string>>(
      36             :       "constant_names", {}, "Vector of constants used in the parsed function");
      37       14877 :   params.addParam<std::vector<std::string>>(
      38             :       "constant_expressions",
      39             :       {},
      40             :       "Vector of values for the constants in constant_names (can be an FParser expression)");
      41             : 
      42       14877 :   return params;
      43           0 : }
      44             : 
      45         306 : ParsedNodeTransformGenerator::ParsedNodeTransformGenerator(const InputParameters & parameters)
      46         306 :   : MeshGenerator(parameters), FunctionParserUtils<false>(parameters), _input(getMesh("input"))
      47             : {
      48        1224 :   for (const auto i : index_range(_functions))
      49             :   {
      50             :     // Create parsed function
      51         918 :     _functions[i] = std::make_shared<SymFunction>();
      52        1836 :     parsedFunctionSetup(_functions[i],
      53         918 :                         getParam<ParsedFunctionExpression>(_func_name[i]),
      54             :                         "x,y,z",
      55             :                         getParam<std::vector<std::string>>("constant_names"),
      56             :                         getParam<std::vector<std::string>>("constant_expressions"),
      57             :                         comm());
      58             :   }
      59             : 
      60         306 :   _func_params.resize(3);
      61         306 : }
      62             : 
      63             : std::unique_ptr<MeshBase>
      64         294 : ParsedNodeTransformGenerator::generate()
      65             : {
      66         294 :   std::unique_ptr<MeshBase> mesh = std::move(_input);
      67             : 
      68       16470 :   for (auto & node : mesh->node_ptr_range())
      69             :   {
      70       32352 :     for (const auto i : make_range(3))
      71       24264 :       _func_params[i] = (*node)(i);
      72             : 
      73       32352 :     for (const auto i : make_range(3))
      74       24264 :       (*node)(i) = evaluate(_functions[i], _func_name[i]);
      75         294 :   }
      76             : 
      77         294 :   return mesh;
      78           0 : }

Generated by: LCOV version 1.14