Memosa-FVM  0.2
SpikeStorage Class Reference

#include <SpikeStorage.h>

Collaboration diagram for SpikeStorage:

Public Member Functions

 SpikeStorage (const CRConnectivity &conn, int semi_bandwidth)
 
 ~SpikeStorage ()
 
const vector< int > & getLSPKInterior () const
 
const vector< int > & getRSPKInterior () const
 
const vector< int > & getLSPKGhost () const
 
const vector< int > & getRSPKGhost () const
 
const vector< int > & getLSPKOffDiagPtr () const
 
const vector< int > & getRSPKOffDiagPtr () const
 
const vector< int > & getLSPKIndexI () const
 
const vector< int > & getLSPKIndexJ () const
 
const vector< int > & getRSPKIndexI () const
 
const vector< int > & getRSPKIndexJ () const
 
const vector< int > & getLSPKCountGhost () const
 
const vector< int > & getRSPKCountGhost () const
 
int getBandWidth () const
 

Private Member Functions

void init ()
 
void gatherCellSizes ()
 
void syncCellIDs ()
 
void setGlobalIndices ()
 
void setOffDiagPtr ()
 

Private Attributes

const CRConnectivity_conn
 
int _bandwidth
 
int _procID
 
int _localCellSelfCount
 
map< int, int > _ghostMap
 
vector< int > _cellSelfCounts
 
vector< int > _LSPK_INTERIOR
 
vector< int > _LSPK_GHOST
 
vector< int > _LSPK_OFFD_PTR
 
vector< int > _RSPK_INTERIOR
 
vector< int > _RSPK_GHOST
 
vector< int > _RSPK_OFFD_PTR
 
vector< int > _LSPK_I
 
vector< int > _LSPK_J
 
vector< int > _RSPK_I
 
vector< int > _RSPK_J
 
vector< int > _glblIndices
 
vector< int > _LSPKCountGhost
 
vector< int > _RSPKCountGhost
 

Detailed Description

Definition at line 15 of file SpikeStorage.h.

Constructor & Destructor Documentation

SpikeStorage::SpikeStorage ( const CRConnectivity conn,
int  semi_bandwidth 
)

Definition at line 17 of file SpikeStorage.cpp.

References init().

17  :
18 _conn(conn), _bandwidth(semi_bandwidth)
19 {
20  //logCtor();
21 
22  init();
23 }
const CRConnectivity & _conn
Definition: SpikeStorage.h:49
SpikeStorage::~SpikeStorage ( )

Definition at line 25 of file SpikeStorage.cpp.

26 {
27  //logDtor();
28 }

Member Function Documentation

void SpikeStorage::gatherCellSizes ( )
private

Definition at line 67 of file SpikeStorage.cpp.

References _cellSelfCounts, _conn, _localCellSelfCount, CRConnectivity::getRowSite(), and StorageSite::getSelfCount().

Referenced by init().

68 {
69  const StorageSite& cellSite = _conn.getRowSite();
70  _localCellSelfCount = cellSite.getSelfCount();
71 #ifdef FVM_PARALLEL
72  MPI::COMM_WORLD.Allgather(&_localCellSelfCount, 1, MPI::INT, &_cellSelfCounts[0], 1, MPI::INT);
73 #endif
74 }
int getSelfCount() const
Definition: StorageSite.h:40
const CRConnectivity & _conn
Definition: SpikeStorage.h:49
int _localCellSelfCount
Definition: SpikeStorage.h:53
vector< int > _cellSelfCounts
Definition: SpikeStorage.h:56
const StorageSite & getRowSite() const
int SpikeStorage::getBandWidth ( ) const
inline

Definition at line 39 of file SpikeStorage.h.

References _bandwidth.

39 { return _bandwidth;}
const vector<int>& SpikeStorage::getLSPKCountGhost ( ) const
inline

Definition at line 36 of file SpikeStorage.h.

