Flow123d
Main Page
Related Pages
Modules
Namespaces
Classes
Files
File List
File Members
flow123d
src
la
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
8
#include <
la/local_to_global_map.hh
>
9
#include <
la/distribution.hh
>
10
11
#include "
system/system.hh
"
12
13
14
LocalToGlobalMap::LocalToGlobalMap
(
const
Distribution
&any_distr)
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
31
void
LocalToGlobalMap::insert
(
const
std::vector<unsigned int>
&indices) {
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
37
void
LocalToGlobalMap::finalize
() {
38
global_indices_
.resize(
distr_
->lsize() +
nonlocal_indices_
->size() );
39
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
Generated on Thu May 29 2014 23:14:48 for Flow123d by
1.8.4