CEPS  24.01
Cardiac ElectroPhysiology Simulator
LocalGlobalMapping< _Type, _Hash > Class Template Reference

Detailed Description

template<class _Type, class _Hash = CepsHash>
class LocalGlobalMapping< _Type, _Hash >

A map destined for things that have (or could have) a global index and must be distributed amongst CPUs. The class manages the local to global indices mapping, and back.

When placing elements in this map, a hash that is unique and the same across CPUs must be given. This is for communication purposes.

Template Parameters
_Type

Definition at line 48 of file LocalGlobalMapping.hpp.

#include <LocalGlobalMapping.hpp>

Public Member Functions

 LocalGlobalMapping ()
 Constructor, empty structures. More...
 
 ~LocalGlobalMapping ()
 Destructor. More...
 
void reserve (CepsUInt n)
 Prepare room for storage. More...
 
void append (const _Type &x, const _Hash &hashValue)
 Emplace an element in the map. More...
 
void append (const _Type &x, const _Hash &hashValue, const CepsGlobalIndex &gId)
 Emplace an element in the map, with an extra global index. More...
 
const CepsVector< _Type > & all () const
 access to data More...
 
CepsVector< _Type > & all ()
 acces to data More...
 
CepsUInt size () const
 Number of elements. More...
 
CepsBool contains (const _Type &x) const
 Tells if the map has the element x. More...
 
void destroyObjects ()
 Wipes content, keeps structure. More...
 
void reset ()
 Wipes content, erase structure. More...
 
void synchronizeLocalSizes ()
 Get info on number of local elements from each CPU. More...
 
void setGlobalIndicesFromLocals ()
 Modifies the local indices by adding the total number of elements on CPUs before self. More...
 
void updateObjects (std::function< void(_Type &, CepsGlobalIndex)> func)
 Applies function func to all elements stored. More...
 
const CepsVector< CepsUInt > & getLocalSizes () const
 Number of elements on each CPU synchronize must be called beforehand. More...
 
CepsBool hasLocal (const CepsLocalIndex &lId) const
 Tells if item with local index lID can be found on this CPU. More...
 
CepsBool hasGlobal (const CepsGlobalIndex &gId) const
 Tells if item with global index gID can be found on this CPU. More...
 
CepsBool hasHash (const _Hash &hId) const
 Tells if map contains the hash hID. More...
 
_Type & atLocal (const CepsLocalIndex &lId, const _Type &def)
 Access value with local ID, with default value. More...
 
const _Type & atLocal (const CepsLocalIndex &lId, const _Type &def) const
 Access value with local ID, with default value. More...
 
const _Type & atLocal (const CepsLocalIndex &lId) const
 Access value with local ID. More...
 
_Type & atLocal (const CepsLocalIndex &lId)
 Access value with local ID. More...
 
const CepsGlobalIndexlocalToGlobal (const CepsLocalIndex &lId) const
 Local index to global index conversion. More...
 
_Type & atGlobal (const CepsGlobalIndex &gId, const _Type &def)
 Access value with global ID, with default value. More...
 
const _Type & atGlobal (const CepsGlobalIndex &gId, const _Type &def) const
 Access value with global ID, with default value. More...
 
_Type & atGlobal (const CepsGlobalIndex &gId)
 Access value with global ID. More...
 
const _Type & atGlobal (const CepsGlobalIndex &gId) const
 Access value with global ID. More...
 
const CepsLocalIndexglobalToLocal (const CepsGlobalIndex &gId) const
 Global index to local index conversion. More...
 
_Type & atHash (const _Hash &hId)
 Access value with given hash, with default value. More...
 
const _Type & atHash (const _Hash &hId) const
 Access value with given hash, with default value. More...
 
_Type & atHash (const _Hash &hId, const _Type &def)
 Access value with given hash, with default value. More...
 
const _Type & atHash (const _Hash &hId, const _Type &def) const
 Access value with given hash, with default value. More...
 