References _LSPKCountGhost.

Referenced by SpikeMatrix< T_Diag, T_OffDiag, X >::setLMtrx().

36 { return _LSPKCountGhost;}
vector< int > _LSPKCountGhost
Definition: SpikeStorage.h:68
const vector<int>& SpikeStorage::getLSPKGhost ( ) const
inline

Definition at line 25 of file SpikeStorage.h.

References _LSPK_GHOST.

25 {return _LSPK_GHOST;}
vector< int > _LSPK_GHOST
Definition: SpikeStorage.h:58
const vector<int>& SpikeStorage::getLSPKIndexI ( ) const
inline

Definition at line 31 of file SpikeStorage.h.

References _LSPK_I.

Referenced by SpikeMatrix< T_Diag, T_OffDiag, X >::setLMtrx().

31 { return _LSPK_I;}
vector< int > _LSPK_I
Definition: SpikeStorage.h:63
const vector<int>& SpikeStorage::getLSPKIndexJ ( ) const
inline

Definition at line 32 of file SpikeStorage.h.

References _LSPK_J.

Referenced by SpikeMatrix< T_Diag, T_OffDiag, X >::setLMtrx().

32 { return _LSPK_J;}
vector< int > _LSPK_J
Definition: SpikeStorage.h:64
const vector<int>& SpikeStorage::getLSPKInterior ( ) const
inline

Definition at line 22 of file SpikeStorage.h.

References _LSPK_INTERIOR.

22 {return _LSPK_INTERIOR;}
vector< int > _LSPK_INTERIOR
Definition: SpikeStorage.h:57
const vector<int>& SpikeStorage::getLSPKOffDiagPtr ( ) const
inline

Definition at line 28 of file SpikeStorage.h.

References _LSPK_OFFD_PTR.

Referenced by SpikeMatrix< T_Diag, T_OffDiag, X >::setLMtrx().

28 {return _LSPK_OFFD_PTR;}
vector< int > _LSPK_OFFD_PTR
Definition: SpikeStorage.h:59
const vector<int>& SpikeStorage::getRSPKCountGhost ( ) const
inline

Definition at line 37 of file SpikeStorage.h.

References _RSPKCountGhost.

Referenced by SpikeMatrix< T_Diag, T_OffDiag, X >::setRMtrx().

37 { return _RSPKCountGhost;}
vector< int > _RSPKCountGhost
Definition: SpikeStorage.h:69
const vector<int>& SpikeStorage::getRSPKGhost ( ) const
inline

Definition at line 26 of file SpikeStorage.h.

References _RSPK_GHOST.

26 {return _RSPK_GHOST;}
vector< int > _RSPK_GHOST
Definition: SpikeStorage.h:61
const vector<int>& SpikeStorage::getRSPKIndexI ( ) const
inline

Definition at line 33 of file SpikeStorage.h.

References _RSPK_I.

Referenced by SpikeMatrix< T_Diag, T_OffDiag, X >::setRMtrx().

33 { return _RSPK_I;}
vector< int > _RSPK_I
Definition: SpikeStorage.h:65
const vector<int>& SpikeStorage::getRSPKIndexJ ( ) const
inline

Definition at line 34 of file SpikeStorage.h.

References _RSPK_J.

Referenced by SpikeMatrix< T_Diag, T_OffDiag, X >::setRMtrx().

34 { return _RSPK_J;}
vector< int > _RSPK_J
Definition: SpikeStorage.h:66
const vector<int>& SpikeStorage::getRSPKInterior ( ) const
inline

Definition at line 23 of file SpikeStorage.h.

References _RSPK_INTERIOR.

23 {return _RSPK_INTERIOR;}
vector< int > _RSPK_INTERIOR
Definition: SpikeStorage.h:60
const vector<int>& SpikeStorage::getRSPKOffDiagPtr ( ) const
inline

Definition at line 29 of file SpikeStorage.h.

