LCOV - code coverage report
Current view: top level - src/meshgenerators - ParsedNodeTransformGenerator.C (source / functions) Hit Total Coverage
Test: idaholab/moose framework: #32971 (54bef8) with base c6cf66 Lines: 30 32 93.8 %
Date: 2026-05-29 20:35:17 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        3763 : ParsedNodeTransformGenerator::validParams()
      22             : {
      23        3763 :   InputParameters params = MeshGenerator::validParams();
      24        3763 :   params += FunctionParserUtils<false>::validParams();
      25             : 
      26       15052 :   params.addRequiredParam<MeshGeneratorName>("input", "The mesh we want to modify");
      27        7526 :   params.addClassDescription("Applies a transform to a the x,y,z coordinates of a Mesh");
      28        7526 :   params.addParam<ParsedFunctionExpression>(
      29             :       _func_name[0], "x", "Function for the updated x component of the node");
      30        7526 :   params.addParam<ParsedFunctionExpression>(
      31             :       _func_name[1], "y", "Function for the updated y component of the node");
      32        7526 :   params.addParam<ParsedFunctionExpression>(
      33             :       _func_name[2], "z", "Function for the updated z component of the node");
      34             : 
      35       15052 :   params.addParam<std::vector<std::string>>(
      36             :       "constant_names", {}, "Vector of constants used in the parsed function");
      37       11289 :   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        3763 :   return params;
      43           0 : }
      44             : 
      45         351 : ParsedNodeTransformGenerator::ParsedNodeTransformGenerator(const InputParameters & parameters)
      46        1053 :   : MeshGenerator(parameters), FunctionParserUtils<false>(parameters), _input(getMesh("input"))
      47             : {
      48        1404 :   for (const auto i : index_range(_functions))
      49             :   {
      50             :     // Create parsed function
      51        1053 :     _functions[i] = std::make_shared<SymFunction>();
      52        8424 :     parsedFunctionSetup(_functions[i],
      53        1053 :                         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         351 :   _func_params.resize(3);
      61         351 : }
      62             : 
      63             : std::unique_ptr<MeshBase>
      64         342 : ParsedNodeTransformGenerator::generate()
      65             : {
      66         342 :   std::unique_ptr<MeshBase> mesh = std::move(_input);
      67             : 
      68       32860 :   for (auto & node : mesh->node_ptr_range())
      69             :   {
      70       65036 :     for (const auto i : make_range(3))
      71       48777 :       _func_params[i] = (*node)(i);
      72             : 
      73       65036 :     for (const auto i : make_range(3))
      74       48777 :       (*node)(i) = evaluate(_functions[i], _func_name[i]);
      75         342 :   }
      76             : 
      77         342 :   mesh->unset_has_cached_elem_data();
      78         342 :   mesh->clear_point_locator();
      79             : 
      80         342 :   return mesh;
      81           0 : }

Generated by: LCOV version 1.14