31 #define __GraphCSR_H 1
36 #include <boost/tuple/tuple.hpp>
39 #include <boost/shared_ptr.hpp>
41 #include <feel/feelcore/feel.hpp>
43 #include <feel/feelalg/datamap.hpp>
48 namespace mpi=boost::mpi;
67 typedef boost::shared_ptr<self_type> self_ptrtype;
69 typedef std::vector<size_type> nz_type;
70 typedef boost::shared_ptr<nz_type> nz_ptrtype;
73 typedef boost::tuple<size_type, size_type, std::set<size_type> > row_type;
74 typedef std::map<size_type, row_type > storage_type;
75 typedef boost::shared_ptr<storage_type> storage_ptrtype;
77 typedef storage_type::iterator iterator;
78 typedef storage_type::const_iterator const_iterator;
94 WorldComm
const& worldcomm = Environment::worldComm() );
96 GraphCSR( boost::shared_ptr<DataMap>
const& mapRow,
97 boost::shared_ptr<DataMap>
const& mapCol );
102 GraphCSR( vf::BlocksBase<self_ptrtype>
const & blockSet,
103 bool diagIsNonZero=
true,
133 return M_last_row_entry_on_proc[this->
worldComm().globalRank()]+1;
137 return M_last_col_entry_on_proc[this->
worldComm().globalRank()]+1;
145 return M_first_row_entry_on_proc[this->
worldComm().globalRank()];
153 return M_last_row_entry_on_proc[this->
worldComm().globalRank()];
160 return M_first_col_entry_on_proc[this->
worldComm().globalRank()];
168 return M_last_col_entry_on_proc[this->
worldComm().globalRank()];
176 return M_storage.size();
183 return M_storage.empty();
190 return M_storage.begin();
198 return M_storage.end();
206 return M_storage.begin();
211 const_iterator
end()
const
213 return M_storage.end();
228 return M_storage.find( i )->second;
253 std::vector<size_type>
const&
263 std::vector<size_type>
const&
273 std::vector<size_type>
const&
288 nz_type
const& ia()
const
292 nz_type
const& ja()
const
296 std::vector<double>
const& a()
const
300 std::vector<double>& a()
313 void setFirstRowEntryOnProc(
size_type entry )
315 M_first_row_entry_on_proc[this->
worldComm().globalRank()] = entry;
317 void setFirstColEntryOnProc(
size_type entry )
319 M_first_col_entry_on_proc[this->
worldComm().globalRank()] = entry;
322 void setLastRowEntryOnProc(
size_type entry )
324 M_last_row_entry_on_proc[this->
worldComm().globalRank()] = entry;
326 void setLastColEntryOnProc(
size_type entry )
328 M_last_col_entry_on_proc[this->
worldComm().globalRank()] = entry;
331 DataMap
const& mapRow()
const {
return *M_mapRow; }
332 DataMap
const& mapCol()
const {
return *M_mapCol; }
333 boost::shared_ptr<DataMap>
const& mapRowPtr()
const {
return M_mapRow; }
334 boost::shared_ptr<DataMap>
const& mapColPtr()
const {
return M_mapCol; }
335 boost::shared_ptr<DataMap> mapRowPtr() {
return M_mapRow; }
336 boost::shared_ptr<DataMap> mapColPtr() {
return M_mapCol; }
358 self_ptrtype
transpose(
bool doClose =
true );
368 void showMe( std::ostream& __out = std::cout )
const;
370 void printPython( std::string
const& nameFile )
const;
376 void mergeBlockGraph( self_ptrtype
const& g,
379 void mergeBlockGraphMPI( self_ptrtype
const& g, vf::BlocksBase<self_ptrtype>
const & blockSet,
int i,
int j,
382 void updateDataMap( vf::BlocksBase<self_ptrtype>
const & blockSet );
384 size_type nLocalDofWithoutGhostOnProcStartRow( vf::BlocksBase<self_ptrtype>
const & blockSet,
int proc,
int rowIndex,
int colIndex )
const;
385 size_type nLocalDofWithoutGhostOnProcStartCol( vf::BlocksBase<self_ptrtype>
const & blockSet,
int proc,
int rowIndex,
int colIndex )
const;
386 size_type nLocalDofWithGhostOnProcStartRow( vf::BlocksBase<self_ptrtype>
const & blockSet,
int proc,
int rowIndex,
int colIndex )
const;
387 size_type nLocalDofWithGhostOnProcStartCol( vf::BlocksBase<self_ptrtype>
const & blockSet,
int proc,
int rowIndex,
int colIndex )
const;
394 WorldComm M_worldComm;
396 std::vector<size_type> M_first_row_entry_on_proc;
397 std::vector<size_type> M_last_row_entry_on_proc;
398 std::vector<size_type> M_first_col_entry_on_proc;
399 std::vector<size_type> M_last_col_entry_on_proc;
401 nz_type M_n_total_nz;
404 storage_type M_storage;
406 std::vector<double> M_a;
408 self_ptrtype M_graphT;
410 boost::shared_ptr<DataMap> M_mapRow, M_mapCol;
414 class BlocksBaseGraphCSR :
public vf::BlocksBase<boost::shared_ptr<GraphCSR> >
417 typedef vf::BlocksBase<boost::shared_ptr<GraphCSR> > super_type;
418 typedef BlocksBaseGraphCSR self_type;
419 typedef boost::shared_ptr<GraphCSR> graph_ptrtype;
421 BlocksBaseGraphCSR(uint16_type nr,uint16_type nc)
426 BlocksBaseGraphCSR(super_type
const & b)
432 operator<<( graph_ptrtype
const& g )
const
434 return super_type::operator<<( g );