const CepsLocalIndexhashToLocal (const _Hash &hId) const
 Access value with given hash. More...
 
const CepsGlobalIndexhashToGlobal (const _Hash &hId) const
 Access value with given hash. More...
 
void registerIndices (const CepsLocalIndex &localId, const CepsGlobalIndex &globalId)
 Stores the pair (localID,globalID) More...
 

Protected Member Functions

CepsLocalIndex pushBack (const _Type &x)
 Adds an element to the map, returns the localID. More...
 
void registerHash (const CepsLocalIndex &localId, const _Hash &hashValue)
 Stores the localID associated to the hash. More...
 

Protected Attributes

CepsVector< _Type > m_data
 Stored objects. More...
 
CepsMap< _Hash, CepsLocalIndexm_hash
 hash map More...
 
CepsMap< CepsGlobalIndex, CepsLocalIndexm_globalToLocal
 global local map More...
 
CepsMap< CepsLocalIndex, CepsGlobalIndexm_localToGlobal
 reverse map More...
 
CepsVector< CepsUIntm_localSizes
 sizes of maps on each cpu More...
 
CepsBool m_synchronized
 true if sizes were updated More...
 

Constructor & Destructor Documentation

◆ LocalGlobalMapping()

template<class _Type , class _Hash = CepsHash>
LocalGlobalMapping< _Type, _Hash >::LocalGlobalMapping ( )

Constructor, empty structures.

◆ ~LocalGlobalMapping()

template<class _Type , class _Hash = CepsHash>
LocalGlobalMapping< _Type, _Hash >::~LocalGlobalMapping ( )

Destructor.

Member Function Documentation

◆ all() [1/2]

template<class _Type , class _Hash = CepsHash>
CepsVector<_Type>& LocalGlobalMapping< _Type, _Hash >::all ( )

acces to data

◆ all() [2/2]

template<class _Type , class _Hash = CepsHash>
const CepsVector<_Type>& LocalGlobalMapping< _Type, _Hash >::all ( ) const

access to data

◆ append() [1/2]

template<class _Type , class _Hash = CepsHash>
void LocalGlobalMapping< _Type, _Hash >::append ( const _Type &  x,
const _Hash &  hashValue 
)

Emplace an element in the map.

Parameters
xthe element to place
hashValueunique identifier for the element

◆ append() [2/2]

template<class _Type , class _Hash = CepsHash>
void LocalGlobalMapping< _Type, _Hash >::append ( const _Type &  x,
const _Hash &  hashValue,
const CepsGlobalIndex gId 
)

Emplace an element in the map, with an extra global index.

Parameters
xthe element to place
hashValueunique identifier for the element
gIda global index

◆ atGlobal() [1/4]

template<class _Type , class _Hash = CepsHash>
_Type& LocalGlobalMapping< _Type, _Hash >::atGlobal ( const CepsGlobalIndex gId)

Access value with global ID.

◆ atGlobal() [2/4]

template<class _Type , class _Hash = CepsHash>
const _Type& LocalGlobalMapping< _Type, _Hash >::atGlobal ( const CepsGlobalIndex gId) const

Access value with global ID.

◆ atGlobal() [3/4]

template<class _Type , class _Hash = CepsHash>
_Type& LocalGlobalMapping< _Type, _Hash >::atGlobal ( const CepsGlobalIndex gId,
const _Type &  def 
)

Access value with global ID, with default value.

◆ atGlobal() [4/4]

template<class _Type , class _Hash = CepsHash>
const _Type& LocalGlobalMapping< _Type, _Hash >::atGlobal ( const CepsGlobalIndex gId,
const _Type &  def 
) const

Access value with global ID, with default value.

◆ atHash() [1/4]

template<class _Type , class _Hash = CepsHash>
_Type& LocalGlobalMapping< _Type, _Hash >::atHash ( const _Hash &  hId)

Access value with given hash, with default value.

