Chombo + EB  3.2
BaseIFFAB.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
12 
13 #ifndef _BASEIFFAB_H_
14 #define _BASEIFFAB_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  BaseIFFAB is a templated data holder
31  defined over the Faces of an irregular domain.
32 */
33 template <class T>
34 class BaseIFFAB
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  BaseIFFAB();
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  BaseIFFAB(const IntVectSet& a_region,
52  const EBGraph& a_ebgraph,
53  const int& a_direction,
54  const int& a_nvarin);
55 
56  ///
57  ~BaseIFFAB();
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 IntVectSet& a_region,
68  const EBGraph& a_ebgraph,
69  const int& a_direction,
70  const int& a_nvarin);
71 
72  ///
73  /**
74  Set a value at every data location.
75  */
76  void setVal(const T& value);
77 
78  ///
79  /**
80  Set a value at every data location.
81  */
82  void setVal(int ivar, const T& value);
83 
84  ///
85  /**
86  define over surrounding nodes of invectset (ivs is cell-centered).
87  */
88  void copy(const Box& a_intBox,
89  const Interval& a_destInterval,
90  const Box& a_toBox,
91  const BaseIFFAB<T>& a_src,
92  const Interval& a_srcInterval);
93 
94  ///
95  /**
96  Remove all data from this BaseIFFAB.
97  You must call {\bf define} again in order
98  to use it.
99  */
100 
101  void clear();
102 
103  ///invalid but necessary for leveldata to compile
104  BaseIFFAB(const Box& a_region, int a_nVar)
105  {
106  MayDay::Error("invalid constructor called for baseebcellfab");
107  }
108 
109  ///
110  /**
111 
112  Tells whether this BaseIFFAB has been defined, either with a constructor
113  or with {\bf define}. It must be initialized in order to access its data.
114  */
115  bool
116  isDefined() const;
117 
118  ///
119  /**
120  Return the number of face in this BaseIFFAB.
121  */
122  int numFaces() const;
123 
124  ///
125  /**
126  Return the number of data components of this BaseIFFAB.
127  */
128  int nComp() const;
129 
130  ///
131 
132  ///
133  /**
134  Return the direction of the faces of this BaseIFFAB.
135  */
136  int direction() const;
137 
138  ///
139 
140  /**
141  Return the irregular domain of the BaseIFFAB.
142  */
143  const IntVectSet& getIVS() const;
144 
145  ///
146  /**
147  Indexing operator. Return a reference to the contents of this IFFAB,
148  at the specified face and data component. The first component is
149  zero, the last is {\em nvar-1}. The returned object is a modifiable
150  lvalue.
151  */
152  T& operator() (const FaceIndex& a_face,const int& varlocin);
153  const T& operator()(const FaceIndex& a_face,const int& varlocin) const;
154 
155 
156  ///
157  T* dataPtr(const int& a_comp);
158 
159  T* getIndex(const FaceIndex& a_face, const int& a_comp) const;
160 
161  ///for AggStencil
162  long offset(const FaceIndex& a_vof, const int& a_ivar) const
163  {
164  const T& conval = (*this)(a_vof, a_ivar);
165  long roffset = (int)(&conval);
166  roffset -= (int)(&m_data[0]);
167  return roffset;
168  }
169 
170  ///
171  const T* dataPtr(const int& a_comp) const;
172 
173  const EBGraph& getEBGraph() const;
174 
175  static int preAllocatable()
176  {
177  return 1; // symmetric preallocatable
178  }
179 
180  ///
181  int size(const Box& R, const Interval& comps) const ;
182 
183  ///
184  void linearOut(void* buf, const Box& R, const Interval& comps) const;
185 
186  ///
187  void linearIn(void* buf, const Box& R, const Interval& comps);
188 
189  ///
190  static void setVerbose(bool a_verbose);
191  static bool s_verbose;
192 private:
193  void
195 
196 protected:
197 
198  //functions to aid in my ongoing battle with
199  //cell-centered semantics for a face-centered
200  //data structure.
201  bool useThisFace(const Box& a_toBox,
202  const FaceIndex& a_face) const;
203 
204  void getBoxAndIVS(Box& a_intBox,
205  IntVectSet& a_ivsIntersect,
206  const Box& a_toBox) const;
207 
208 
209  static Arena* s_Arena;
210 
211  //get index vector<int> at the face location
212  //using lexographic ordering of vof's indicies
213  int getLocalVecIndex(const FaceIndex& a_face) const;
214 
215 public:
216  static void setSurroundingNodeSemantic(bool a_useSurr);
217 
218 protected:
220  //T* m_data;
223  int m_nComp;
224  int m_nFaces;
226 
227  //object to store pointers to facilitate fast indexing
232 private:
233  //we disallow copy construction and assigment for data holders
235  {
236  MayDay::Error("invalid operator");
237  }
239  {
240  MayDay::Error("invalid operator");
241  }
242 };
243 
244 #include "NamespaceFooter.H"
245 
246 #ifndef CH_EXPLICIT_TEMPLATES
247 #include "BaseIFFABI.H"
248 #endif
249 
250 #endif
void linearIn(void *buf, const Box &R, const Interval &comps)
Definition: BaseIFFABI.H:603
int nComp() const
Definition: BaseIFFABI.H:424
T * dataPtr(const int &a_comp)
Definition: BaseIFFABI.H:463
static void setVerbose(bool a_verbose)
Definition: BaseIFFABI.H:72
int m_nComp
Definition: BaseIFFAB.H:223
int m_truesize
Definition: BaseIFFAB.H:222
An irregular domain on an integer lattice.
Definition: IntVectSet.H:44
int size(const Box &R, const Interval &comps) const
Definition: BaseIFFABI.H:499
bool m_isDefined
Definition: BaseIFFAB.H:231
one dimensional dynamic array
Definition: Vector.H:53
Definition: FaceIndex.H:28
void clear()
Definition: BaseIFFABI.H:388
void operator=(const BaseIFFAB< T > &)
Definition: BaseIFFAB.H:234
void setVal(const T &value)
Definition: BaseIFFABI.H:273
~BaseIFFAB()
Definition: BaseIFFABI.H:91
int getLocalVecIndex(const FaceIndex &a_face) const
Definition: BaseIFFABI.H:360
Geometric description within a box.
Definition: EBGraph.H:427
BaseIFFAB(const Box &a_region, int a_nVar)
invalid but necessary for leveldata to compile
Definition: BaseIFFAB.H:104
static Arena * s_Arena
Definition: BaseIFFAB.H:209
IntVectSet m_ivs
Definition: BaseIFFAB.H:229
Structure for passing component ranges in code.
Definition: Interval.H:23
bool isDefined() const
Definition: BaseIFFABI.H:410
static void setSurroundingNodeSemantic(bool a_useSurr)
Definition: BaseIFFABI.H:25
A Virtual Base Class for Dynamic Memory Managemen.
Definition: Arena.H:40
BaseIFFAB(const BaseIFFAB< T > &)
Definition: BaseIFFAB.H:238
int direction() const
Definition: BaseIFFABI.H:266
EBGraph m_ebgraph
Definition: BaseIFFAB.H:230
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.
BaseFab< T * > m_fab
Definition: BaseIFFAB.H:228
Definition: BaseFab.H:77
Vector< T > m_data
Definition: BaseIFFAB.H:221
int m_direction
Definition: BaseIFFAB.H:225
bool useThisFace(const Box &a_toBox, const FaceIndex &a_face) const
Definition: BaseIFFABI.H:34
void setDefaultValues()
Definition: BaseIFFABI.H:488
static bool s_doSurroundingNodeSemantic
Definition: BaseIFFAB.H:219
A Rectangular Domain on an Integer Lattice.
Definition: Box.H:465
long offset(const FaceIndex &a_vof, const int &a_ivar) const
for AggStencil
Definition: BaseIFFAB.H:162
Definition: BaseIFFAB.H:34
BaseIFFAB()
Definition: BaseIFFABI.H:85
int m_nFaces
Definition: BaseIFFAB.H:224
static bool s_verbose
Definition: BaseIFFAB.H:191
void linearOut(void *buf, const Box &R, const Interval &comps) const
Definition: BaseIFFABI.H:561
void copy(const Box &a_intBox, const Interval &a_destInterval, const Box &a_toBox, const BaseIFFAB< T > &a_src, const Interval &a_srcInterval)
Definition: BaseIFFABI.H:298
static int preAllocatable()
Definition: BaseIFFAB.H:175
T & operator()(const FaceIndex &a_face, const int &varlocin)
Definition: BaseIFFABI.H:431
void define(const IntVectSet &a_region, const EBGraph &a_ebgraph, const int &a_direction, const int &a_nvarin)
Definition: BaseIFFABI.H:112
void getBoxAndIVS(Box &a_intBox, IntVectSet &a_ivsIntersect, const Box &a_toBox) const
Definition: BaseIFFABI.H:54
T * getIndex(const FaceIndex &a_face, const int &a_comp) const
Definition: BaseIFFABI.H:347
int numFaces() const
Definition: BaseIFFABI.H:417
const EBGraph & getEBGraph() const
Definition: BaseIFFABI.H:79
const IntVectSet & getIVS() const
Definition: BaseIFFABI.H:259