LCOV - code coverage report
Current view: top level - src/meshgenerators - ParsedElementDeletionGenerator.C (source / functions) Hit Total Coverage
Test: idaholab/moose framework: 2bf808 Lines: 22 23 95.7 %
Date: 2025-07-17 01:28:37 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 "ParsedElementDeletionGenerator.h"
      11             : 
      12             : registerMooseObject("MooseApp", ParsedElementDeletionGenerator);
      13             : 
      14             : InputParameters
      15       14305 : ParsedElementDeletionGenerator::validParams()
      16             : {
      17       14305 :   InputParameters params = ElementDeletionGeneratorBase::validParams();
      18       14305 :   params += FunctionParserUtils<false>::validParams();
      19             : 
      20       14305 :   params.addClassDescription(
      21             :       "Removes elements such that the parsed expression is evaluated as strictly positive. "
      22             :       "The parameters of the parsed expression can be the X,Y,Z coordinates of the "
      23             :       "element vertex average (must be 'x','y','z' in the expression), the element volume "
      24             :       "(must be 'volume' in the expression) and the element id ('id' in the expression).");
      25       14305 :   params.addRequiredParam<ParsedFunctionExpression>(
      26             :       "expression", "Expression to evaluate to decide whether an element should be deleted");
      27       14305 :   params.addParam<std::vector<std::string>>(
      28             :       "constant_names", {}, "Vector of constants used in the parsed function");
      29       14305 :   params.addParam<std::vector<std::string>>(
      30             :       "constant_expressions",
      31             :       {},
      32             :       "Vector of values for the constants in constant_names (can be an FParser expression)");
      33       14305 :   return params;
      34           0 : }
      35             : 
      36          20 : ParsedElementDeletionGenerator::ParsedElementDeletionGenerator(const InputParameters & parameters)
      37          20 :   : ElementDeletionGeneratorBase(parameters), FunctionParserUtils<false>(parameters)
      38             : {
      39             :   // Create parsed function
      40          20 :   _function = std::make_shared<SymFunction>();
      41          40 :   parsedFunctionSetup(_function,
      42          20 :                       getParam<ParsedFunctionExpression>("expression"),
      43             :                       "x,y,z,volume,id",
      44             :                       getParam<std::vector<std::string>>("constant_names"),
      45             :                       getParam<std::vector<std::string>>("constant_expressions"),
      46             :                       comm());
      47             : 
      48          20 :   _func_params.resize(5);
      49          20 : }
      50             : 
      51             : bool
      52          58 : ParsedElementDeletionGenerator::shouldDelete(const Elem * elem)
      53             : {
      54          58 :   const auto vertex_average = elem->vertex_average();
      55         232 :   for (const auto i : make_range(3))
      56         174 :     _func_params[i] = vertex_average(i);
      57          58 :   _func_params[3] = elem->volume();
      58          58 :   _func_params[4] = elem->id();
      59             : 
      60          58 :   return evaluate(_function, "expression") > 0;
      61             : }

Generated by: LCOV version 1.14