Chombo + EB + MF  3.2
MBStencilIterator.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 _MBSTENCILITERATOR_H_
12 #define _MBSTENCILITERATOR_H_
13 
14 #include <cstdlib>
15 
16 #include "MBStencil.H"
17 
18 #include "NamespaceHeader.H"
19 
20 ///iterates through the MBStencilElements of a MBStencil.
21 /**
22  MBStencilIterator iterates through the MBStencilElements of a MBStencil.
23 
24  MBStencil stencil;
25  ...
26  MBStencilIterator sit(stencil);
27  for (sit.begin(); sit.ok(); ++sit)
28  {
29  const MBStencilElement& 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 MBStencilIterator and associates it with a Box.
46  Arguments:
47  a_bx (not modified) the Box to iterate over.
48  */
49  MBStencilIterator(const MBStencil& a_stencil);
50 
51  void setStencil(const MBStencil& a_stencil);
52 
53  ///
54  /**
55  Associates a MBStencil with this MBStencilIterator.
56  Arguments:
57  a_stencil (not modified) the MBStencil to iterate over.
58  */
59  void define(const MBStencil& a_stencil);
60 
61  ///
62  /**
63  Copy constructor.
64  Arguments:
65  a_iterIn (not modified) the MBStencilIterator to copy.
66  */
67  MBStencilIterator(const MBStencilIterator& a_iterIn);
68 
69  ///
71  {
72  }
73 
74  ///
75  /**
76  Sets this MBStencilIterator to first MBStencilElement in its MBStencil.
77  */
78  void begin();
79 
80  ///
81  /**
82  Sets this MBStencilIterator to first MBStencilElement in its MBStencil.
83  */
84  void reset();
85 
86  ///
87  /**
88  Modifies this MBStencilIterator to set it to
89  the next MBStencilElement in its MBStencil.
90  */
91  void operator ++ ();
92 
93  void next();
94 
95  ///
96  /**
97  Returns the value of the MBStencilElement for
98  the current location of this MBStencilIterator.
99  */
100  const MBStencilElement& operator () () const;
101 
102  ///
103  /**
104  Returns true if this MBStencilIterator's location is within its MBStencil.
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
MBStencil m_stencil
Definition: MBStencilIterator.H:110
int m_indHi
Definition: MBStencilIterator.H:113
Class to describe a single element of a multi-block interpolation stencil.
Definition: MBStencilElement.H:20
#define CH_assert(cond)
Definition: CHArray.H:37
~MBStencilIterator()
Definition: MBStencilIterator.H:70
iterates through the MBStencilElements of a MBStencil.
Definition: MBStencilIterator.H:33
void operator++()
Definition: MBStencilIterator.H:152
bool ok()
Definition: MBStencilIterator.H:172
const MBStencilElement & operator()() const
Definition: MBStencilIterator.H:164
int m_indCurrent
Definition: MBStencilIterator.H:111
void begin()
Definition: MBStencilIterator.H:140
int m_indLo
Definition: MBStencilIterator.H:112
void reset()
Definition: MBStencilIterator.H:146
void define(const MBStencil &a_stencil)
Class to describe a multi-block interpolation stencil.
Definition: MBStencil.H:21
void next()
Definition: MBStencilIterator.H:158
void setStencil(const MBStencil &a_stencil)
MBStencilIterator()
Definition: MBStencilIterator.H:117