LCOV - code coverage report
Current view: top level - src/utils - ElemIndexHelper.C (source / functions) Hit Total Coverage
Test: idaholab/moose ray_tracing: #31405 (292dce) with base fef103 Lines: 12 12 100.0 %
Date: 2025-09-04 07:56:07 Functions: 2 2 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 "ElemIndexHelper.h"
      11             : 
      12             : using namespace libMesh;
      13             : 
      14        3827 : ElemIndexHelper::ElemIndexHelper(MeshBase & mesh, const std::string & extra_elem_integer_name)
      15        3827 :   : _mesh(mesh), _extra_integer(invalid_uint), _initialized(false)
      16             : {
      17        3827 :   _extra_integer = mesh.add_elem_integer(extra_elem_integer_name);
      18        3827 : }
      19             : 
      20             : void
      21        3937 : ElemIndexHelper::initialize(const SimpleRange<MeshBase::element_iterator> elems)
      22             : {
      23             :   // First, invalidate the integers for all elements that we know about
      24             :   // so that we can tell when getting an index for an elem if said elem
      25             :   // was not in the range
      26     1358708 :   for (Elem * elem : _mesh.element_ptr_range())
      27      679354 :     elem->set_extra_integer(_extra_integer, DofObject::invalid_id);
      28             : 
      29             :   // Set the index in a contiguous manner for all elements in the range
      30             :   dof_id_type next_index = 0;
      31     1350515 :   for (Elem * elem : elems)
      32      673289 :     elem->set_extra_integer(_extra_integer, next_index++);
      33             : 
      34             :   // Store the max index so that users can use it to initialize data
      35             :   // structures that will use these indices
      36        3937 :   _max_index = next_index - 1;
      37             : 
      38        3937 :   _initialized = true;
      39        3937 : }

Generated by: LCOV version 1.14