Chombo + EB  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  /// 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  /// aliasing copy-ish constructor. Used when the 'alias' function is invoked on LevelData
249  /**
250  Constructs an 'aliased' BaseEBCellFab of the requested interval of the
251  argument BaseEBCellFab. This BaseEBCellFab does not allocate any memory, but
252  sets its data pointer into the memory pointed to by the argument
253  BaseEBCellFab. It is the users responsiblity to ensure this aliased
254  BaseEBCellFab is not used after the original BaseEBCellFab has deleted its data ptr
255  (resize, define(..) called, or destruction, etc.).
256 
257  This aliased BaseEBCellFab will also generate side effects (modifying the values
258  of data in one will modify the other's data).
259 
260  This aliased BaseFab will have a_comps.size() components, starting at zero.
261  */
262  BaseEBFaceFAB(const Interval& a_comps,
263  BaseEBFaceFAB<T>& a_original);
264 protected:
265  ///data at faces which abut multi-valued cells
267  ///data at faces between two single-valued cells
269 
270  ///number of data values at each face in BaseEBFaceFAB
271  int m_nComp;
272 
273  //direction of the faces in the BaseEBFaceFAB
274  int m_iDir;
275 
276  ///the face-centered region over which the BaseEBFaceFAB lives
278 
279  ///the cell-centered region over which the BaseEBFaceFAB lives
281 
282  ///has the full define function been called for the BaseEBFaceFAB?
284 
286 private:
287  void
289  //disallowed for performance reasons
290  void operator= (const BaseEBFaceFAB<T>& ebcin)
291  {
292  MayDay::Error("BaseEBFaceFAB<T>::operator= not defined");
293  }
295  {
296  MayDay::Error("BaseEBFaceFAB<T> copy constructor not defined");
297  }
298 };
299 
300 #include "NamespaceFooter.H"
301 
302 #ifndef CH_EXPLICIT_TEMPLATES
303 #include "BaseEBFaceFABI.H"
304 #endif // CH_EXPLICIT_TEMPLATES
305 
306 #endif
int m_nComp
number of data values at each face in BaseEBFaceFAB
Definition: BaseEBFaceFAB.H:271
void clear()
Definition: BaseEBFaceFABI.H:246
long offset(const BaseIndex &a_baseInd, const int a_ivar) const
for AggStencil
Definition: BaseEBFaceFAB.H:72
void setVal(const T &value)
Definition: BaseEBFaceFABI.H:257
int direction() const
Definition: BaseEBFaceFABI.H:335
BaseEBFaceFAB(const Box &a_region, int a_nVar)
Invalid but necessary for LevelData<T> to compile.
Definition: BaseEBFaceFAB.H:234
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:280
Definition: EBISBox.H:46
int dataType(const BaseIndex &a_baseInd) const
for AggStencil
Definition: BaseEBFaceFAB.H:54
const Box & getRegion() const
Definition: BaseEBFaceFABI.H:345
int numDataTypes() const
for AggStencil
Definition: BaseEBFaceFAB.H:48
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
const MiniIFFAB< T > & getMultiValuedFAB() const
Definition: BaseEBFaceFABI.H:295
Definition: LoHiSide.H:31
T & operator()(const FaceIndex &a_facein, int a_nVarLoc)
Definition: BaseEBFaceFABI.H:364
EBISBox m_ebisBox
Definition: BaseEBFaceFAB.H:285
static bool preAllocatable()
Definition: BaseEBFaceFAB.H:209
virtual ~BaseEBFaceFAB()
Definition: BaseEBFaceFABI.H:237
BaseEBFaceFAB(const BaseEBFaceFAB< T > &ebcin)
Definition: BaseEBFaceFAB.H:294
BaseFab< T > m_regFAB
data at faces between two single-valued cells
Definition: BaseEBFaceFAB.H:268
Structure for passing component ranges in code.
Definition: Interval.H:23
int nComp() const
Definition: BaseEBFaceFABI.H:285
const T * dataPtr(int a_dataType, int a_ivar) const
Definition: BaseEBFaceFAB.H:116
MiniIFFAB< T > m_irrFAB
data at faces which abut multi-valued cells
Definition: BaseEBFaceFAB.H:266
void copy(const Box &RegionFrom, const Interval &destInt, const Box &RegionTo, const BaseEBFaceFAB< T > &source, const Interval &srcInt)
Definition: BaseEBFaceFABI.H:141
const BaseFab< T > & getSingleValuedFAB() const
Definition: BaseEBFaceFABI.H:315
void linearIn(void *buf, const Box &R, const Interval &comps)
Definition: BaseEBFaceFABI.H:102
const EBISBox & getEBISBox() const
Definition: BaseEBFaceFABI.H:114
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 linearOut(void *buf, const Box &R, const Interval &comps) const
Definition: BaseEBFaceFABI.H:90
Definition: BaseFab.H:76
void operator=(const BaseEBFaceFAB< T > &ebcin)
Definition: BaseEBFaceFAB.H:290
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:180
bool m_isDefined
has the full define function been called for the BaseEBFaceFAB?
Definition: BaseEBFaceFAB.H:283
const IntVect & gridIndex(const Side::LoHiSide &a_sd) const
size_t size() const
Definition: Vector.H:192
Box m_regionFace
the face-centered region over which the BaseEBFaceFAB lives
Definition: BaseEBFaceFAB.H:277
int size(const Box &R, const Interval &comps) const
Definition: BaseEBFaceFABI.H:78
const Box & getCellRegion() const
Definition: BaseEBFaceFABI.H:354
virtual void define(const EBISBox &a_ebisBox, const Box &a_region, int a_iDir, int a_nVar)
Definition: BaseEBFaceFABI.H:200
void setDefaultValues()
Definition: BaseEBFaceFABI.H:432
int m_iDir
Definition: BaseEBFaceFAB.H:274
bool isDefined() const
Definition: BaseEBFaceFABI.H:276