LCOV - code coverage report
Current view: top level - include/interfaces - ElementIDInterface.h (source / functions) Hit Total Coverage
Test: idaholab/moose framework: 2bf808 Lines: 11 11 100.0 %
Date: 2025-07-17 01:28:37 Functions: 5 6 83.3 %
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             : #pragma once
      11             : 
      12             : #include <string>
      13             : #include <memory>
      14             : 
      15             : #include "MooseObject.h"
      16             : #include "MooseMesh.h"
      17             : 
      18             : #include "libmesh/elem.h"
      19             : 
      20             : class InputParameters;
      21             : class MooseObject;
      22             : 
      23             : class ElementIDInterface
      24             : {
      25             : public:
      26             :   ElementIDInterface(const MooseObject * moose_object);
      27             :   static InputParameters validParams();
      28             : 
      29      247753 :   virtual ~ElementIDInterface() {}
      30             : 
      31             :   /**
      32             :    * Gets index of an element integer with a parameter of the object derived from this interface
      33             :    * @param id_parameter_name Name of object parameter
      34             :    * @param comp Component number for vector of integer names
      35             :    * @return Index of the element integer
      36             :    */
      37             :   virtual unsigned int getElementIDIndex(const std::string & id_parameter_name,
      38             :                                          unsigned int comp = 0) const;
      39             : 
      40             :   /**
      41             :    * Return the accessing integer for an extra element integer with its name
      42             :    * @param id_name Name of element integer
      43             :    * @return Index of the element integer
      44             :    */
      45             :   virtual unsigned int getElementIDIndexByName(const std::string & id_name) const;
      46             : 
      47             :   /**
      48             :    * Gets an element integer with a parameter of the object derived from this interface
      49             :    * @param id_parameter_name Name of object parameter
      50             :    * @param comp Component number for vector of integer names
      51             :    * @return Integer for the current element
      52             :    */
      53             :   virtual const dof_id_type & getElementID(const std::string & id_parameter_name,
      54             :                                            unsigned int comp = 0) const;
      55             : 
      56             :   /**
      57             :    * Gets a neighbor element integer with a parameter of the object derived from this interface
      58             :    * @param id_parameter_name Name of object parameter
      59             :    * @param comp Component number for vector of integer names
      60             :    * @return Integer for the neighbor element
      61             :    */
      62             :   virtual const dof_id_type & getElementIDNeighbor(const std::string & id_parameter_name,
      63             :                                                    unsigned int comp = 0) const;
      64             : 
      65             :   /**
      66             :    * Gets an element integer with the element integer name
      67             :    * @param id_name Name of element integer
      68             :    * @return Integer for the current element
      69             :    */
      70             :   virtual const dof_id_type & getElementIDByName(const std::string & id_name) const;
      71             : 
      72             :   /**
      73             :    * Gets a neighbor element integer with the element integer name
      74             :    * @param id_name Name of element integer
      75             :    * @return Integer for the neighbor element
      76             :    */
      77             :   virtual const dof_id_type & getElementIDNeighborByName(const std::string & id_name) const;
      78             : 
      79             :   /**
      80             :    * Whether mesh has an element integer with a given name
      81             :    */
      82             :   bool hasElementID(const std::string & id_name) const { return _id_mesh->hasElementID(id_name); }
      83             : 
      84             :   /**
      85             :    * Return the maximum element ID for an element integer with its index
      86             :    */
      87             :   dof_id_type maxElementID(unsigned int elem_id_index) const
      88             :   {
      89             :     return _id_mesh->maxElementID(elem_id_index);
      90             :   }
      91             : 
      92             :   /**
      93             :    * Return the minimum element ID for an element integer with its index
      94             :    */
      95             :   dof_id_type minElementID(unsigned int elem_id_index) const
      96             :   {
      97             :     return _id_mesh->minElementID(elem_id_index);
      98             :   }
      99             : 
     100             :   /**
     101             :    * Whether two element integers are identical for all elements
     102             :    */
     103             :   bool areElemIDsIdentical(const std::string & id_name1, const std::string & id_name2) const
     104             :   {
     105             :     return _id_mesh->areElemIDsIdentical(id_name1, id_name2);
     106             :   }
     107             : 
     108             :   /**
     109             :    * Get the mapping from IDs of one extra element integer to another given the two integer names
     110             :    */
     111             :   std::unordered_map<dof_id_type, std::set<dof_id_type>>
     112          11 :   getElemIDMapping(const std::string & id_name1, const std::string & id_name2) const
     113             :   {
     114          11 :     return _id_mesh->getElemIDMapping(id_name1, id_name2);
     115             :   }
     116             : 
     117             :   /**
     118             :    * Return all the unique element IDs for an element integer with its index on the entire domain
     119             :    */
     120          39 :   std::set<dof_id_type> getAllElemIDs(unsigned int elem_id_index) const
     121             :   {
     122          39 :     return _id_mesh->getAllElemIDs(elem_id_index);
     123             :   }
     124             : 
     125             :   /**
     126             :    * Return all the unique element IDs for an extra element integer with its index on a set of
     127             :    * subdomains
     128             :    */
     129          65 :   std::set<dof_id_type> getElemIDsOnBlocks(unsigned int elem_id_index,
     130             :                                            const std::set<SubdomainID> & blks) const
     131             :   {
     132          65 :     return _id_mesh->getElemIDsOnBlocks(elem_id_index, blks);
     133             :   }
     134             : 
     135             :   /**
     136             :    * Get an element integer for an element
     137             :    */
     138        3200 :   dof_id_type getElementID(const Elem * elem, unsigned int elem_id_index) const
     139             :   {
     140        3200 :     if (elem_id_index == elem->n_extra_integers())
     141        1600 :       return elem->subdomain_id();
     142             : 
     143        1600 :     return elem->get_extra_integer(elem_id_index);
     144             :   }
     145             : 
     146             : private:
     147             :   /// Reference to the object's input parameters
     148             :   const InputParameters & _obj_parameters;
     149             : 
     150             :   /// References to the mesh and displaced mesh (currently in the ActionWarehouse)
     151             :   std::shared_ptr<MooseMesh> & _id_mesh;
     152             : 
     153             :   /// Name of the object using this interface
     154             :   const std::string & _ei_name;
     155             : };

Generated by: LCOV version 1.14