References _RSPK_OFFD_PTR.

Referenced by SpikeMatrix< T_Diag, T_OffDiag, X >::setRMtrx().

29 {return _RSPK_OFFD_PTR;}
vector< int > _RSPK_OFFD_PTR
Definition: SpikeStorage.h:62
void SpikeStorage::init ( )
private

Definition at line 32 of file SpikeStorage.cpp.

References _bandwidth, _cellSelfCounts, _conn, _LSPK_GHOST, _LSPK_I, _LSPK_INTERIOR, _LSPK_J, _LSPK_OFFD_PTR, _LSPKCountGhost, _procID, _RSPK_GHOST, _RSPK_I, _RSPK_INTERIOR, _RSPK_J, _RSPK_OFFD_PTR, _RSPKCountGhost, gatherCellSizes(), CRConnectivity::getRowSite(), StorageSite::getSelfCount(), setGlobalIndices(), setOffDiagPtr(), and syncCellIDs().

Referenced by SpikeStorage().

33 {
34  //reserve minumum space for data structures
35  _LSPK_INTERIOR.reserve(_bandwidth);
36  _LSPK_GHOST.reserve (_bandwidth);
37  _LSPK_OFFD_PTR.reserve(_bandwidth);
38  _RSPK_INTERIOR.reserve(_bandwidth);
39  _RSPK_GHOST.reserve (_bandwidth);
40  _RSPK_OFFD_PTR.reserve(_bandwidth);
41  _LSPK_I.reserve(_bandwidth);
42  _LSPK_J.reserve(_bandwidth);
43  _RSPK_I.reserve(_bandwidth);
44  _RSPK_J.reserve(_bandwidth);
45  //keeping left and right spike matrices counter, we will know if there is more than one ghost cell
46  int ncells = _conn.getRowSite().getSelfCount();
47  _LSPKCountGhost.resize(ncells,0);
48  _RSPKCountGhost.resize(ncells,0);
49 
50 
51 #ifdef FVM_PARALLEL
52  _cellSelfCounts.resize( MPI::COMM_WORLD.Get_size() );
53  _procID = MPI::COMM_WORLD.Get_rank();
54 #endif
55  //get size of cells from other process
57  //syn operation to get neighbour local indices to this ghost cells
58  syncCellIDs();
59  //create local array to store global indices
61  //spk_offd_ptr
62  setOffDiagPtr();
63 }
int getSelfCount() const
Definition: StorageSite.h:40
vector< int > _LSPK_J
Definition: SpikeStorage.h:64
vector< int > _LSPK_I
Definition: SpikeStorage.h:63
void setOffDiagPtr()
vector< int > _RSPK_I
Definition: SpikeStorage.h:65
vector< int > _RSPK_GHOST
Definition: SpikeStorage.h:61
vector< int > _LSPK_OFFD_PTR
Definition: SpikeStorage.h:59
vector< int > _LSPKCountGhost
Definition: SpikeStorage.h:68
vector< int > _RSPK_OFFD_PTR
Definition: SpikeStorage.h:62
void syncCellIDs()
vector< int > _LSPK_GHOST
Definition: SpikeStorage.h:58
vector< int > _RSPKCountGhost
Definition: SpikeStorage.h:69
vector< int > _RSPK_INTERIOR
Definition: SpikeStorage.h:60
const CRConnectivity & _conn
Definition: SpikeStorage.h:49
vector< int > _RSPK_J
Definition: SpikeStorage.h:66
void setGlobalIndices()
vector< int > _cellSelfCounts
Definition: SpikeStorage.h:56
const StorageSite & getRowSite() const
vector< int > _LSPK_INTERIOR
Definition: SpikeStorage.h:57
void gatherCellSizes()
void SpikeStorage::setGlobalIndices ( )
private

Definition at line 109 of file SpikeStorage.cpp.

