Chombo + EB  3.0
BaseEBFaceFAB.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 // ANAG, LBNL
12 
13 #ifndef _BASEEBFACEFAB_H_
14 #define _BASEEBFACEFAB_H_
15 
16 #include <cmath>
17 #include <cstdlib>
18 #include "SPACE.H"
19 #include "Vector.H"
20 #include "MiniIFFAB.H"
21 #include "IntVectSet.H"
22 #include "BaseFab.H"
23 #include "EBISBox.H"
24 #include "NamespaceHeader.H"
25 
26 /// Array defined at the Faces of an Box in an EBISBox.
27 /**
28  An BaseEBFaceFAB is a templated holder for face-centered
29  data over a region which consists of the intersection
30  of a face-centered box and an EBISBox.
31  At every uncovered VoF in this intersection,
32  the BaseEBFaceFAB contains a specified number of data values.
33  At singly valued faces,
34  the data is stored internally in a BaseFab. At multiply-valued
35  faces, the data is stored internally in an INFab.
36  A multiply-valued face is defined to be a face which
37  abuts at least one multiply-valued Face.
38  BaseEBFaceFAB provides indexing by Face.
39  This class does not provide a copy constructor or assignment operator
40  for all the usual reasons.
41  */
42 template <class T>
44 {
45 public:
46 
47  /// for AggStencil
48  int numDataTypes() const
49  {
50  return 2;
51  }
52 
53  /// for AggStencil
54  int dataType(const BaseIndex& a_baseInd) const
55  {
56  const FaceIndex* vofPtr = dynamic_cast<const FaceIndex *>(&a_baseInd);
57  if (vofPtr == NULL) MayDay::Error("Trying to index into an EBCellFAB with something that is not a FaceIndex");
58  int retval = 0;
59  const Vector<FaceIndex>& irrfaces =m_irrFAB.getFaces();
60  for (int iface = 0; iface < irrfaces.size(); iface++)
61  {
62  if (irrfaces[iface] == *vofPtr)
63  {
64  retval = 1;
65  break;
66  }
67  }
68  return retval;
69  }
70 
71  ///for AggStencil
72  long offset(const BaseIndex& a_baseInd, const int a_ivar) const
73  {
74  const FaceIndex* vofPtr = dynamic_cast<const FaceIndex *>(&a_baseInd);
75  if (vofPtr == NULL) MayDay::Error("Trying to index into an EBCellFAB with something that is not a FaceIndex");
76  bool irreg = false;
77  const Vector<FaceIndex>& irrfaces =m_irrFAB.getFaces();
78  for (int iface = 0; iface < irrfaces.size(); iface++)
79  {
80  if (irrfaces[iface] == *vofPtr)
81  {
82  irreg = true;
83  break;
84  }
85  }
86  long retval = 0;
87  if (irreg)
88  {
89  retval = m_irrFAB.offset(*vofPtr, a_ivar);
90  }
91  else
92  {
93  retval = m_regFAB.offset(vofPtr->gridIndex(Side::Hi), a_ivar);
94  }
95  return retval;
96  }
97 
98  ///for AggStencil
99  T* dataPtr(int a_dataType, int a_ivar)
100  {
101  if (a_dataType == 0)
102  {
103  return m_regFAB.dataPtr(a_ivar);
104  }
105  else if (a_dataType == 1)
106  {
107  return m_irrFAB.dataPtr(a_ivar);
108  }
109  else
110  {
111  MayDay::Error("bogus datatype input into dataPtr");
112  }
113  return NULL; //just avoiding compiler warnings with this
114  }
115 
116  const T* dataPtr(int a_dataType, int a_ivar) const
117  {
118  if (a_dataType == 0)
119  {
120  return m_regFAB.dataPtr(a_ivar);
121  }
122  else if (a_dataType == 1)
123  {
124  return m_irrFAB.dataPtr(a_ivar);
125  }
126  else
127  {
128  MayDay::Error("bogus datatype input into dataPtr");
129  }
130  return NULL; //just avoiding compiler warnings with this
131 
132  }
133 
134  ///
135  BaseEBFaceFAB();
136 
137  ///
138  /**
139  Box going into this needs to be cell-centered.
140  Data will exist over the surrounding nodes of the box.
141  */
142  BaseEBFaceFAB(const EBISBox& a_ebisBox,
143  const Box& a_region,
144  int a_iDir, int a_nVar);
145 
146  ///
147  /**
148  Box going into this needs to be cell-centered.
149  Data will exist over the surrounding nodes of the box.
150  */
151  virtual void
152  define(const EBISBox& a_ebisBox,
153  const Box& a_region,
154  int a_iDir, int a_nVar);
155 
156  ///
157  virtual ~BaseEBFaceFAB();
158 
159  ///
160  void clear();
161 
162  ///
163  void setVal(const T& value);
164 
165  ///
166  void setVal(int ivar,const T& value);
167 
168  ///
169  bool isDefined() const;
170 
171  ///
172  int nComp() const ;
173 
174  ///
175  const MiniIFFAB<T>& getMultiValuedFAB() const;
176 
177  ///
179 
180  ///
181  const BaseFab<T>& getSingleValuedFAB() const;
182 
183  ///
185 
186  ///
187  int direction() const;
188 
189  ///
190  /**
191  Returns the FACE-CENTERED region of the fab
192  */
193  const Box& getRegion() const ;
194 
195  ///
196  /**
197  Returns the CELL-CENTERED region of the fab
198  */
199  const Box& getCellRegion() const ;
200 
201  ///
202  T& operator() (const FaceIndex& a_facein, int a_nVarLoc);
203 
204  ///
205  const T&
206  operator() (const FaceIndex& a_facein, int a_nVarLoc) const;
207 
208  ///
209  static bool preAllocatable()
210  {
211  return true;
212  }
213 
214  ///
215  /**
216  Box going into this should be CELL CENTERED.
217  copy done over surrounding nodes.
218  */
219  void copy(const Box& RegionFrom,
220  const Interval& destInt,
221  const Box& RegionTo,
222  const BaseEBFaceFAB<T>& source,
223  const Interval& srcInt);
224 
225  BaseEBFaceFAB<T>& copy(const BaseEBFaceFAB<T>& source);
226 
227  int size(const Box& R, const Interval& comps) const;
228 
229  void linearOut(void* buf, const Box& R, const Interval& comps) const;
230 
231  void linearIn(void* buf, const Box& R, const Interval& comps);
232 
233  /// Invalid but necessary for LevelData<T> to compile
234  BaseEBFaceFAB(const Box& a_region, int a_nVar)
235  {
236  MayDay::Error("invalid constructor called for BaseEBFaceFAB");
237  }
238 
239  ///
240  const EBISBox& getEBISBox() const;
241 
242  ///
243  void
244  setCoveredFaceVal(const T& a_val,
245  const int& a_comp,
246  const bool& a_doMulti=true);
247 
248 protected:
249  ///data at faces which abut multi-valued cells
251  ///data at faces between two single-valued cells
253 
254  ///number of data values at each face in BaseEBFaceFAB
255  int m_nComp;
256 
257  //direction of the faces in the BaseEBFaceFAB
258  int m_iDir;
259 
260  ///the face-centered region over which the BaseEBFaceFAB lives
262 
263  ///the cell-centered region over which the BaseEBFaceFAB lives
265 
266  ///has the full define function been called for the BaseEBFaceFAB?
268 
270 private:
271  void
273  //disallowed for performance reasons
274  void operator= (const BaseEBFaceFAB<T>& ebcin)
275  {
276  MayDay::Error("BaseEBFaceFAB<T>::operator= not defined");
277  }
279  {
280  MayDay::Error("BaseEBFaceFAB<T> copy constructor not defined");
281  }
282 };
283 
284 #include "NamespaceFooter.H"
285 
286 #ifndef CH_EXPLICIT_TEMPLATES
287 #include "BaseEBFaceFABI.H"
288 #endif // CH_EXPLICIT_TEMPLATES
289 
290 #endif
int m_nComp
number of data values at each face in BaseEBFaceFAB
Definition: BaseEBFaceFAB.H:255
void clear()
Definition: BaseEBFaceFABI.H:225
const Box & getRegion() const
Definition: BaseEBFaceFABI.H:324
void setVal(const T &value)
Definition: BaseEBFaceFABI.H:236
BaseEBFaceFAB(const Box &a_region, int a_nVar)
Invalid but necessary for LevelData<T> to compile.
Definition: BaseEBFaceFAB.H:234
int nComp() const
Definition: BaseEBFaceFABI.H:264
void setCoveredFaceVal(const T &a_val, const int &a_comp, const bool &a_doMulti=true)
Definition: BaseEBFaceFABI.H:23
Definition: FaceIndex.H:28
Box m_region
the cell-centered region over which the BaseEBFaceFAB lives
Definition: BaseEBFaceFAB.H:264
Definition: EBISBox.H:46
const IntVect & gridIndex(const Side::LoHiSide &a_sd) const
index for other indicies to inherit
Definition: BaseIndex.H:26
Array defined at the Faces of an Box in an EBISBox.
Definition: BaseEBFaceFAB.H:43
Definition: LoHiSide.H:31
T & operator()(const FaceIndex &a_facein, int a_nVarLoc)
Definition: BaseEBFaceFABI.H:343
EBISBox m_ebisBox
Definition: BaseEBFaceFAB.H:269
void linearOut(void *buf, const Box &R, const Interval &comps) const
Definition: BaseEBFaceFABI.H:76
static bool preAllocatable()
Definition: BaseEBFaceFAB.H:209
virtual ~BaseEBFaceFAB()
Definition: BaseEBFaceFABI.H:216
BaseEBFaceFAB(const BaseEBFaceFAB< T > &ebcin)
Definition: BaseEBFaceFAB.H:278
BaseFab< T > m_regFAB
data at faces between two single-valued cells
Definition: BaseEBFaceFAB.H:252
Structure for passing component ranges in code.
Definition: Interval.H:23
MiniIFFAB< T > m_irrFAB
data at faces which abut multi-valued cells
Definition: BaseEBFaceFAB.H:250
void copy(const Box &RegionFrom, const Interval &destInt, const Box &RegionTo, const BaseEBFaceFAB< T > &source, const Interval &srcInt)
Definition: BaseEBFaceFABI.H:127
const T * dataPtr(int a_dataType, int a_ivar) const
Definition: BaseEBFaceFAB.H:116
const Box & getCellRegion() const
Definition: BaseEBFaceFABI.H:333
const EBISBox & getEBISBox() const
Definition: BaseEBFaceFABI.H:100
void linearIn(void *buf, const Box &R, const Interval &comps)
Definition: BaseEBFaceFABI.H:88
size_t size() const
Definition: Vector.H:177
int size(const Box &R, const Interval &comps) const
Definition: BaseEBFaceFABI.H:64
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.
Definition: BaseFab.H:76
const BaseFab< T > & getSingleValuedFAB() const
Definition: BaseEBFaceFABI.H:294
void operator=(const BaseEBFaceFAB< T > &ebcin)
Definition: BaseEBFaceFAB.H:274
long offset(const BaseIndex &a_baseInd, const int a_ivar) const
for AggStencil
Definition: BaseEBFaceFAB.H:72
A Rectangular Domain on an Integer Lattice.
Definition: Box.H:465
Definition: MiniIFFAB.H:34
T * dataPtr(int a_dataType, int a_ivar)
for AggStencil
Definition: BaseEBFaceFAB.H:99
BaseEBFaceFAB()
Definition: BaseEBFaceFABI.H:161
bool m_isDefined
has the full define function been called for the BaseEBFaceFAB?
Definition: BaseEBFaceFAB.H:267
int numDataTypes() const
for AggStencil
Definition: BaseEBFaceFAB.H:48
Box m_regionFace
the face-centered region over which the BaseEBFaceFAB lives
Definition: BaseEBFaceFAB.H:261
int direction() const
Definition: BaseEBFaceFABI.H:314
virtual void define(const EBISBox &a_ebisBox, const Box &a_region, int a_iDir, int a_nVar)
Definition: BaseEBFaceFABI.H:181
void setDefaultValues()
Definition: BaseEBFaceFABI.H:411
int m_iDir
Definition: BaseEBFaceFAB.H:258
const MiniIFFAB< T > & getMultiValuedFAB() const
Definition: BaseEBFaceFABI.H:274
int dataType(const BaseIndex &a_baseInd) const
for AggStencil
Definition: BaseEBFaceFAB.H:54
bool isDefined() const
Definition: BaseEBFaceFABI.H:255