47 template <
class _Type,
class _Hash=CepsHash>
66 append(
const _Type&x ,
const _Hash& hashValue);
180 atHash(
const _Hash& hId,
const _Type& def);
184 atHash(
const _Hash& hId,
const _Type& def)
const;
std::map< _Key, _Tp, _Compare, _Alloc > CepsMap
C++ map.
std::vector< _Type, _Alloc > CepsVector
C++ vector.
CepsIndex CepsGlobalIndex
Many uses. Has to be signed for PETSc.
std::make_unsigned_t< CepsInt > CepsUInt
Unsigned version on CepsInt.
CepsIndex CepsLocalIndex
To use when the indexing is only on one process.
A map destined for things that have (or could have) a global index and must be distributed amongst CP...
_Type & atLocal(const CepsLocalIndex &lId)
Access value with local ID.
void reserve(CepsUInt n)
Prepare room for storage.
void registerIndices(const CepsLocalIndex &localId, const CepsGlobalIndex &globalId)
Stores the pair (localID,globalID)
CepsMap< CepsLocalIndex, CepsGlobalIndex > m_localToGlobal
reverse map
const _Type & atHash(const _Hash &hId, const _Type &def) const
Access value with given hash, with default value.
void reset()
Wipes content, erase structure.
CepsVector< _Type > & all()
acces to data
CepsBool hasLocal(const CepsLocalIndex &lId) const
Tells if item with local index lID can be found on this CPU.
void append(const _Type &x, const _Hash &hashValue, const CepsGlobalIndex &gId)
Emplace an element in the map, with an extra global index.
_Type & atGlobal(const CepsGlobalIndex &gId)
Access value with global ID.
CepsMap< _Hash, CepsLocalIndex > m_hash
hash map
CepsUInt size() const
Number of elements.
CepsBool contains(const _Type &x) const
Tells if the map has the element x.
const CepsGlobalIndex & localToGlobal(const CepsLocalIndex &lId) const
Local index to global index conversion.
CepsVector< CepsUInt > m_localSizes
sizes of maps on each cpu
~LocalGlobalMapping()
Destructor.
const _Type & atHash(const _Hash &hId) const
Access value with given hash, with default value.
const CepsVector< _Type > & all() const
access to data
void setGlobalIndicesFromLocals()
Modifies the local indices by adding the total number of elements on CPUs before self.
void registerHash(const CepsLocalIndex &localId, const _Hash &hashValue)
Stores the localID associated to the hash.
const CepsLocalIndex & hashToLocal(const _Hash &hId) const
Access value with given hash.
_Type & atHash(const _Hash &hId, const _Type &def)
Access value with given hash, with default value.
void updateObjects(std::function< void(_Type &, CepsGlobalIndex)> func)
Applies function func to all elements stored.
_Type & atLocal(const CepsLocalIndex &lId, const _Type &def)
Access value with local ID, with default value.
const CepsLocalIndex & globalToLocal(const CepsGlobalIndex &gId) const
Global index to local index conversion.
CepsMap< CepsGlobalIndex, CepsLocalIndex > m_globalToLocal
global local map
_Type & atGlobal(const CepsGlobalIndex &gId, const _Type &def)
Access value with global ID, with default value.
_Type & atHash(const _Hash &hId)
Access value with given hash, with default value.
const CepsGlobalIndex & hashToGlobal(const _Hash &hId) const
Access value with given hash.
void destroyObjects()
Wipes content, keeps structure.
const CepsVector< CepsUInt > & getLocalSizes() const
Number of elements on each CPU synchronize must be called beforehand.
CepsBool hasHash(const _Hash &hId) const
Tells if map contains the hash hID.
CepsLocalIndex pushBack(const _Type &x)
Adds an element to the map, returns the localID.
CepsBool hasGlobal(const CepsGlobalIndex &gId) const
Tells if item with global index gID can be found on this CPU.
CepsVector< _Type > m_data
Stored objects.
const _Type & atLocal(const CepsLocalIndex &lId) const
Access value with local ID.
LocalGlobalMapping()
Constructor, empty structures.
const _Type & atGlobal(const CepsGlobalIndex &gId, const _Type &def) const
Access value with global ID, with default value.
void append(const _Type &x, const _Hash &hashValue)
Emplace an element in the map.
const _Type & atGlobal(const CepsGlobalIndex &gId) const
Access value with global ID.
void synchronizeLocalSizes()
Get info on number of local elements from each CPU.
const _Type & atLocal(const CepsLocalIndex &lId, const _Type &def) const
Access value with local ID, with default value.
CepsBool m_synchronized
true if sizes were updated