https://mooseframework.inl.gov
ElementIDInterface.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 #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 
24 {
25 public:
27 
28  ElementIDInterface(const MooseObject * moose_object);
29 
30 #ifdef MOOSE_KOKKOS_ENABLED
31 
35 #endif
36 
37  virtual ~ElementIDInterface() {}
38 
45  virtual unsigned int getElementIDIndex(const std::string & id_parameter_name,
46  unsigned int comp = 0) const;
47 
53  virtual unsigned int getElementIDIndexByName(const std::string & id_name) const;
54 
61  virtual const dof_id_type & getElementID(const std::string & id_parameter_name,
62  unsigned int comp = 0) const;
63 
70  virtual const dof_id_type & getElementIDNeighbor(const std::string & id_parameter_name,
71  unsigned int comp = 0) const;
72 
78  virtual const dof_id_type & getElementIDByName(const std::string & id_name) const;
79 
85  virtual const dof_id_type & getElementIDNeighborByName(const std::string & id_name) const;
86 
90  bool hasElementID(const std::string & id_name) const { return _id_mesh->hasElementID(id_name); }
91 
95  dof_id_type maxElementID(unsigned int elem_id_index) const
96  {
97  return _id_mesh->maxElementID(elem_id_index);
98  }
99 
103  dof_id_type minElementID(unsigned int elem_id_index) const
104  {
105  return _id_mesh->minElementID(elem_id_index);
106  }
107 
111  bool areElemIDsIdentical(const std::string & id_name1, const std::string & id_name2) const
112  {
113  return _id_mesh->areElemIDsIdentical(id_name1, id_name2);
114  }
115 
119  std::unordered_map<dof_id_type, std::set<dof_id_type>>
120  getElemIDMapping(const std::string & id_name1, const std::string & id_name2) const
121  {
122  return _id_mesh->getElemIDMapping(id_name1, id_name2);
123  }
124 
128  std::set<dof_id_type> getAllElemIDs(unsigned int elem_id_index) const
129  {
130  return _id_mesh->getAllElemIDs(elem_id_index);
131  }
132 
137  std::set<dof_id_type> getElemIDsOnBlocks(unsigned int elem_id_index,
138  const std::set<SubdomainID> & blks) const
139  {
140  return _id_mesh->getElemIDsOnBlocks(elem_id_index, blks);
141  }
142 
146  dof_id_type getElementID(const Elem * elem, unsigned int elem_id_index) const
147  {
148  if (elem_id_index == elem->n_extra_integers())
149  return elem->subdomain_id();
150 
151  return elem->get_extra_integer(elem_id_index);
152  }
153 
154 private:
157 
159  std::shared_ptr<MooseMesh> & _id_mesh;
160 
162  const std::string & _ei_name;
163 };
bool areElemIDsIdentical(const std::string &id_name1, const std::string &id_name2) const
Whether two element integers are identical for all elements.
virtual const dof_id_type & getElementIDNeighbor(const std::string &id_parameter_name, unsigned int comp=0) const
Gets a neighbor element integer with a parameter of the object derived from this interface.
dof_id_type getElementID(const Elem *elem, unsigned int elem_id_index) const
Get an element integer for an element.
dof_id_type maxElementID(unsigned int elem_id_index) const
Return the maximum element ID for an element integer with its index.
std::shared_ptr< MooseMesh > & _id_mesh
References to the mesh and displaced mesh (currently in the ActionWarehouse)
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system...
virtual const dof_id_type & getElementIDNeighborByName(const std::string &id_name) const
Gets a neighbor element integer with the element integer name.
std::set< dof_id_type > getAllElemIDs(unsigned int elem_id_index) const
Return all the unique element IDs for an element integer with its index on the entire domain...
Every object that can be built by the factory should be derived from this class.
Definition: MooseObject.h:27
const std::string & _ei_name
Name of the object using this interface.
virtual unsigned int getElementIDIndex(const std::string &id_parameter_name, unsigned int comp=0) const
Gets index of an element integer with a parameter of the object derived from this interface...
virtual const dof_id_type & getElementIDByName(const std::string &id_name) const
Gets an element integer with the element integer name.
static InputParameters validParams()
const InputParameters & _obj_parameters
Reference to the object&#39;s input parameters.
virtual unsigned int getElementIDIndexByName(const std::string &id_name) const
Return the accessing integer for an extra element integer with its name.
bool hasElementID(const std::string &id_name) const
Whether mesh has an element integer with a given name.
dof_id_type minElementID(unsigned int elem_id_index) const
Return the minimum element ID for an element integer with its index.
virtual const dof_id_type & getElementID(const std::string &id_parameter_name, unsigned int comp=0) const
Gets an element integer with a parameter of the object derived from this interface.
ElementIDInterface(const MooseObject *moose_object)
std::unordered_map< dof_id_type, std::set< dof_id_type > > getElemIDMapping(const std::string &id_name1, const std::string &id_name2) const
Get the mapping from IDs of one extra element integer to another given the two integer names...
uint8_t dof_id_type
std::set< dof_id_type > getElemIDsOnBlocks(unsigned int elem_id_index, const std::set< SubdomainID > &blks) const
Return all the unique element IDs for an extra element integer with its index on a set of subdomains...