LCOV - code coverage report
Current view: top level - include/userobjects - BooleanComboClusteringUserObject.h (source / functions) Hit Total Coverage
Test: neams-th-coe/cardinal: ddd5f2 Lines: 2 2 100.0 %
Date: 2026-06-07 19:35:24 Functions: 2 2 100.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : #pragma once
       2             : 
       3             : #include "GeneralUserObject.h"
       4             : #include <unordered_map>
       5             : 
       6             : class ClusteringUserObjectBase;
       7             : 
       8             : /**
       9             :  * A clustering user object which implements the mesh walking
      10             :  * and clustering process. This is performed by evaluating a user-defined
      11             :  * boolean expression involving other heuristic based user objects
      12             :  */
      13             : class BooleanComboClusteringUserObject : public GeneralUserObject
      14             : {
      15             : public:
      16             :   static InputParameters validParams();
      17             :   BooleanComboClusteringUserObject(const InputParameters & parameters);
      18             : 
      19             :   virtual void execute() override;
      20          24 :   virtual void initialize() override {};
      21          24 :   virtual void finalize() override {};
      22             : 
      23             : private:
      24             :   /**
      25             :    * getter function for extra element integer score of an element
      26             :    * @param[in] a libmesh element
      27             :    * @return extra element integer score of that element
      28             :    */
      29             :   int getExtraIntegerScore(libMesh::Elem * elem) const;
      30             : 
      31             :   /**
      32             :    * function for converting the expression input to reverse polish notation
      33             :    * using the shunting yard algorithm.
      34             :    * @param[in] expression a boolean logic expression
      35             :    */
      36             :   void reversePolishNotation(const std::vector<std::string> & expression);
      37             : 
      38             :   /**
      39             :    * Method for evaluating if element should be clustered or not
      40             :    * @param[in] base_element
      41             :    * @param[in] neighbor_elem neighboring element of the base element
      42             :    * @return if these two element belong to a cluster or not
      43             :    */
      44             :   bool belongsToCluster(libMesh::Elem * base_element, libMesh::Elem * neighbor_elem);
      45             : 
      46             :   /// this method implements the mesh walking process
      47             :   void findCluster();
      48             : 
      49             :   /// sets the extra element integer to NOT_VISITED for every active element
      50             :   void resetExtraInteger();
      51             : 
      52             :   /**
      53             :    * Initializes the local cache of clustering user objects from the boolean
      54             :    * logic operation expression from the input file
      55             :    */
      56             :   void initializeUserObjects();
      57             : 
      58             :   /// extra element integer id name
      59             :   const ExtraElementIDName & _id_name;
      60             : 
      61             :   /// mesh ref
      62             :   libMesh::MeshBase & _mesh;
      63             : 
      64             :   /// element integer index
      65             :   unsigned int _extra_integer_index;
      66             : 
      67             :   /// Hash map for clustering user object. The key is the name of the UserObject
      68             :   std::unordered_map<std::string, const ClusteringUserObjectBase *> _clustering_user_objects;
      69             : 
      70             :   /// hold the final rpn expression
      71             :   std::vector<std::string> _output_stack;
      72             : 
      73             :   /// operator precedence
      74             :   static std::unordered_map<std::string, int> _precedence;
      75             : 
      76             :   static constexpr int NOT_VISITED = -1;
      77             :   static constexpr std::string_view _left_parenthesis = "(";
      78             :   static constexpr std::string_view _right_parenthesis = ")";
      79             : };

Generated by: LCOV version 1.14