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:
26  ElementIDInterface(const MooseObject * moose_object);
28 
29  virtual ~ElementIDInterface() {}
30 
37  virtual unsigned int getElementIDIndex(const std::string & id_parameter_name,
38  unsigned int comp = 0) const;
39 
45  virtual unsigned int getElementIDIndexByName(const std::string & id_name) const;
46 
53  virtual const dof_id_type & getElementID(const std::string & id_parameter_name,
54  unsigned int comp = 0) const;
55 
62  virtual const dof_id_type & getElementIDNeighbor(const std::string & id_parameter_name,
63  unsigned int comp = 0) const;
64 
70  virtual const dof_id_type & getElementIDByName(const std::string & id_name) const;
71 
77  virtual const dof_id_type & getElementIDNeighborByName(const std::string & id_name) const;
78 
82  bool hasElementID(const std::string & id_name) const { return _id_mesh->hasElementID(id_name); }
83 
87  dof_id_type maxElementID(unsigned int elem_id_index) const
88  {
89  return _id_mesh->maxElementID(elem_id_index);
90  }
91 
95  dof_id_type minElementID(unsigned int elem_id_index) const
96  {
97  return _id_mesh->minElementID(elem_id_index);
98  }
99 
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 
111  std::unordered_map<dof_id_type, std::set<dof_id_type>>
112  getElemIDMapping(const std::string & id_name1, const std::string & id_name2) const
113  {
114  return _id_mesh->getElemIDMapping(id_name1, id_name2);
115  }
116 
120  std::set<dof_id_type> getAllElemIDs(unsigned int elem_id_index) const
121  {
122  return _id_mesh->getAllElemIDs(elem_id_index);
123  }
124 
129  std::set<dof_id_type> getElemIDsOnBlocks(unsigned int elem_id_index,
130  const std::set<SubdomainID> & blks) const
131  {
132  return _id_mesh->getElemIDsOnBlocks(elem_id_index, blks);
133  }
134 
138  dof_id_type getElementID(const Elem * elem, unsigned int elem_id_index) const
139  {
140  if (elem_id_index == elem->n_extra_integers())
141  return elem->subdomain_id();
142 
143  return elem->get_extra_integer(elem_id_index);
144  }
145 
146 private:
149 
151  std::shared_ptr<MooseMesh> & _id_mesh;
152 
154  const std::string & _ei_name;
155 };
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:28
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...