Chombo + EB  3.0
NeighborIterator.H
Go to the documentation of this file.
1 #ifdef CH_LANG_CC
2 /*
3  * _______ __
4  * / ___/ / ___ __ _ / / ___
5  * / /__/ _ \/ _ \/ V \/ _ \/ _ \
6  * \___/_//_/\___/_/_/_/_.__/\___/
7  * Please refer to Copyright.txt, in Chombo's root directory.
8  */
9 #endif
10 
11 #ifndef _NEIGHBORITERATOR_H_
12 #define _NEIGHBORITERATOR_H_
13 
14 #include "DataIndex.H"
15 #include "ProblemDomain.H"
16 #include "DisjointBoxLayout.H"
17 #include "NamespaceHeader.H"
18 
19 ///An Iterator based on a DisjointBoxLayout object for neighboring boxes.
20 /**
21 
22 */
24 {
25 public:
26 
28  {
29  }
30 
31  ///
33 
34  /// return the index that this iterator is at
35  /** Aborts if the iterator is not ok() */
36  inline const LayoutIndex& operator()() const ;
37 
38  Box box() const ;
39 
40  /// move the iterator to the next index in the neighbor list
41  inline void operator++();
42 
43 
44  /// return true if this iterator is still in the neighbor list
45  inline bool ok() const;
46 
47  /// initialize this iterator to the first index in the neighbor list
48  void begin(const DataIndex& a_dataIndex);
49 
50  /// OK, this one requires a little explanation
51  /**
52  if the *current* box is a periodic image box, then this operation returns the unmapping
53  of a_box.
54  */
55  Box unshift(const Box& a_box) const ;
56 
57 private:
58 
60  std::vector<std::pair<int, LayoutIndex> >::const_iterator m_current, m_end;
62 };
63 
64 
65 inline bool NeighborIterator::ok() const
66 {
67  CH_assert(m_dblPtr!=NULL);
68  return m_current != m_end;
69 }
70 
72 {
73  ++m_current;
74  if (m_current != m_end)
75  m_lindex = m_current->second;
76 }
77 
78 
80 {
81  CH_assert(m_dblPtr!= NULL);
82  CH_assert(this->ok());
83  return m_lindex;
84 }
85 
86 #include "NamespaceFooter.H"
87 #endif
#define CH_assert(cond)
Definition: CHArray.H:37
std::vector< std::pair< int, LayoutIndex > >::const_iterator m_current
Definition: NeighborIterator.H:60
Box box() const
const DisjointBoxLayout * m_dblPtr
Definition: NeighborIterator.H:59
const LayoutIndex & operator()() const
return the index that this iterator is at
Definition: NeighborIterator.H:79
Box unshift(const Box &a_box) const
OK, this one requires a little explanation.
LayoutIndex m_lindex
Definition: NeighborIterator.H:61
A BoxLayout that has a concept of disjointedness.
Definition: DisjointBoxLayout.H:31
NeighborIterator()
Definition: NeighborIterator.H:27
bool ok() const
return true if this iterator is still in the neighbor list
Definition: NeighborIterator.H:65
A Rectangular Domain on an Integer Lattice.
Definition: Box.H:465
Definition: DataIndex.H:112
void begin(const DataIndex &a_dataIndex)
initialize this iterator to the first index in the neighbor list
An index for LayoutIterator.
Definition: DataIndex.H:30
std::vector< std::pair< int, LayoutIndex > >::const_iterator m_end
Definition: NeighborIterator.H:60
An Iterator based on a DisjointBoxLayout object for neighboring boxes.
Definition: NeighborIterator.H:23
void operator++()
move the iterator to the next index in the neighbor list
Definition: NeighborIterator.H:71