Memosa-FVM  0.2
CRConnectivity.h
Go to the documentation of this file.
1 // This file os part of FVM
2 // Copyright (c) 2012 FVM Authors
3 // See LICENSE file for terms.
4 
5 #ifndef _CRCONNECTIVITY_H_
6 #define _CRCONNECTIVITY_H_
7 
8 #include "misc.h"
9 #include "Array.h"
10 #include "Vector.h"
11 #include "StorageSite.h"
12 
53 {
54 public:
56 
57  enum CRTYPE
58  {
59  CELLCELL1 = 1,
61  };
62 
63  CRConnectivity(const StorageSite& rowSite, const StorageSite& colSite);
65 
66  DEFINE_TYPENAME("CRConnectivity");
67 
68  int getRowDim() const {return _rowDim;}
69  int getColDim() const {return _colDim;}
70 
71  const StorageSite& getRowSite() const {return *_rowSite;}
72  const StorageSite& getColSite() const {return *_colSite;}
73 
74  shared_ptr<CRConnectivity> getTranspose() const;
75  shared_ptr<CRConnectivity> getMultiTranspose(const int varSize) const;
76 
77  shared_ptr<CRConnectivity> multiply(const CRConnectivity& b,
78  const bool implicitDiagonal) const;
79 
80  shared_ptr<CRConnectivity>
81  createOffset(const StorageSite& newRowSite,
82  const int offset, const int size) const;
83 
84  shared_ptr<CRConnectivity>
85  getSubset(const StorageSite& site,const Array<int>& indices) const;
86 
87  void reorder( const Array<int>& indices );
88 
89  shared_ptr<CRConnectivity>
90  getLocalizedSubset(const StorageSite& newRowSite,
91  StorageSite& newColSite,
92  const Array<int>& indices) const;
93 
94  shared_ptr<CRConnectivity>
95  getLocalizedSubsetOfFaceCells(const StorageSite& newRowSite, StorageSite& newColSite,
96  const Array<int>& indices, const CRConnectivity& faceCells,
97  const CRConnectivity& cellCells) const;
98  //this is more robust method
99  shared_ptr<CRConnectivity>
100  getLocalizedSubsetOfFaceCells(const StorageSite& newRowSite, StorageSite& newColSite,
101  const Array<int>& indices, const CRConnectivity& cellParts, const int partID) const;
102 
103 
104  void
105  localize(const Array<int>& globalToLocal,const StorageSite& newColSite);
106 
108 
114  void initCount();
115 
116  void addCount(const int index, const int count)
117  {
118  (*_row)[index] += count;
119  }
120 
121  void finishCount();
122 
123  int add(const int index, const int val)
124  {
125  int pos = (*_row)[index];
126  (*_col)[pos] = val;
127  (*_row)[index]++;
128  return pos;
129  }
130 
131  void finishAdd();
132 
134 
135  int operator()(const int i, const int j) const
136  {
137  return (*_col)[(*_row)[i]+j];
138  }
139 
145  int& operator()(const int i, const int j)
146  {
147  return (*_col)[(*_row)[i]+j];
148  }
149 
150  int getCoeffPosition(const int i, const int j) const
151  {
152  for (int nnb = (*_row)[i]; nnb<(*_row)[i+1]; nnb++)
153  {
154  if ((*_col)[nnb] == j)
155  return nnb;
156  }
157  throw CException("invalid indices");
158  }
159 
165  int getCount(const int i) const
166  {
167  return ((*_row)[i+1] - (*_row)[i]);
168  }
169 
171 
177  void resizeLocalToGlobalMap( int size )
178  {
179  _localToGlobalMap = shared_ptr< Array<int> > ( new Array<int>(size) );
180  }
181 
182  const Array<int>& getRow() const {return *_row;}
183  const Array<int>& getCol() const {return *_col;}
184  Array<int>& getCol() {return *_col;}
185 
187 
188 
191 
192  const map<int,int>& getGlobalToLocalMapper() const {return _globalToLocalMapper;}
194 
195  shared_ptr<Array<int> > getGlobalToLocalMapPtr() {return _globalToLocalMap;}
196  shared_ptr<Array<int> > getLocalToGlobalMapPtr() {return _localToGlobalMap;}
197 
198  const PairToColMapping&
199  getPairToColMapping(const CRConnectivity& pairs) const;
200 
201  void
202  clearPairToColMapping(const CRConnectivity& pairs) const;
203 
204  void setConnType( CRTYPE type ){
205  _connType = type;
206  }
207 
208  const CRTYPE& getConnType() const {
209  return _connType;
210  }
211 
212 
213 private:
215  mutable StorageSite const *_rowSite;
216  mutable StorageSite const *_colSite;
217  mutable int _rowDim;
218  mutable int _colDim;
219  shared_ptr<Array<int> > _row;
220  shared_ptr<Array<int> > _col;
221  shared_ptr<Array<int> > _globalToLocalMap;
222  map<int,int> _globalToLocalMapper;
223  shared_ptr<Array<int> > _localToGlobalMap;
224  mutable map<const CRConnectivity*, PairToColMapping*> _pairToColMappings;
226 };
227 
228 #endif
shared_ptr< CRConnectivity > getMultiTranspose(const int varSize) const
const Array< int > & getCol() const
int getCount(const int i) const
void setConnType(CRTYPE type)
const Array< int > & getRow() const
shared_ptr< CRConnectivity > getSubset(const StorageSite &site, const Array< int > &indices) const
const Array< int > & getGlobalToLocalMap() const
StorageSite const * _colSite
void resizeLocalToGlobalMap(int size)
void reorder(const Array< int > &indices)
shared_ptr< Array< int > > _globalToLocalMap
shared_ptr< Array< int > > _row
const map< int, int > & getGlobalToLocalMapper() const
StorageSite const * _rowSite
map< int, int > & getGlobalToLocalMapper()
int getCoeffPosition(const int i, const int j) const
const Array< int > & getLocalToGlobalMap() const
void clearPairToColMapping(const CRConnectivity &pairs) const
shared_ptr< CRConnectivity > getLocalizedSubset(const StorageSite &newRowSite, StorageSite &newColSite, const Array< int > &indices) const
Array< int > & getCol()
map< const CRConnectivity *, PairToColMapping * > _pairToColMappings
CRConnectivity(const StorageSite &rowSite, const StorageSite &colSite)
void localize(const Array< int > &globalToLocal, const StorageSite &newColSite)
shared_ptr< Array< int > > _col
const StorageSite & getColSite() const
DEFINE_TYPENAME("CRConnectivity")
Definition: Array.h:14
shared_ptr< CRConnectivity > getLocalizedSubsetOfFaceCells(const StorageSite &newRowSite, StorageSite &newColSite, const Array< int > &indices, const CRConnectivity &faceCells, const CRConnectivity &cellCells) const
const CRTYPE & getConnType() const
shared_ptr< CRConnectivity > multiply(const CRConnectivity &b, const bool implicitDiagonal) const
shared_ptr< Array< int > > _localToGlobalMap
int & operator()(const int i, const int j)
shared_ptr< CRConnectivity > getTranspose() const
int add(const int index, const int val)
shared_ptr< CRConnectivity > createOffset(const StorageSite &newRowSite, const int offset, const int size) const
int operator()(const int i, const int j) const
shared_ptr< Array< int > > getLocalToGlobalMapPtr()
map< int, int > _globalToLocalMapper
shared_ptr< Array< int > > getGlobalToLocalMapPtr()
const StorageSite & getRowSite() const
int getRowDim() const
void addCount(const int index, const int count)
int getColDim() const
const PairToColMapping & getPairToColMapping(const CRConnectivity &pairs) const
Array< Vector< int, 2 > > PairToColMapping