◆ atHash() [2/4]

template<class _Type , class _Hash = CepsHash>
const _Type& LocalGlobalMapping< _Type, _Hash >::atHash ( const _Hash &  hId) const

Access value with given hash, with default value.

◆ atHash() [3/4]

template<class _Type , class _Hash = CepsHash>
_Type& LocalGlobalMapping< _Type, _Hash >::atHash ( const _Hash &  hId,
const _Type &  def 
)

Access value with given hash, with default value.

◆ atHash() [4/4]

template<class _Type , class _Hash = CepsHash>
const _Type& LocalGlobalMapping< _Type, _Hash >::atHash ( const _Hash &  hId,
const _Type &  def 
) const

Access value with given hash, with default value.

◆ atLocal() [1/4]

template<class _Type , class _Hash = CepsHash>
_Type& LocalGlobalMapping< _Type, _Hash >::atLocal ( const CepsLocalIndex lId)

Access value with local ID.

◆ atLocal() [2/4]

template<class _Type , class _Hash = CepsHash>
const _Type& LocalGlobalMapping< _Type, _Hash >::atLocal ( const CepsLocalIndex lId) const

Access value with local ID.

◆ atLocal() [3/4]

template<class _Type , class _Hash = CepsHash>
_Type& LocalGlobalMapping< _Type, _Hash >::atLocal ( const CepsLocalIndex lId,
const _Type &  def 
)

Access value with local ID, with default value.

◆ atLocal() [4/4]

template<class _Type , class _Hash = CepsHash>
const _Type& LocalGlobalMapping< _Type, _Hash >::atLocal ( const CepsLocalIndex lId,
const _Type &  def 
) const

Access value with local ID, with default value.

◆ contains()

template<class _Type , class _Hash = CepsHash>
CepsBool LocalGlobalMapping< _Type, _Hash >::contains ( const _Type &  x) const

Tells if the map has the element x.

◆ destroyObjects()

template<class _Type , class _Hash = CepsHash>
void LocalGlobalMapping< _Type, _Hash >::destroyObjects ( )

Wipes content, keeps structure.

◆ getLocalSizes()

template<class _Type , class _Hash = CepsHash>
const CepsVector<CepsUInt>& LocalGlobalMapping< _Type, _Hash >::getLocalSizes ( ) const

Number of elements on each CPU synchronize must be called beforehand.

◆ globalToLocal()

template<class _Type , class _Hash = CepsHash>
const CepsLocalIndex& LocalGlobalMapping< _Type, _Hash >::globalToLocal ( const CepsGlobalIndex gId) const

Global index to local index conversion.

◆ hasGlobal()

template<class _Type , class _Hash = CepsHash>
CepsBool LocalGlobalMapping< _Type, _Hash >::hasGlobal ( const CepsGlobalIndex gId) const

Tells if item with global index gID can be found on this CPU.

◆ hasHash()

template<class _Type , class _Hash = CepsHash>
CepsBool LocalGlobalMapping< _Type, _Hash >::hasHash ( const _Hash &  hId) const

Tells if map contains the hash hID.

◆ hashToGlobal()

template<class _Type , class _Hash = CepsHash>
const CepsGlobalIndex& LocalGlobalMapping< _Type, _Hash >::hashToGlobal ( const _Hash &  hId) const

Access value with given hash.

◆ hashToLocal()

template<class _Type , class _Hash = CepsHash>
const CepsLocalIndex& LocalGlobalMapping< _Type, _Hash >::hashToLocal ( const _Hash &  hId) const

Access value with given hash.

◆ hasLocal()

template<class _Type , class _Hash = CepsHash>
CepsBool LocalGlobalMapping< _Type, _Hash >::hasLocal ( const CepsLocalIndex lId) const

Tells if item with local index lID can be found on this CPU.

◆ localToGlobal()

template<class _Type , class _Hash = CepsHash>
const CepsGlobalIndex& LocalGlobalMapping< _Type, _Hash >::localToGlobal ( const CepsLocalIndex lId) const