References _bandwidth, _cellSelfCounts, _conn, _ghostMap, _LSPK_GHOST, _LSPK_I, _LSPK_INTERIOR, _LSPK_J, _LSPKCountGhost, _procID, _RSPK_GHOST, _RSPK_I, _RSPK_INTERIOR, _RSPK_J, _RSPKCountGhost, StorageSite::getGatherMap(), StorageSite::getGatherProcID(), Array< T >::getLength(), and CRConnectivity::getRowSite().

Referenced by init().

110 {
111  int indx_base = 0;
112  for ( int i = 1; i <= _procID; i++)
113  indx_base += _cellSelfCounts[i-1];
114 
115  const StorageSite& cellSite = _conn.getRowSite();
116  const StorageSite::GatherMap& gatherMap = cellSite.getGatherMap();
117  //loop over gather maps
118  foreach( const StorageSite::GatherMap::value_type& mpos, gatherMap ){
119  const StorageSite& oSite = *mpos.first;
120  const int oRank = oSite.getGatherProcID();
121  const Array<int>& ghostIndices = *(mpos.second);
122  //get inner indices
123  Array<int> innerIndices( ghostIndices.getLength() );
124  for ( int n = 0; n < ghostIndices.getLength(); n++ ){
125  innerIndices[n] = _conn( ghostIndices[n], 0 );
126  }
127  //finding base for neighbour
128  int indx_base_other = 0;
129  for ( int i = 1; i <= oRank; i++)
130  indx_base_other += _cellSelfCounts[i-1];
131 
132  //check
133  for ( int n = 0; n < ghostIndices.getLength(); n++ ){
134  const int iGlbIndx = indx_base + innerIndices[n];
135  const int jGlbIndx = indx_base_other + _ghostMap[ ghostIndices[n] ];
136  //check left or right
137  if ( (iGlbIndx > jGlbIndx) && ((iGlbIndx - jGlbIndx) <= _bandwidth) ){
138  _LSPK_INTERIOR.push_back( innerIndices[n] );
139  _LSPK_GHOST.push_back ( ghostIndices[n] );
140  _LSPK_I.push_back( innerIndices[n] );
141  _LSPK_J.push_back( _bandwidth + jGlbIndx - indx_base );
142  _LSPKCountGhost[innerIndices[n]] += 1;
143  } else if ( (iGlbIndx < jGlbIndx) && (jGlbIndx - iGlbIndx) <= _bandwidth ) {
144  _RSPK_INTERIOR.push_back( innerIndices[n] );
145  _RSPK_GHOST.push_back ( ghostIndices[n] );
146  _RSPK_I.push_back( innerIndices[n] );
147  _RSPK_J.push_back( jGlbIndx - indx_base_other );
148  _RSPKCountGhost[innerIndices[n]] += 1;
149  }
150  }
151  }
152 
153 }
vector< int > _LSPK_J
Definition: SpikeStorage.h:64
vector< int > _LSPK_I
Definition: SpikeStorage.h:63
vector< int > _RSPK_I
Definition: SpikeStorage.h:65
vector< int > _RSPK_GHOST
Definition: SpikeStorage.h:61
vector< int > _LSPKCountGhost
Definition: SpikeStorage.h:68
vector< int > _LSPK_GHOST
Definition: SpikeStorage.h:58
vector< int > _RSPKCountGhost
Definition: SpikeStorage.h:69
vector< int > _RSPK_INTERIOR
Definition: SpikeStorage.h:60
int getGatherProcID() const
Definition: StorageSite.h:83
const CRConnectivity & _conn
Definition: SpikeStorage.h:49
vector< int > _RSPK_J
Definition: SpikeStorage.h:66
map< int, int > _ghostMap
Definition: SpikeStorage.h:54
const GatherMap & getGatherMap() const
Definition: StorageSite.h:59
vector< int > _cellSelfCounts
Definition: SpikeStorage.h:56
map< const StorageSite *, shared_ptr< Array< int > > > GatherMap
Definition: StorageSite.h:24
const StorageSite & getRowSite() const
vector< int > _LSPK_INTERIOR
Definition: SpikeStorage.h:57
int getLength() const
Definition: Array.h:87
void SpikeStorage::setOffDiagPtr ( )
private

