Chombo + EB  3.0
CFIVS.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 _CFIVS_H_
12 #define _CFIVS_H_
13 
14 #include "REAL.H"
15 #include "DataIndex.H"
16 #include "IntVect.H"
17 #include "Box.H"
18 #include "IntVectSet.H"
19 #include "NamespaceHeader.H"
20 
21 //--Forward declarations
22 
23 class DisjointBoxLayout;
24 class ProblemDomain;
25 class LoHiSide;
26 
27 
28 /// Internal class to find parts of a box outside the valid region of a level
29 /**
30  * Typically used to find the ghost cells between this and a coarser level.
31  * These cells are represented by an IntVectSet and, if possible, packed into
32  * a box. This class should only be used through a CFRegion which breaks down
33  * the parts of a box into regions that have a high probability of being
34  * packed.
35  */
36 
37 class CFIVS
38 {
39 public:
40  /// Null constructor
41  CFIVS();
42 
43  /// Destructor
44  ~CFIVS();
45 
46  /// Explicit define based on an IntVectSet
47  // Using this means the cells to store in the IVS have been identified
48  // elsewhere!
49  void define(const IntVectSet & a_IVS);
50 
51  /// General define for any box using NeighborIterators
52  // WARNING! To use this, neighbors must be defined in the DBL. Otherwise
53  // continue to use the legacy define functions.
54  void define(const DataIndex& a_dataIndex,
55  const DisjointBoxLayout& a_grids,
56  const Box& a_ghostBox);
57 
58  /// Coarsen the stored cells
59  void coarsen(int a_ref);
60 
61  /// Returns packed box for when isPacked() is true.
62  const Box& packedBox() const;
63 
64  /// Returns minbox for when isPacked() is false (but can also be used if true)
65  const Box& minBox() const;
66 
67  /// Get the set of IntVects
68  const IntVectSet& getIVS() const;
69 
70  /// Returns "true" if this CF IntVectSet can be represented as a simple Box.
71  bool isPacked() const;
72 
73  /// Returns "true" if the defined IVS is empty
74  bool isEmpty() const;
75 
76  /// Returns "true" if the object has been defined
77  bool isDefined() const;
78 
79 protected:
80  // For internal use
81  void setDefaultValues();
82 
83  /// Decrement counts (during redefine)
84  void decrementCounts();
85 
86  /// Pack the IVS
87  void packIVS();
88 
89 public:
90  static long long s_packCount, s_sparseCount;
91 
92 protected:
93  IntVectSet m_IVS; ///< IntVects that are outside the level
94  Box m_packedBox; ///< If m_packed is true, the Box with
95  ///< which the coarse-fine IntVectSet can
96  ///< be represented. If m_packed is
97  ///< false, same as m_IVS.minBox().
98  bool m_packed; ///< Can the coarse-fine IntVectSet be
99  ///< represented as a Box? Set to false
100  ///< if the IVS is empty
101  bool m_empty; ///< Is the IVS empty - cached here for
102  ///< fast lookup
103  bool m_defined; ///< Has this object been defined?
104 
105 
106 /*============================================================================*/
107 /** \name Legacy members
108  *
109  * New uses of CFIVS should avoid these routines
110  *//*=========================================================================*/
111 
112 public:
113 //@{
114  /// (Deprecated) constructor
115  /** The ProblemDomain class has replaced the Box domain
116  Replaces Box domain with a ProblemDomain and calls define fn.
117  */
118  CFIVS(const Box& a_domain,
119  const Box& a_boxIn,
120  const DisjointBoxLayout& a_fineBoxes,
121  int a_direction,
122  Side::LoHiSide a_hiorlo);
123 
124  /// (Deprecated) full constructor
125  /** CFRegion should specify the region and call general define for a box
126  Calls corresponding define function.
127  */
128  CFIVS(const ProblemDomain& a_domain,
129  const Box& a_boxIn,
130  const DisjointBoxLayout& a_fineBoxes,
131  int a_direction,
132  Side::LoHiSide a_hiorlo);
133 
134  /// (Deprecated) define function
135  /** CFRegion should specify the region and call general define for a box
136  Replaces Box domain with a ProblemDomain and calls define fn.
137  */
138  void define(const Box& a_domain,
139  const Box& a_boxIn,
140  const DisjointBoxLayout& a_fineBoxes,
141  int a_direction,
142  Side::LoHiSide a_hiorlo);
143 
144  /// (Deprecated) full define function
145  /** CFRegion should specify the region and call general define for a box
146  */
147  void define (const ProblemDomain& a_domain, /// Problem domain at the fine level
148  const Box& a_boxIn, /// fine-level grid box
149  const DisjointBoxLayout& a_fineBoxes, /// fine-level grids
150  int a_direction, /// direction of the face of interest
151  Side::LoHiSide a_hiorlo); /// is the face on the hi or lo side of the box?
152 
153  /// (Deprecated) faster define function. Requires the use of CFStencil::buildPeriodicVector static function.
154  /** CFRegion should specify the region and call general define for a box
155  */
156  void define(const ProblemDomain& a_domain,
157  const Box& a_boxIn,
158  const Vector<Box>& a_periodicfineBoxes,
159  int a_direction,
160  Side::LoHiSide a_hiorlo);
161 
162  /// (Deprecated) Updated define function that uses NeighborIterators instead of traversing the
163  /// entire list of boxes.
164  /** CFRegion should specify the region and call general define for a box.
165  * However, at least this one is using the recommended technology, Neighbor
166  * iterators.
167  */
168  void define(const ProblemDomain& a_domain,
169  const DataIndex& a_dataIndex,
170  const DisjointBoxLayout& a_grids,
171  int a_direction,
172  Side::LoHiSide a_hiorlo);
173 
174  /// Get fine intvects which need to be interpolated.
175  /** Renamed to getIVS() since CFIV has a general purpose now.
176  * This will be empty if isEmpty() returns true
177  */
178  const IntVectSet& getFineIVS() const;
179 //@}
180 };
181 
182 // Returns packed box for when isPacked() is true.
183 inline const Box& CFIVS::packedBox() const
184 {
185  CH_assert(isPacked());
186  return m_packedBox;
187 }
188 
189 // Returns minbox for when isPacked() is false (but can also be used if true)
190 inline const Box& CFIVS::minBox() const
191 {
192  return m_packedBox;
193 }
194 
195 // Get the set of IntVects
196 inline const IntVectSet&
198 {
199  return m_IVS;
200 }
201 
202 // Get fine intvects which need to be interpolated (deprecated).
203 inline const IntVectSet&
205 {
206  return m_IVS;
207 }
208 
209 // Returns "true" if this CF IntVectSet can be represented as a simple Box.
210 /** Returns 'true' if this coarse-fine IntVectSet can be represented
211  as just a Box, ie. a user can perform a dense computation instead of
212  a pointwise calculation using IVSIterator.
213 */
214 inline bool
216 {
218  return m_packed;
219 }
220 
221 // Returns "true" if the defined IVS is empty
222 inline bool
224 {
226  return m_empty;
227 }
228 
229 // Returns "true" if the object has been defined
230 inline bool
232 {
233  return m_defined;
234 }
235 
236 #include "NamespaceFooter.H"
237 #endif
bool isEmpty() const
Returns "true" if the defined IVS is empty.
Definition: CFIVS.H:223
static long long s_sparseCount
Definition: CFIVS.H:90
static long long s_packCount
Definition: CFIVS.H:90
An irregular domain on an integer lattice.
Definition: IntVectSet.H:44
#define CH_assert(cond)
Definition: CHArray.H:37
A class to facilitate interaction with physical boundary conditions.
Definition: ProblemDomain.H:130
Internal class to find parts of a box outside the valid region of a level.
Definition: CFIVS.H:37
bool isDefined() const
Returns "true" if the object has been defined.
Definition: CFIVS.H:231
void coarsen(int a_ref)
Coarsen the stored cells.
void packIVS()
Pack the IVS.
IntVectSet m_IVS
IntVects that are outside the level.
Definition: CFIVS.H:93
bool m_packed
Definition: CFIVS.H:98
void setDefaultValues()
const Box & minBox() const
Returns minbox for when isPacked() is false (but can also be used if true)
Definition: CFIVS.H:190
void define(const IntVectSet &a_IVS)
Explicit define based on an IntVectSet.
const IntVectSet & getIVS() const
Get the set of IntVects.
Definition: CFIVS.H:197
A BoxLayout that has a concept of disjointedness.
Definition: DisjointBoxLayout.H:31
LoHiSide
Definition: LoHiSide.H:27
~CFIVS()
Destructor.
bool m_empty
Definition: CFIVS.H:101
bool isPacked() const
Returns "true" if this CF IntVectSet can be represented as a simple Box.
Definition: CFIVS.H:215
A Rectangular Domain on an Integer Lattice.
Definition: Box.H:465
bool m_defined
Has this object been defined?
Definition: CFIVS.H:103
CFIVS()
Null constructor.
Definition: DataIndex.H:112
const IntVectSet & getFineIVS() const
Get fine intvects which need to be interpolated.
Definition: CFIVS.H:204
Box m_packedBox
Definition: CFIVS.H:94
const Box & packedBox() const
Returns packed box for when isPacked() is true.
Definition: CFIVS.H:183
void decrementCounts()
Decrement counts (during redefine)