Chombo + EB + MF  3.2
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  bool m_verbose = false;
48 
49  /// for AggStencil
50  int numDataTypes() const
51  {
52  return 2;
53  }
54 
55  /// for AggStencil
56  int dataType(const BaseIndex& a_baseInd) const
57  {
58  const FaceIndex* vofPtr = dynamic_cast<const FaceIndex *>(&a_baseInd);
59  if (vofPtr == NULL) MayDay::Error("Trying to index into an EBCellFAB with something that is not a FaceIndex");
60  int retval = 0;
61  const Vector<FaceIndex>& irrfaces =m_irrFAB.getFaces();
62  for (int iface = 0; iface < irrfaces.size(); iface++)
63  {
64  if (irrfaces[iface] == *vofPtr)
65  {
66  retval = 1;
67  break;
68  }
69  }
70  return retval;
71  }
72 
73  ///for AggStencil
74  long offset(const BaseIndex& a_baseInd, const int a_ivar) const
75  {
76  const FaceIndex* vofPtr = dynamic_cast<const FaceIndex *>(&a_baseInd);
77  if (vofPtr == NULL) MayDay::Error("Trying to index into an EBCellFAB with something that is not a FaceIndex");
78  bool irreg = false;
79  const Vector<FaceIndex>& irrfaces =m_irrFAB.getFaces();
80  for (int iface = 0; iface < irrfaces.size(); iface++)
81  {
82  if (irrfaces[iface] == *vofPtr)
83  {
84  irreg = true;
85  break;
86  }
87  }
88  long retval = 0;
89  if (irreg)
90  {
91  retval = m_irrFAB.offset(*vofPtr, a_ivar);
92  }
93  else
94  {
95  retval = m_regFAB.offset(vofPtr->gridIndex(Side::Hi), a_ivar);
96  }
97  return retval;
98  }
99 
100  ///for AggStencil
101  T* dataPtr(int a_dataType, int a_ivar)
102  {
103  if (a_dataType == 0)
104  {
105  return m_regFAB.dataPtr(a_ivar);
106  }
107  else if (a_dataType == 1)
108  {
109  return m_irrFAB.dataPtr(a_ivar);
110  }
111  else
112  {
113  MayDay::Error("bogus datatype input into dataPtr");
114  }
115  return NULL; //just avoiding compiler warnings with this
116  }
117 
118  const T* dataPtr(int a_dataType, int a_ivar) const
119  {
120  if (a_dataType == 0)
121  {
122  return m_regFAB.dataPtr(a_ivar);
123  }
124  else if (a_dataType == 1)
125  {
126  return m_irrFAB.dataPtr(a_ivar);
127  }
128  else
129  {
130  MayDay::Error("bogus datatype input into dataPtr");
131  }
132  return NULL; //just avoiding compiler warnings with this
133 
134  }
135 
136  ///
137  BaseEBFaceFAB();
138 
139  ///
140  /**
141  Box going into this needs to be cell-centered.
142  Data will exist over the surrounding nodes of the box.
143  */
144  BaseEBFaceFAB(const EBISBox& a_ebisBox,
145  const Box& a_region,
146  int a_iDir, int a_nVar);
147 
148  ///
149  /**
150  Box going into this needs to be cell-centered.
151  Data will exist over the surrounding nodes of the box.
152  */
153  virtual void
154  define(const EBISBox& a_ebisBox,
155  const Box& a_region,
156  int a_iDir, int a_nVar);
157 
158  ///
159  virtual ~BaseEBFaceFAB();
160 
161  ///
162  void clear();
163 
164  ///
165  void setVal(const T& value);
166 
167  ///
168  void setVal(int ivar,const T& value);
169 
170  ///
171  bool isDefined() const;
172 
173  ///
174  int nComp() const ;
175 
176  ///
177  const MiniIFFAB<T>& getMultiValuedFAB() const;
178 
179  ///
181 
182  ///
183  const BaseFab<T>& getSingleValuedFAB() const;
184 
185  ///
187 
188  ///
189  int direction() const;
190 
191  ///
192  /**
193  Returns the FACE-CENTERED region of the fab
194  */
195  const Box& getRegion() const ;
196 
197  ///
198  /**
199  Returns the CELL-CENTERED region of the fab
200  */
201  const Box& getCellRegion() const ;
202 
203  ///
204  T& operator() (const FaceIndex& a_facein, int a_nVarLoc);
205 
206  ///
207  const T&
208  operator() (const FaceIndex& a_facein, int a_nVarLoc) const;
209 
210  ///
211  static bool preAllocatable()
212  {
213  return true;
214  }
215 
216  ///
217  /**
218  Box going into this should be CELL CENTERED.
219  copy done over surrounding nodes.
220  */
221  void copy(const Box& RegionFrom,
222  const Interval& destInt,
223  const Box& RegionTo,
224  const BaseEBFaceFAB<T>& source,
225  const Interval& srcInt);
226 
227  BaseEBFaceFAB<T>& copy(const BaseEBFaceFAB<T>& source);
228 
229  int size(const Box& R, const Interval& comps) const;
230 
231  void linearOut(void* buf, const Box& R, const Interval& comps) const;
232 
233  void linearIn(void* buf, const Box& R, const Interval& comps);
234 
235  /// Invalid but necessary for LevelData<T> to compile
236  BaseEBFaceFAB(const Box& a_region, int a_nVar)
237  {
238  MayDay::Error("invalid constructor called for BaseEBFaceFAB");
239  }
240 
241  ///
242  const EBISBox& getEBISBox() const;
243 
244  ///
245  void
246  setCoveredFaceVal(const T& a_val,
247  const int& a_comp,
248  const bool& a_doMulti=true);
249 
250  /// aliasing copy-ish constructor. Used when the 'alias' function is invoked on LevelData
251  /**
252  Constructs an 'aliased' BaseEBCellFab of the requested interval of the
253  argument BaseEBCellFab. This BaseEBCellFab does not allocate any memory, but
254  sets its data pointer into the memory pointed to by the argument
255  BaseEBCellFab. It is the users responsiblity to ensure this aliased
256  BaseEBCellFab is not used after the original BaseEBCellFab has deleted its data ptr
257  (resize, define(..) called, or destruction, etc.).
258 
259  This aliased BaseEBCellFab will also generate side effects (modifying the values
260  of data in one will modify the other's data).
261 
262  This aliased BaseFab will have a_comps.size() components, starting at zero.
263  */
264  BaseEBFaceFAB(const Interval& a_comps,
265  BaseEBFaceFAB<T>& a_original);
266 protected:
267  ///data at faces which abut multi-valued cells
269  ///data at faces between two single-valued cells
271 
272  ///number of data values at each face in BaseEBFaceFAB
273  int m_nComp;
274 
275  //direction of the faces in the BaseEBFaceFAB
276  int m_iDir;
277 
278  ///the face-centered region over which the BaseEBFaceFAB lives
280 
281  ///the cell-centered region over which the BaseEBFaceFAB lives
283 
284  ///has the full define function been called for the BaseEBFaceFAB?
286 
288 private:
289  void
291  //disallowed for performance reasons
292  void operator= (const BaseEBFaceFAB<T>& ebcin)
293  {
294  MayDay::Error("BaseEBFaceFAB<T>::operator= not defined");
295  }
297  {
298  MayDay::Error("BaseEBFaceFAB<T> copy constructor not defined");
299  }
300 };
301 
302 #include "NamespaceFooter.H"
303 
304 #ifndef CH_EXPLICIT_TEMPLATES
305 #include "BaseEBFaceFABI.H"
306 #endif // CH_EXPLICIT_TEMPLATES
307 
308 #endif
int m_nComp
number of data values at each face in BaseEBFaceFAB
Definition: BaseEBFaceFAB.H:273
void clear()
Definition: BaseEBFaceFABI.H:254
const Box & getRegion() const
Definition: BaseEBFaceFABI.H:353
void setVal(const T &value)
Definition: BaseEBFaceFABI.H:265
BaseEBFaceFAB(const Box &a_region, int a_nVar)
Invalid but necessary for LevelData<T> to compile.
Definition: BaseEBFaceFAB.H:236
int nComp() const
Definition: BaseEBFaceFABI.H:293
void setCoveredFaceVal(const T &a_val, const int &a_comp, const bool &a_doMulti=true)
Definition: BaseEBFaceFABI.H:37
Definition: FaceIndex.H:28
Box m_region
the cell-centered region over which the BaseEBFaceFAB lives
Definition: BaseEBFaceFAB.H:282
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:372
EBISBox m_ebisBox
Definition: BaseEBFaceFAB.H:287
bool m_verbose
Definition: BaseEBFaceFAB.H:47
void linearOut(void *buf, const Box &R, const Interval &comps) const
Definition: BaseEBFaceFABI.H:98
static bool preAllocatable()
Definition: BaseEBFaceFAB.H:211
virtual ~BaseEBFaceFAB()
Definition: BaseEBFaceFABI.H:245
BaseEBFaceFAB(const BaseEBFaceFAB< T > &ebcin)
Definition: BaseEBFaceFAB.H:296
BaseFab< T > m_regFAB
data at faces between two single-valued cells
Definition: BaseEBFaceFAB.H:270
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:268
void copy(const Box &RegionFrom, const Interval &destInt, const Box &RegionTo, const BaseEBFaceFAB< T > &source, const Interval &srcInt)
Definition: BaseEBFaceFABI.H:149
const T * dataPtr(int a_dataType, int a_ivar) const
Definition: BaseEBFaceFAB.H:118
const Box & getCellRegion() const
Definition: BaseEBFaceFABI.H:362
const EBISBox & getEBISBox() const
Definition: BaseEBFaceFABI.H:122
void linearIn(void *buf, const Box &R, const Interval &comps)
Definition: BaseEBFaceFABI.H:110
size_t size() const
Definition: Vector.H:192
int size(const Box &R, const Interval &comps) const
Definition: BaseEBFaceFABI.H:78
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:81
const BaseFab< T > & getSingleValuedFAB() const
Definition: BaseEBFaceFABI.H:323
void operator=(const BaseEBFaceFAB< T > &ebcin)
Definition: BaseEBFaceFAB.H:292
long offset(const BaseIndex &a_baseInd, const int a_ivar) const
for AggStencil
Definition: BaseEBFaceFAB.H:74
A Rectangular Domain on an Integer Lattice.
Definition: Box.H:469
Definition: MiniIFFAB.H:34
T * dataPtr(int a_dataType, int a_ivar)
for AggStencil
Definition: BaseEBFaceFAB.H:101
BaseEBFaceFAB()
Definition: BaseEBFaceFABI.H:188
bool m_isDefined
has the full define function been called for the BaseEBFaceFAB?
Definition: BaseEBFaceFAB.H:285
int numDataTypes() const
for AggStencil
Definition: BaseEBFaceFAB.H:50
Box m_regionFace
the face-centered region over which the BaseEBFaceFAB lives
Definition: BaseEBFaceFAB.H:279
int direction() const
Definition: BaseEBFaceFABI.H:343
virtual void define(const EBISBox &a_ebisBox, const Box &a_region, int a_iDir, int a_nVar)
Definition: BaseEBFaceFABI.H:208
void setDefaultValues()
Definition: BaseEBFaceFABI.H:440
int m_iDir
Definition: BaseEBFaceFAB.H:276
const MiniIFFAB< T > & getMultiValuedFAB() const
Definition: BaseEBFaceFABI.H:303
int dataType(const BaseIndex &a_baseInd) const
for AggStencil
Definition: BaseEBFaceFAB.H:56
bool isDefined() const
Definition: BaseEBFaceFABI.H:284