Definition at line 156 of file SpikeStorage.cpp.

References _conn, _LSPK_GHOST, _LSPK_INTERIOR, _LSPK_OFFD_PTR, _RSPK_GHOST, _RSPK_INTERIOR, _RSPK_OFFD_PTR, CRConnectivity::getCol(), and CRConnectivity::getRow().

Referenced by init().

157 {
158  //loop over LSPK
159  const Array<int>& row = _conn.getRow();
160  const Array<int>& col = _conn.getCol();
161  for( unsigned int i = 0; i < _LSPK_INTERIOR.size(); i++ ){
162  const int rowIndx = _LSPK_INTERIOR[i];
163  for ( int j = row[rowIndx]; j < row[rowIndx+1]; j++ ){
164  const int neighCellID = col[j];
165  if ( neighCellID == _LSPK_GHOST[i] )
166  _LSPK_OFFD_PTR.push_back( j );
167  }
168  }
169  //loop over RSPK
170  for( unsigned int i = 0; i < _RSPK_INTERIOR.size(); i++ ){
171  const int rowIndx = _RSPK_INTERIOR[i];
172  for ( int j = row[rowIndx]; j < row[rowIndx+1]; j++ ){
173  const int neighCellID = col[j];
174  if ( neighCellID == _RSPK_GHOST[i] )
175  _RSPK_OFFD_PTR.push_back( j );
176  }
177  }
178 
179 
180 }
const Array< int > & getCol() const
const Array< int > & getRow() const
vector< int > _RSPK_GHOST
Definition: SpikeStorage.h:61
vector< int > _LSPK_OFFD_PTR
Definition: SpikeStorage.h:59
vector< int > _RSPK_OFFD_PTR
Definition: SpikeStorage.h:62
vector< int > _LSPK_GHOST
Definition: SpikeStorage.h:58
vector< int > _RSPK_INTERIOR
Definition: SpikeStorage.h:60
const CRConnectivity & _conn
Definition: SpikeStorage.h:49
vector< int > _LSPK_INTERIOR
Definition: SpikeStorage.h:57
void SpikeStorage::syncCellIDs ( )
private

Definition at line 77 of file SpikeStorage.cpp.

References _conn, _ghostMap, StorageSite::getCount(), CRConnectivity::getRowSite(), StorageSite::getSelfCount(), and Array< T >::zero().

Referenced by init().

78 {
79  shared_ptr<Field> cellIndicesField( new Field("cellID") );
80 
81  const StorageSite& cells = _conn.getRowSite();
82  const int cellCount = cells.getCount();
83  shared_ptr< Array<int> > indPtr( new Array<int>(cellCount) );
84  Array<int>& indices = *indPtr;
85  Array<int> indicesOld( cellCount ); //keep original indices
86  //zeroing
87  indices.zero();
88  //filling indices
89  for ( int n = 0; n < cells.getCount(); n++ ){
90  indices[n] = n;
91  indicesOld[n] = n;
92  }
93  //volume add
94  cellIndicesField->addArray(cells, indPtr);
95  //synLocal to get neighbourhood
96  cellIndicesField->syncLocal();
97  //create mapping between old and new ghost ids
98  int ibeg = cells.getSelfCount();
99  int iend = cells.getCount();
100  for ( int i = ibeg; i < iend; i++ ){
101  _ghostMap[ indicesOld[i] ] = indices[i];
102  }
103 
104 
105 }
virtual void zero()
Definition: Array.h:281
int getSelfCount() const
Definition: StorageSite.h:40
Definition: Field.h:14
const CRConnectivity & _conn
Definition: SpikeStorage.h:49
map< int, int > _ghostMap
Definition: SpikeStorage.h:54
int getCount() const
Definition: StorageSite.h:39
const StorageSite & getRowSite() const

