Flow123d  jenkins-Flow123d-windows32-release-multijob-51
local_to_global_map.cc
Go to the documentation of this file.
1 /*
2  * local_to_global.map.cc
3  *
4  * Created on: Mar 9, 2012
5  * Author: jb
6  */
7 
9 #include <la/distribution.hh>
10 
11 #include "system/system.hh"
12 
13 
15 : nonlocal_indices_(new std::set<unsigned int>()),
16  distr_(boost::make_shared<Distribution>(any_distr)),
17  global_indices_(0)
18 {}
19 
20 LocalToGlobalMap::LocalToGlobalMap(boost::shared_ptr<Distribution> any_distr)
21 : nonlocal_indices_(new std::set<unsigned int>()),
22  distr_(any_distr),
23  global_indices_(0)
24 {}
25 
26 void LocalToGlobalMap::insert(const unsigned int global_idx) {
27  ASSERT( global_indices_.size() == 0, "Insertion into the map after finalize.");
28  if (! distr_->is_local( global_idx ) ) nonlocal_indices_->insert( global_idx );
29 }
30 
32  ASSERT( global_indices_.size() == 0, "Insertion into the map after finalize.");
33  for(std::vector<unsigned int>::const_iterator it=indices.begin(); it != indices.end(); ++it)
34  if (! distr_->is_local( *it ) ) nonlocal_indices_->insert( *it );
35 }
36 
38  global_indices_.resize( distr_->lsize() + nonlocal_indices_->size() );
39  unsigned int i;
40 
41  for(i=0; i< distr_->lsize(); i++) global_indices_[i]=distr_->begin()+i;
42  for(std::set<unsigned int>::iterator it = nonlocal_indices_->begin();
43  it != nonlocal_indices_->end(); ++it)
44  global_indices_[i++]=*it;
45  delete nonlocal_indices_;
46 }
47 
48 
49 
boost::shared_ptr< Distribution > distr_
distribution of the global indices
std::vector< unsigned int > global_indices_
mapping for all local indices
void insert(const unsigned int idx)
LocalToGlobalMap(const Distribution &distr)
#define ASSERT(...)
Definition: global_defs.h:121
Support classes for parallel programing.
std::set< unsigned int > * nonlocal_indices_
auxiliary set of non-local part of the map