Local index to global index conversion.

◆ pushBack()

template<class _Type , class _Hash = CepsHash>
CepsLocalIndex LocalGlobalMapping< _Type, _Hash >::pushBack ( const _Type &  x)
protected

Adds an element to the map, returns the localID.

◆ registerHash()

template<class _Type , class _Hash = CepsHash>
void LocalGlobalMapping< _Type, _Hash >::registerHash ( const CepsLocalIndex localId,
const _Hash &  hashValue 
)
protected

Stores the localID associated to the hash.

◆ registerIndices()

template<class _Type , class _Hash = CepsHash>
void LocalGlobalMapping< _Type, _Hash >::registerIndices ( const CepsLocalIndex localId,
const CepsGlobalIndex globalId 
)

Stores the pair (localID,globalID)

◆ reserve()

template<class _Type , class _Hash = CepsHash>
void LocalGlobalMapping< _Type, _Hash >::reserve ( CepsUInt  n)

Prepare room for storage.

◆ reset()

template<class _Type , class _Hash = CepsHash>
void LocalGlobalMapping< _Type, _Hash >::reset ( )

Wipes content, erase structure.

◆ setGlobalIndicesFromLocals()

template<class _Type , class _Hash = CepsHash>
void LocalGlobalMapping< _Type, _Hash >::setGlobalIndicesFromLocals ( )

Modifies the local indices by adding the total number of elements on CPUs before self.

◆ size()

template<class _Type , class _Hash = CepsHash>
CepsUInt LocalGlobalMapping< _Type, _Hash >::size ( ) const

Number of elements.

◆ synchronizeLocalSizes()

template<class _Type , class _Hash = CepsHash>
void LocalGlobalMapping< _Type, _Hash >::synchronizeLocalSizes ( )

Get info on number of local elements from each CPU.

◆ updateObjects()

template<class _Type , class _Hash = CepsHash>
void LocalGlobalMapping< _Type, _Hash >::updateObjects ( std::function< void(_Type &, CepsGlobalIndex)>  func)

Applies function func to all elements stored.

Parameters
funcHas the globalID as second argument

Field Documentation

◆ m_data

template<class _Type , class _Hash = CepsHash>
CepsVector<_Type> LocalGlobalMapping< _Type, _Hash >::m_data
protected

Stored objects.

Definition at line 212 of file LocalGlobalMapping.hpp.

◆ m_globalToLocal

template<class _Type , class _Hash = CepsHash>
CepsMap<CepsGlobalIndex,CepsLocalIndex> LocalGlobalMapping< _Type, _Hash >::m_globalToLocal
protected

global local map

Definition at line 214 of file LocalGlobalMapping.hpp.

◆ m_hash

template<class _Type , class _Hash = CepsHash>
CepsMap<_Hash,CepsLocalIndex> LocalGlobalMapping< _Type, _Hash >::m_hash
protected

hash map

Definition at line 213 of file LocalGlobalMapping.hpp.

◆ m_localSizes

template<class _Type , class _Hash = CepsHash>
CepsVector<CepsUInt> LocalGlobalMapping< _Type, _Hash >::m_localSizes
protected

sizes of maps on each cpu

Definition at line 216 of file LocalGlobalMapping.hpp.

◆ m_localToGlobal

template<class _Type , class _Hash = CepsHash>
CepsMap<CepsLocalIndex,CepsGlobalIndex> LocalGlobalMapping< _Type, _Hash >::m_localToGlobal
protected

reverse map

Definition at line 215 of file LocalGlobalMapping.hpp.

◆ m_synchronized

template<class _Type , class _Hash = CepsHash>
CepsBool LocalGlobalMapping< _Type, _Hash >::m_synchronized
protected

true if sizes were updated

Definition at line 217 of file LocalGlobalMapping.hpp.


The documentation for this class was generated from the following file: