forked from fmihpc/dccrg
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathdccrg_iterator_support.hpp
90 lines (67 loc) · 2.13 KB
/
dccrg_iterator_support.hpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
/*
Supporting routines for dccrg iterators.
Copyright 2013, 2014, 2015, 2016 Finnish Meteorological Institute
Dccrg is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License version 3
as published by the Free Software Foundation.
Dccrg is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with dccrg. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef DCCRG_ITERATOR_SUPPORT_HPP
#define DCCRG_ITERATOR_SUPPORT_HPP
namespace dccrg {
template <class Cell_Data, class Geometry> class Dccrg;
/*!
\brief Returns true if given cell is not on the process boundary, false otherwise.
*/
template<class Cell_Data, class Geometry> class Is_Inner_Cell
{
friend class Dccrg<Cell_Data, Geometry>;
public:
//! Does all the work
bool operator()(const typename Dccrg<Cell_Data, Geometry>::cell_and_data_pair_t& item)
{
if (this->grid.get_local_cells_on_process_boundary_internal().count(item.first)) {
return false;
} else {
return true;
}
}
protected:
/*!
Given grid is used to query whether a cell is local or not.
*/
Is_Inner_Cell(const Dccrg<Cell_Data, Geometry>& given_grid) : grid(given_grid) {}
private:
const Dccrg<Cell_Data, Geometry>& grid;
};
/*!
\brief Returns true if given cell is on the process boundary, false otherwise.
*/
template<class Cell_Data, class Geometry> class Is_Outer_Cell
{
friend class Dccrg<Cell_Data, Geometry>;
public:
//! Does all the work
bool operator()(const typename Dccrg<Cell_Data, Geometry>::cell_and_data_pair_t& item)
{
if (this->grid.get_local_cells_on_process_boundary_internal().count(item.first)) {
return true;
} else {
return false;
}
}
protected:
/*!
Given grid is used to query whether a cell is local or not.
*/
Is_Outer_Cell(const Dccrg<Cell_Data, Geometry>& given_grid) : grid(given_grid) {}
private:
const Dccrg<Cell_Data, Geometry>& grid;
};
} // namespace
#endif