Chombo + EB + MF  3.2
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  /// return true if this iterator is still in the neighbor list
44  inline bool ok() const;
45 
46  /// initialize this iterator to the first index in the neighbor list
47  void begin(const DataIndex& a_dataIndex);
48 
49  /// OK, this one requires a little explanation
50  /**
51  if the *current* box is a periodic image box, then this operation returns the unmapping
52  of a_box.
53  */
54  Box unshift(const Box& a_box) const ;
55 
56 private:
57 
59  std::vector<std::pair<int, LayoutIndex> >::const_iterator m_current, m_end;
61 };
62 
63 inline bool NeighborIterator::ok() const
64 {
65  CH_assert(m_dblPtr!=NULL);
66  return m_current != m_end;
67 }
68 
70 {
71  ++m_current;
72  if (m_current != m_end)
73  m_lindex = m_current->second;
74 }
75 
77 {
78  CH_assert(m_dblPtr!= NULL);
79  CH_assert(this->ok());
80  return m_lindex;
81 }
82 
83 #include "NamespaceFooter.H"
84 #endif
#define CH_assert(cond)
Definition: CHArray.H:37
std::vector< std::pair< int, LayoutIndex > >::const_iterator m_current
Definition: NeighborIterator.H:59
Box box() const
const DisjointBoxLayout * m_dblPtr
Definition: NeighborIterator.H:58
const LayoutIndex & operator()() const
return the index that this iterator is at
Definition: NeighborIterator.H:76
Box unshift(const Box &a_box) const
OK, this one requires a little explanation.
LayoutIndex m_lindex
Definition: NeighborIterator.H:60
A BoxLayout that has a concept of disjointedness.
Definition: DisjointBoxLayout.H:30
NeighborIterator()
Definition: NeighborIterator.H:27
bool ok() const
return true if this iterator is still in the neighbor list
Definition: NeighborIterator.H:63
A Rectangular Domain on an Integer Lattice.
Definition: Box.H:469
Definition: DataIndex.H:114
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:59
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:69