Chombo + EB  3.0
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  ~MiniIFFAB();
58 
59  ///
60  /**
61  Full define function. Specifies the irregular domain and the
62  number of data components per face. The irregular domain
63  must lie completely within the EBGraph. The contents
64  are uninitialized. If it has previously been defined, the old definition
65  data is overwritten and lost.
66  */
67  void define(const Box& a_box,
68  const EBGraph& a_ebgraph,
69  const int& a_direction,
70  const int& a_nvarin);
71 
72  ///for AggStencil
73  long offset(const FaceIndex& a_vof, const int& a_ivar) const
74  {
75  const T* conval = &((*this)(a_vof, a_ivar));
76  long roffset = (long)(conval-dataPtr(0));
77  return roffset;
78  }
79 
80  ///
81  /**
82  Set a value at every data location.
83  */
84  void setVal(const T& value);
85 
86  ///
87  /**
88  Set a value at every data location.
89  */
90  void setVal(int ivar, const T& value);
91 
92  ///
93  /**
94  define over surrounding nodes of invectset (ivs is cell-centered).
95  */
96  void copy(const Box& a_intBox,
97  const Interval& a_destInterval,
98  const Box& a_toBox,
99  const MiniIFFAB<T>& a_src,
100  const Interval& a_srcInterval);
101 
102  ///
103  /**
104  Remove all data from this MiniIFFAB.
105  You must call {\bf define} again in order
106  to use it.
107  */
108  void clear();
109 
110  ///invalid but necessary for leveldata to compile
111  MiniIFFAB(const Box& a_region, int a_nVar)
112  {
113  MayDay::Error("invalid constructor called for baseebcellfab");
114  }
115 
116  ///
117  /**
118 
119  Tells whether this MiniIFFAB has been defined, either with a constructor
120  or with {\bf define}. It must be initialized in order to access its data.
121  */
122  bool
123  isDefined() const
124  {
125  return (m_isDefined);
126  }
127 
128 
129  ///
130  /**
131  Return the number of data components of this MiniIFFAB.
132  */
133  int nComp() const
134  {
135  return m_nComp;
136  }
137 
138  ///
139  /**
140  Indexing operator. Return a reference to the contents of this IFFAB,
141  at the specified face and data component. The first component is
142  zero, the last is {\em nvar-1}. The returned object is a modifiable
143  lvalue.
144  */
145  T& operator() (const FaceIndex& a_face,const int& varlocin);
146  const T& operator()(const FaceIndex& a_face,const int& varlocin) const;
147 
148 
149  ///
150  T* dataPtr(const int& a_comp);
151 
152  T* getIndex(const FaceIndex& a_face, const int& a_comp) const;
153  ///
154  const T* dataPtr(const int& a_comp) const;
155 
156  static int preAllocatable()
157  {
158  return 1; // symmetric preallocatable
159  }
160 
161  ///
162  int size(const Box& R, const Interval& comps) const ;
163 
164  ///
165  void linearOut(void* buf, const Box& R, const Interval& comps) const;
166 
167  ///
168  void linearIn(void* buf, const Box& R, const Interval& comps);
169 
170  ///
171  int numFaces() const
172  {
173  return m_nFaces;
174  }
175 
176  ///
178  {
179  return m_faces;
180  }
181 
182  static bool s_verbose;
183 
186 
187 private:
188  void setDefaultValues();
189 
190  void getFaceSubset(Vector<FaceIndex>& a_subFaces, const Box& a_subBox) const;
191 protected:
192 
193  T* m_data;
195  int m_nFaces;
196  int m_nComp;
198 
200 private:
201  //we disallow copy construction and assigment for data holders
203  {
204  MayDay::Error("invalid operator");
205  }
207  {
208  MayDay::Error("invalid operator");
209  }
210 };
211 
212 #include "NamespaceFooter.H"
213 
214 #ifndef CH_EXPLICIT_TEMPLATES
215 #include "MiniIFFABI.H"
216 #endif
217 
218 #endif
long offset(const FaceIndex &a_vof, const int &a_ivar) const
for AggStencil
Definition: MiniIFFAB.H:73
int m_nComp
Definition: MiniIFFAB.H:196
int m_nFaces
Definition: MiniIFFAB.H:195
~MiniIFFAB()
Definition: MiniIFFABI.H:29
bool isDefined() const
Definition: MiniIFFAB.H:123
static int preAllocatable()
Definition: MiniIFFAB.H:156
void setVal(const T &value)
Definition: MiniIFFABI.H:72
Definition: FaceIndex.H:28
int nComp() const
Definition: MiniIFFAB.H:133
EBGraph m_ebgraph
Definition: MiniIFFAB.H:185
void clear()
Definition: MiniIFFABI.H:173
int size(const Box &R, const Interval &comps) const
Definition: MiniIFFABI.H:256
MiniIFFAB()
Definition: MiniIFFABI.H:23
Geometric description within a box.
Definition: EBGraph.H:432
void setDefaultValues()
Definition: MiniIFFABI.H:228
const Vector< FaceIndex > & getFaces() const
Definition: MiniIFFAB.H:177
void linearIn(void *buf, const Box &R, const Interval &comps)
Definition: MiniIFFABI.H:329
Structure for passing component ranges in code.
Definition: Interval.H:23
static bool s_verbose
Definition: MiniIFFAB.H:182
T * m_data
Definition: MiniIFFAB.H:193
int m_direction
Definition: MiniIFFAB.H:197
void operator=(const MiniIFFAB< T > &)
Definition: MiniIFFAB.H:202
Vector< FaceIndex > m_faces
Definition: MiniIFFAB.H:194
T * dataPtr(const int &a_comp)
Definition: MiniIFFABI.H:210
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.
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:99
T & operator()(const FaceIndex &a_face, const int &varlocin)
Definition: MiniIFFABI.H:186
void define(const Box &a_box, const EBGraph &a_ebgraph, const int &a_direction, const int &a_nvarin)
Definition: MiniIFFABI.H:48
MiniIFFAB(const MiniIFFAB< T > &)
Definition: MiniIFFAB.H:206
Definition: MiniIFFAB.H:34
int numFaces() const
Definition: MiniIFFAB.H:171
MiniIFFAB(const Box &a_region, int a_nVar)
invalid but necessary for leveldata to compile
Definition: MiniIFFAB.H:111
bool m_isDefined
Definition: MiniIFFAB.H:199
T * getIndex(const FaceIndex &a_face, const int &a_comp) const
Definition: MiniIFFABI.H:143
Box m_box
Definition: MiniIFFAB.H:184
void getFaceSubset(Vector< FaceIndex > &a_subFaces, const Box &a_subBox) const
Definition: MiniIFFABI.H:240
void linearOut(void *buf, const Box &R, const Interval &comps) const
Definition: MiniIFFABI.H:297