Chi-Tech
chi_meshcontinuum_localcellhandler.h
Go to the documentation of this file.
1#ifndef CHI_MESHCONTINUUM_LOCALCELLHANDLER_H_
2#define CHI_MESHCONTINUUM_LOCALCELLHANDLER_H_
3
4#include "mesh/Cell/cell.h"
5
6namespace chi_mesh
7{
8
9//##################################################
10/**Stores references to global cells to enable an iterator.*/
12{
13 friend class MeshContinuum;
14public:
15 std::vector<std::unique_ptr<chi_mesh::Cell>>& native_cells;
16
17private:
18 /**Constructor.*/
19 explicit
20 LocalCellHandler(std::vector<std::unique_ptr<chi_mesh::Cell>>& in_native_cells) :
21 native_cells(in_native_cells)
22 {}
23
24public:
25 chi_mesh::Cell& operator[](uint64_t cell_local_index);
26 const chi_mesh::Cell& operator[](uint64_t cell_local_index) const;
27
28
29 //##################################### iterator Class Definition
30 /**Internal iterator class.*/
32 {
33 public:
36
37 iterator(LocalCellHandler& in_block, size_t i) :
38 ref_block(in_block),
39 ref_element(i) {}
40
41 iterator operator++() { iterator i = *this; ref_element++; return i; }
42 iterator operator++(int) { ref_element++; return *this; }
43
45 bool operator==(const iterator& rhs) const { return ref_element == rhs.ref_element; }
46 bool operator!=(const iterator& rhs) const { return ref_element != rhs.ref_element; }
47 };
48
49 /**Internal const iterator class.*/
51 {
52 public:
55
56 const_iterator(const LocalCellHandler& in_block, size_t i) :
57 ref_block(in_block),
58 ref_element(i) {}
59
61 const_iterator operator++(int) { ref_element++; return *this; }
62
64 bool operator==(const const_iterator& rhs) const { return ref_element == rhs.ref_element; }
65 bool operator!=(const const_iterator& rhs) const { return ref_element != rhs.ref_element; }
66 };
67
68 iterator begin() {return {*this,0};}
69
70 iterator end(){return {*this, native_cells.size()};}
71
72 const_iterator begin() const {return {*this,0};}
73
74 const_iterator end() const {return {*this, native_cells.size()};}
75
76 size_t size() const {return native_cells.size();}
77};
78
79}//namespace chi_mesh
80
81#endif //CHI_MESHCONTINUUM_LOCALCELLHANDLER_H_
const_iterator(const LocalCellHandler &in_block, size_t i)
iterator(LocalCellHandler &in_block, size_t i)
chi_mesh::Cell & operator[](uint64_t cell_local_index)
LocalCellHandler(std::vector< std::unique_ptr< chi_mesh::Cell > > &in_native_cells)
std::vector< std::unique_ptr< chi_mesh::Cell > > & native_cells