Debian Codegraph @

src/atlas/functionspace/HaloDescription.h

raw
1 #pragma once
2
3 #include <algorithm>
4
5 #include "atlas/library/config.h"
6
7 namespace atlas::functionspace {
8
9 class HaloDescription {
10 public:
11 HaloDescription() = default;
12 HaloDescription(idx_t size) :
13 halo_size_(size) {
14 }
15 HaloDescription(idx_t begin, idx_t end) :
16 halo_begin_(begin),
17 halo_end_(end),
18 halo_size_(halo_end_ - halo_begin_) {
19 }
20 template<typename View>
21 HaloDescription(const View& ghost) {
22 for (idx_t i=0; i<ghost.size(); ++i) {
23 if (ghost[i]) {
24 halo_size_ += 1;
25 if (halo_begin_ == -1) {
26 halo_begin_ = i;
27 }
28 halo_end_ = std::max(halo_end_, i+1);
29 }
30 }
31 }
32
33 bool contiguous() const { return halo_end_ - halo_begin_ == halo_size_; }
34 idx_t size() const { return halo_size_; }
35 idx_t begin() const { return halo_begin_; }
36 idx_t end() const { return halo_end_; }
37 private:
38 idx_t halo_begin_{-1};
39 idx_t halo_end_{-1};
40 idx_t halo_size_{0};
41 };
42
43 } // namespace atlas::functionspace
44