Chombo + EB + MF  3.2
MBVectorStencilIterator.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 _MBVECTORSTENCILITERATOR_H_
12 #define _MBVECTORSTENCILITERATOR_H_
13 
14 #include <cstdlib>
15 
16 #include "MBVectorStencil.H"
17 
18 #include "NamespaceHeader.H"
19 
20 ///iterates through the MBVectorStencilElements of a MBVectorStencil.
21 /**
22  MBVectorStencilIterator iterates through the MBVectorStencilElements of a MBVectorStencil.
23 
24  MBVectorStencil stencil;
25  ...
26  MBVectorStencilIterator sit(stencil);
27  for (sit.begin(); sit.ok(); ++sit)
28  {
29  const MBVectorStencilElement& stencilElement = sit();
30  (do operations involving stencilElement)
31  }
32 */
34 {
35 public:
36  ///
37  /**
38  Default constructor. This constructs an invalid iterator.
39  The user must call define before using.
40  */
42 
43  ///
44  /**
45  Constructs a MBVectorStencilIterator and associates it with a Box.
46  Arguments:
47  a_bx (not modified) the Box to iterate over.
48  */
49  MBVectorStencilIterator(const MBVectorStencil& a_stencil);
50 
51  void setStencil(const MBVectorStencil& a_stencil);
52 
53  ///
54  /**
55  Associates a MBVectorStencil with this MBVectorStencilIterator.
56  Arguments:
57  a_stencil (not modified) the MBVectorStencil to iterate over.
58  */
59  void define(const MBVectorStencil& a_stencil);
60 
61  ///
62  /**
63  Copy constructor.
64  Arguments:
65  a_iterIn (not modified) the MBVectorStencilIterator to copy.
66  */
68 
69  ///
71  {
72  }
73 
74  ///
75  /**
76  Sets this MBVectorStencilIterator to first MBVectorStencilElement in its MBVectorStencil.
77  */
78  void begin();
79 
80  ///
81  /**
82  Sets this MBVectorStencilIterator to first MBVectorStencilElement in its MBVectorStencil.
83  */
84  void reset();
85 
86  ///
87  /**
88  Modifies this MBVectorStencilIterator to set it to
89  the next MBVectorStencilElement in its MBVectorStencil.
90  */
91  void operator ++ ();
92 
93  void next();
94 
95  ///
96  /**
97  Returns the value of the MBVectorStencilElement for
98  the current location of this MBVectorStencilIterator.
99  */
100  const MBVectorStencilElement& operator () () const;
101 
102  ///
103  /**
104  Returns true if this MBVectorStencilIterator's location is within its MBVectorStencil.
105  */
106  bool ok();
107 
108 protected:
109 
112  int m_indLo;
113  int m_indHi;
114 };
115 
116 inline
118 {
119  m_indCurrent = -1;
120  m_indLo = 0;
121  m_indHi = -1;
122 }
123 
124 inline
126 {
127  define(a_stencil);
128 }
129 
130 inline
132 {
133  m_stencil = a_iterIn.m_stencil;
134  m_indCurrent = a_iterIn.m_indCurrent;
135  m_indLo = a_iterIn.m_indLo;
136  m_indHi = a_iterIn.m_indHi;
137 }
138 
139 inline
141 {
143 }
144 
145 inline
147 {
148  begin();
149 }
150 
151 inline
153 {
154  next();
155 }
156 
157 inline
159 {
160  m_indCurrent++;
161 }
162 
163 inline
165 {
168  return m_stencil[m_indCurrent];
169 }
170 
171 inline
173 {
174  return (m_indCurrent <= m_indHi);
175 }
176 
177 #include "NamespaceFooter.H"
178 #endif
int m_indLo
Definition: MBVectorStencilIterator.H:112
#define CH_assert(cond)
Definition: CHArray.H:37
Class to describe a single element of a multi-block interpolation stencil.
Definition: MBVectorStencilElement.H:21
Class to describe a multi-block interpolation stencil.
Definition: MBVectorStencil.H:21
MBVectorStencilIterator()
Definition: MBVectorStencilIterator.H:117
bool ok()
Definition: MBVectorStencilIterator.H:172
MBVectorStencil m_stencil
Definition: MBVectorStencilIterator.H:110
void define(const MBVectorStencil &a_stencil)
void next()
Definition: MBVectorStencilIterator.H:158
int m_indHi
Definition: MBVectorStencilIterator.H:113
int m_indCurrent
Definition: MBVectorStencilIterator.H:111
~MBVectorStencilIterator()
Definition: MBVectorStencilIterator.H:70
void reset()
Definition: MBVectorStencilIterator.H:146
const MBVectorStencilElement & operator()() const
Definition: MBVectorStencilIterator.H:164
iterates through the MBVectorStencilElements of a MBVectorStencil.
Definition: MBVectorStencilIterator.H:33
void begin()
Definition: MBVectorStencilIterator.H:140
void operator++()
Definition: MBVectorStencilIterator.H:152
void setStencil(const MBVectorStencil &a_stencil)