Chombo + EB  3.2
MiniIFFAB.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 // DTG, ANAG, LBNL, 2009
12 
13 #ifndef _MINIIFFAB_H_
14 #define _MINIIFFAB_H_
15 
16 #include <cmath>
17 #include <cstdlib>
18 #include "SPACE.H"
19 #include "Vector.H"
20 #include "IntVectSet.H"
21 #include "FaceIndex.H"
22 #include "BaseFab.H"
23 #include "EBGraph.H"
24 #include "Arena.H"
25 #include "NamespaceHeader.H"
26 
27 
28 ///
29 /**
30  MiniIFFAB is a templated data holder
31  defined over the Faces of an irregular domain.
32 */
33 template <class T>
34 class MiniIFFAB
35 {
36 public:
37  ///
38  /**
39  Default constructor. Constructs an uninitialized IFFAB. You must
40  subsequently call {\bf define} before using this IFFAB.
41  */
42  MiniIFFAB();
43 
44  ///
45  /**
46  Defining constructor. Specifies the irregular domain
47  and the number of data components per face. The irregular domain
48  must lie completely within the EBGraph. The
49  contents are uninitialized. Calls full define function.
50  */
51  MiniIFFAB(const Box& a_box,
52  const EBGraph& a_ebgraph,
53  const int& a_direction,
54  const int& a_nvarin);
55 
56  ///
57  /**
58  Constructor to define miniIFFAB over all faces in an intvectset.
59  Calls full define function.
60  */
61  MiniIFFAB(const IntVectSet& a_ivs,
62  const EBGraph& a_ebgraph,
63  const int& a_direction,
64  const int& a_nvarin);
65 
66  ///
67  /**
68  Define function for all faces in an intvectset..
69  */
70 
71  void define(const IntVectSet& a_ivs,
72  const EBGraph& a_ebgraph,
73  const int& a_direction,
74  const int& a_nvarin);
75 
76  ///
77  /**
78 
79  This aliased MiniIFFAB will have a_comps.size() components, starting at zero.
80  */
81  MiniIFFAB(const Interval& a_comps,
82  MiniIFFAB<T>& a_original);
83  ///
84  ~MiniIFFAB();
85 
86  ///
87  /**
88  Full define function. Specifies the irregular domain and the
89  number of data components per face. The irregular domain
90  must lie completely within the EBGraph. The contents
91  are uninitialized. If it has previously been defined, the old definition
92  data is overwritten and lost.
93  */
94  void define(const Box& a_box,
95  const EBGraph& a_ebgraph,
96  const int& a_direction,
97  const int& a_nvarin);
98 
99  ///for AggStencil
100  long offset(const FaceIndex& a_vof, const int& a_ivar) const
101  {
102  const T* conval = &((*this)(a_vof, a_ivar));
103  long roffset = (long)(conval-dataPtr(0));
104  return roffset;
105  }
106 
107  ///
108  /**
109  Set a value at every data location.
110  */
111  void setVal(const T& value);
112 
113  ///
114  /**
115  Set a value at every data location.
116  */
117  void setVal(int ivar, const T& value);
118 
119  ///
120  /**
121  define over surrounding nodes of invectset (ivs is cell-centered).
122  */
123  void copy(const Box& a_intBox,
124  const Interval& a_destInterval,
125  const Box& a_toBox,
126  const MiniIFFAB<T>& a_src,
127  const Interval& a_srcInterval);
128 
129  ///
130  /**
131  Remove all data from this MiniIFFAB.
132  You must call {\bf define} again in order
133  to use it.
134  */
135  void clear();
136 
137  ///invalid but necessary for leveldata to compile
138  MiniIFFAB(const Box& a_region, int a_nVar)
139  {
140  MayDay::Error("invalid constructor called for baseebcellfab");
141  }
142 
143  ///
144  /**
145 
146  Tells whether this MiniIFFAB has been defined, either with a constructor
147  or with {\bf define}. It must be initialized in order to access its data.
148  */
149  bool
150  isDefined() const
151  {
152  return (m_isDefined);
153  }
154 
155 
156  ///
157  /**
158  Return the number of data components of this MiniIFFAB.
159  */
160  int nComp() const
161  {
162  return m_nComp;
163  }
164 
165  ///
166  /**
167  Indexing operator. Return a reference to the contents of this IFFAB,
168  at the specified face and data component. The first component is
169  zero, the last is {\em nvar-1}. The returned object is a modifiable
170  lvalue.
171  */
172  T& operator() (const FaceIndex& a_face,const int& varlocin);
173  const T& operator()(const FaceIndex& a_face,const int& varlocin) const;
174 
175 
176  ///
177  T* dataPtr(const int& a_comp);
178 
179  T* getIndex(const FaceIndex& a_face, const int& a_comp) const;
180  ///
181  const T* dataPtr(const int& a_comp) const;
182 
183  static int preAllocatable()
184  {
185  return 1; // symmetric preallocatable
186  }
187 
188  ///
189  int size(const Box& R, const Interval& comps) const ;
190 
191  ///
192  void linearOut(void* buf, const Box& R, const Interval& comps) const;
193 
194  ///
195  void linearIn(void* buf, const Box& R, const Interval& comps);
196 
197  ///
198  int numFaces() const
199  {
200  return m_nFaces;
201  }
202 
203  ///
205  {
206  return m_faces;
207  }
208 
209  static bool s_verbose;
210 
213 
214 private:
215  void setDefaultValues();
216 
217  void getFaceSubset(Vector<FaceIndex>& a_subFaces, const Box& a_subBox) const;
218 protected:
219 
220  T* m_data;
222  int m_nFaces;
223  int m_nComp;
225  bool m_aliased = false;
227 private:
228  //we disallow copy construction and assigment for data holders
230  {
231  MayDay::Error("invalid operator");
232  }
234  {
235  MayDay::Error("invalid operator");
236  }
237 };
238 
239 #include "NamespaceFooter.H"
240 
241 #ifndef CH_EXPLICIT_TEMPLATES
242 #include "MiniIFFABI.H"
243 #endif
244 
245 #endif
int numFaces() const
Definition: MiniIFFAB.H:198
bool isDefined() const
Definition: MiniIFFAB.H:150
int m_nComp
Definition: MiniIFFAB.H:223
int size(const Box &R, const Interval &comps) const
Definition: MiniIFFABI.H:305
int m_nFaces
Definition: MiniIFFAB.H:222
An irregular domain on an integer lattice.
Definition: IntVectSet.H:44
~MiniIFFAB()
Definition: MiniIFFABI.H:29
int nComp() const
Definition: MiniIFFAB.H:160
static int preAllocatable()
Definition: MiniIFFAB.H:183
void linearOut(void *buf, const Box &R, const Interval &comps) const
Definition: MiniIFFABI.H:346
void setVal(const T &value)
Definition: MiniIFFABI.H:108
Definition: FaceIndex.H:28
bool m_aliased
Definition: MiniIFFAB.H:225
EBGraph m_ebgraph
Definition: MiniIFFAB.H:212
void clear()
Definition: MiniIFFABI.H:222
MiniIFFAB()
Definition: MiniIFFABI.H:23
Geometric description within a box.
Definition: EBGraph.H:427
const Vector< FaceIndex > & getFaces() const
Definition: MiniIFFAB.H:204
void setDefaultValues()
Definition: MiniIFFABI.H:277
void linearIn(void *buf, const Box &R, const Interval &comps)
Definition: MiniIFFABI.H:378
long offset(const FaceIndex &a_vof, const int &a_ivar) const
for AggStencil
Definition: MiniIFFAB.H:100
Structure for passing component ranges in code.
Definition: Interval.H:23
static bool s_verbose
Definition: MiniIFFAB.H:209
T * m_data
Definition: MiniIFFAB.H:220
int m_direction
Definition: MiniIFFAB.H:224
void operator=(const MiniIFFAB< T > &)
Definition: MiniIFFAB.H:229
Vector< FaceIndex > m_faces
Definition: MiniIFFAB.H:221
T * dataPtr(const int &a_comp)
Definition: MiniIFFABI.H:259
static void Error(const char *const a_msg=m_nullString, int m_exitCode=CH_DEFAULT_ERROR_CODE)
Print out message to cerr and exit with the specified exit code.
void getFaceSubset(Vector< FaceIndex > &a_subFaces, const Box &a_subBox) const
Definition: MiniIFFABI.H:289
T * getIndex(const FaceIndex &a_face, const int &a_comp) const
Definition: MiniIFFABI.H:179
A Rectangular Domain on an Integer Lattice.
Definition: Box.H:465
void copy(const Box &a_intBox, const Interval &a_destInterval, const Box &a_toBox, const MiniIFFAB< T > &a_src, const Interval &a_srcInterval)
Definition: MiniIFFABI.H:135
T & operator()(const FaceIndex &a_face, const int &varlocin)
Definition: MiniIFFABI.H:235
MiniIFFAB(const MiniIFFAB< T > &)
Definition: MiniIFFAB.H:233
Definition: MiniIFFAB.H:34
MiniIFFAB(const Box &a_region, int a_nVar)
invalid but necessary for leveldata to compile
Definition: MiniIFFAB.H:138
bool m_isDefined
Definition: MiniIFFAB.H:226
Box m_box
Definition: MiniIFFAB.H:211
void define(const IntVectSet &a_ivs, const EBGraph &a_ebgraph, const int &a_direction, const int &a_nvarin)
Definition: MiniIFFABI.H:83