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 : static InputParameters validParams(); 27 : 28 : ElementIDInterface(const MooseObject * moose_object); 29 : 30 : #ifdef MOOSE_KOKKOS_ENABLED 31 : /** 32 : * Special constructor used for Kokkos functor copy during parallel dispatch 33 : */ 34 : ElementIDInterface(const ElementIDInterface & object, const Moose::Kokkos::FunctorCopy & key); 35 : #endif 36 : 37 311040 : virtual ~ElementIDInterface() {} 38 : 39 : /** 40 : * Gets index of an element integer with a parameter of the object derived from this interface 41 : * @param id_parameter_name Name of object parameter 42 : * @param comp Component number for vector of integer names 43 : * @return Index of the element integer 44 : */ 45 : virtual unsigned int getElementIDIndex(const std::string & id_parameter_name, 46 : unsigned int comp = 0) const; 47 : 48 : /** 49 : * Return the accessing integer for an extra element integer with its name 50 : * @param id_name Name of element integer 51 : * @return Index of the element integer 52 : */ 53 : virtual unsigned int getElementIDIndexByName(const std::string & id_name) const; 54 : 55 : /** 56 : * Gets an element integer with a parameter of the object derived from this interface 57 : * @param id_parameter_name Name of object parameter 58 : * @param comp Component number for vector of integer names 59 : * @return Integer for the current element 60 : */ 61 : virtual const dof_id_type & getElementID(const std::string & id_parameter_name, 62 : unsigned int comp = 0) const; 63 : 64 : /** 65 : * Gets a neighbor element integer with a parameter of the object derived from this interface 66 : * @param id_parameter_name Name of object parameter 67 : * @param comp Component number for vector of integer names 68 : * @return Integer for the neighbor element 69 : */ 70 : virtual const dof_id_type & getElementIDNeighbor(const std::string & id_parameter_name, 71 : unsigned int comp = 0) const; 72 : 73 : /** 74 : * Gets an element integer with the element integer name 75 : * @param id_name Name of element integer 76 : * @return Integer for the current element 77 : */ 78 : virtual const dof_id_type & getElementIDByName(const std::string & id_name) const; 79 : 80 : /** 81 : * Gets a neighbor element integer with the element integer name 82 : * @param id_name Name of element integer 83 : * @return Integer for the neighbor element 84 : */ 85 : virtual const dof_id_type & getElementIDNeighborByName(const std::string & id_name) const; 86 : 87 : /** 88 : * Whether mesh has an element integer with a given name 89 : */ 90 : bool hasElementID(const std::string & id_name) const { return _id_mesh->hasElementID(id_name); } 91 : 92 : /** 93 : * Return the maximum element ID for an element integer with its index 94 : */ 95 : dof_id_type maxElementID(unsigned int elem_id_index) const 96 : { 97 : return _id_mesh->maxElementID(elem_id_index); 98 : } 99 : 100 : /** 101 : * Return the minimum element ID for an element integer with its index 102 : */ 103 : dof_id_type minElementID(unsigned int elem_id_index) const 104 : { 105 : return _id_mesh->minElementID(elem_id_index); 106 : } 107 : 108 : /** 109 : * Whether two element integers are identical for all elements 110 : */ 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 : 116 : /** 117 : * Get the mapping from IDs of one extra element integer to another given the two integer names 118 : */ 119 : std::unordered_map<dof_id_type, std::set<dof_id_type>> 120 12 : getElemIDMapping(const std::string & id_name1, const std::string & id_name2) const 121 : { 122 12 : return _id_mesh->getElemIDMapping(id_name1, id_name2); 123 : } 124 : 125 : /** 126 : * Return all the unique element IDs for an element integer with its index on the entire domain 127 : */ 128 42 : std::set<dof_id_type> getAllElemIDs(unsigned int elem_id_index) const 129 : { 130 42 : return _id_mesh->getAllElemIDs(elem_id_index); 131 : } 132 : 133 : /** 134 : * Return all the unique element IDs for an extra element integer with its index on a set of 135 : * subdomains 136 : */ 137 70 : std::set<dof_id_type> getElemIDsOnBlocks(unsigned int elem_id_index, 138 : const std::set<SubdomainID> & blks) const 139 : { 140 70 : return _id_mesh->getElemIDsOnBlocks(elem_id_index, blks); 141 : } 142 : 143 : /** 144 : * Get an element integer for an element 145 : */ 146 3600 : dof_id_type getElementID(const Elem * elem, unsigned int elem_id_index) const 147 : { 148 3600 : if (elem_id_index == elem->n_extra_integers()) 149 1800 : return elem->subdomain_id(); 150 : 151 1800 : return elem->get_extra_integer(elem_id_index); 152 : } 153 : 154 : private: 155 : /// Reference to the object's input parameters 156 : const InputParameters & _obj_parameters; 157 : 158 : /// References to the mesh and displaced mesh (currently in the ActionWarehouse) 159 : std::shared_ptr<MooseMesh> & _id_mesh; 160 : 161 : /// Name of the object using this interface 162 : const std::string & _ei_name; 163 : };