https://mooseframework.inl.gov
ElemIndexHelper.h
Go to the documentation of this file.
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 // MOOSE includes
13 #include "MooseError.h"
14 
15 // libMesh includes
16 #include "libmesh/elem.h"
17 #include "libmesh/elem_range.h"
18 #include "libmesh/mesh_base.h"
19 
30 {
31 public:
40  ElemIndexHelper(libMesh::MeshBase & mesh, const std::string & extra_elem_integer_name);
41 
46 
50  bool hasIndex(const libMesh::Elem * elem) const
51  {
52  mooseAssert(elem, "Null elem");
53  mooseAssert(_initialized, "Not initialized");
54  mooseAssert(_mesh.query_elem_ptr(elem->id()), "Not an elem of the mesh");
56  }
57 
62  {
63  mooseAssert(hasIndex(elem), "Elem not in indexed range");
64  return elem->get_extra_integer(_extra_integer);
65  }
66 
74 
75 private:
76  // The mesh
79  unsigned int _extra_integer;
84 };
bool hasIndex(const libMesh::Elem *elem) const
Whether or not the element elem has an index set for it using this object.
ElemIndexHelper(libMesh::MeshBase &mesh, const std::string &extra_elem_integer_name)
Constructor.
bool _initialized
Whether or not this object is initialized.
libMesh::MeshBase & _mesh
libMesh::dof_id_type maxIndex() const
Gets the maximum index generated using this object.
MeshBase & mesh
void initialize(const libMesh::SimpleRange< libMesh::MeshBase::element_iterator > elems)
Initializes the indices in a contiguous manner for the given element range.
dof_id_type id() const
static const dof_id_type invalid_id
libMesh::dof_id_type getIndex(const libMesh::Elem *elem) const
Get the index associated with the element elem.
unsigned int _extra_integer
The extra elem integer that stores the index.
virtual const Elem * query_elem_ptr(const dof_id_type i) const=0
Helper for setting up a contiguous index for a given range of elements that are known by this process...
libMesh::dof_id_type _max_index
The max index generated.
dof_id_type get_extra_integer(const unsigned int index) const
uint8_t dof_id_type