Member Data Documentation

int SpikeStorage::_bandwidth
private

Definition at line 50 of file SpikeStorage.h.

Referenced by getBandWidth(), init(), and setGlobalIndices().

vector<int> SpikeStorage::_cellSelfCounts
private

Definition at line 56 of file SpikeStorage.h.

Referenced by gatherCellSizes(), init(), and setGlobalIndices().

const CRConnectivity& SpikeStorage::_conn
private

Definition at line 49 of file SpikeStorage.h.

Referenced by gatherCellSizes(), init(), setGlobalIndices(), setOffDiagPtr(), and syncCellIDs().

map<int,int> SpikeStorage::_ghostMap
private

Definition at line 54 of file SpikeStorage.h.

Referenced by setGlobalIndices(), and syncCellIDs().

vector<int> SpikeStorage::_glblIndices
private

Definition at line 67 of file SpikeStorage.h.

int SpikeStorage::_localCellSelfCount
private

Definition at line 53 of file SpikeStorage.h.

Referenced by gatherCellSizes().

vector<int> SpikeStorage::_LSPK_GHOST
private

Definition at line 58 of file SpikeStorage.h.

Referenced by getLSPKGhost(), init(), setGlobalIndices(), and setOffDiagPtr().

vector<int> SpikeStorage::_LSPK_I
private

Definition at line 63 of file SpikeStorage.h.

Referenced by getLSPKIndexI(), init(), and setGlobalIndices().

vector<int> SpikeStorage::_LSPK_INTERIOR
private

Definition at line 57 of file SpikeStorage.h.

Referenced by getLSPKInterior(), init(), setGlobalIndices(), and setOffDiagPtr().

vector<int> SpikeStorage::_LSPK_J
private

Definition at line 64 of file SpikeStorage.h.

Referenced by getLSPKIndexJ(), init(), and setGlobalIndices().

vector<int> SpikeStorage::_LSPK_OFFD_PTR
private

Definition at line 59 of file SpikeStorage.h.

Referenced by getLSPKOffDiagPtr(), init(), and setOffDiagPtr().

vector<int> SpikeStorage::_LSPKCountGhost
private

Definition at line 68 of file SpikeStorage.h.

Referenced by getLSPKCountGhost(), init(), and setGlobalIndices().

int SpikeStorage::_procID
private

Definition at line 52 of file SpikeStorage.h.

Referenced by init(), and setGlobalIndices().

vector<int> SpikeStorage::_RSPK_GHOST
private

Definition at line 61 of file SpikeStorage.h.

Referenced by getRSPKGhost(), init(), setGlobalIndices(), and setOffDiagPtr().

vector<int> SpikeStorage::_RSPK_I
private

Definition at line 65 of file SpikeStorage.h.

Referenced by getRSPKIndexI(), init(), and setGlobalIndices().

vector<int> SpikeStorage::_RSPK_INTERIOR
private

Definition at line 60 of file SpikeStorage.h.

Referenced by getRSPKInterior(), init(), setGlobalIndices(), and setOffDiagPtr().

vector<int> SpikeStorage::_RSPK_J
private

Definition at line 66 of file SpikeStorage.h.

Referenced by getRSPKIndexJ(), init(), and setGlobalIndices().

vector<int> SpikeStorage::_RSPK_OFFD_PTR
private

Definition at line 62 of file SpikeStorage.h.

Referenced by getRSPKOffDiagPtr(), init(), and setOffDiagPtr().

vector<int> SpikeStorage::_RSPKCountGhost
private

Definition at line 69 of file SpikeStorage.h.

Referenced by getRSPKCountGhost(), init(), and setGlobalIndices().


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