Chombo + EB  3.2
FaceIndex.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, DTG
12 
13 #ifndef _FACEINDEX_H_
14 #define _FACEINDEX_H_
15 
16 #include "LoHiSide.H"
17 #include "VolIndex.H"
18 #include "SPMD.H"
19 #include "BaseIndex.H"
20 #include "NamespaceHeader.H"
21 
22 ///
23 /**
24  FaceIndex is a very lightweight object used
25  to distinguish faces. It has two VolIndex (s)
26  and a direction and a way to access them.
27 */
28 class FaceIndex : public BaseIndex
29 {
30 public:
31  ///
32  /**
33  if both cellindexes of the vofs are >= 0,
34  then the face is interior. otherwise the face is
35  a boundary face.
36  */
37  FaceIndex(const VolIndex& a_vof1,
38  const VolIndex& a_vof2,
39  const int& a_direction);
40  ///
41  /**
42  shorthand constructor.
43  */
44  FaceIndex(const VolIndex& a_vof1,
45  const VolIndex& a_vof2);
46 
47  ///
48  /**
49  if both cellindexes of the vofs are >= 0,
50  then the face is interior. otherwise the face is
51  a boundary face.
52  */
53  void define(const VolIndex& a_vof1,
54  const VolIndex& a_vof2,
55  const int& a_direction);
56 
57  ///
58  /**
59  Shorthand define. First determine if they are neighbors
60  then find the direction to pass to full define
61  */
62  void define(const VolIndex& a_vof1,
63  const VolIndex& a_vof2);
64  ///
65  /**
66  */
67  FaceIndex();
68 
69  ///
70  /**
71  */
72  FaceIndex(const FaceIndex& a_facein);
73 
74  ///
75  /**
76  */
77  void define(const FaceIndex& a_facein);
78 
79  ///
80  /**
81  */
82  ~FaceIndex();
83 
84  ///
85  /**
86  */
87  FaceIndex& operator= (const FaceIndex& a_facein);
88 
89  ///
90  /** Lexicographic */
91  friend bool operator<( const FaceIndex& f1, const FaceIndex& f2 );
92 
93  ///
94  friend ostream& operator<<( ostream& out, const FaceIndex& fi );
95 
96 
97  ///
98  /**
99  */
100  bool operator== (const FaceIndex& a_facein) const;
101 
102  ///
103  /**
104  */
105  bool operator!= (const FaceIndex& a_facein) const;
106 
107  ///
108  /**
109  */
110  const int& direction() const;
111 
112  ///
113  /**
114  */
115  const bool& isDefined() const;
116 
117  ///
118  /**
119  */
120  const bool& isBoundary() const;
121 
122  ///
123  /**
124  return cell index of the vof on the a_sd side.
125  returns -1 if that side of the face is outside
126  the domain (boundary face case).
127  */
128  const int& cellIndex(const Side::LoHiSide& a_sd) const;
129 
130  ///
131  /**
132  return grid index of the vof on the a_sd side.
133  may be inside or ouside domain.
134  */
135  const IntVect& gridIndex(const Side::LoHiSide& a_sd) const;
136 
137  ///
138  /**
139  manufactures the appropriate volindex.
140  */
141  VolIndex getVoF(const Side::LoHiSide& a_sd) const;
142 
143  ///
144  /**
145  a_vof needs to be one of the two vofs connected by this face
146  Standing on a_vof, face opens toward the other vof
147  returns 1 if face opens toward positive axis
148  returns -1 if face opens toward negative axis
149  returns 0 if a_vof is not one of the member vofs.
150  */
151  int faceSign(const VolIndex& a_vof) const;
152 
153  // not user functions
154  static size_t lo_offset, hi_offset, rest_offset;
155  static int initializeOffsets();
156 
157  ///for stencil gymnastics
158  void shift(const IntVect& a_iv)
159  {
160  m_loiv += a_iv;
161  m_hiiv += a_iv;
162  }
163 
164 private:
165 
166  ///the intvect of the low vof
167  /**
168  */
170 
171  ///the intvect of the high vof
172  /**
173  */
175 
176  ///
177  /**
178  The index of the low vof.
179  This = -1 if the face is set to be a boundary
180  face on the low side of the domain.
181  */
183 
184  ///
185  /**
186  The index of the high vof.
187  This = -1 if the face is set to be a boundary
188  face on the high side of the domain.
189  */
191 
192  ///direction of the face.
194 
195  ///
196  /**
197  true if one of the define functions has been called.
198  */
200 
201  ///
202  /**
203  true if the face is constructed
204  using the boundary face constructor
205  */
207 
208 };
209 
210 /** Friend of class FaceIndex */
211 inline
212 bool operator<( const FaceIndex& f1, const FaceIndex& f2 )
213 {
214  if ( f1.m_loiv.lexLT( f2.m_loiv ) )
215  {
216  return true;
217  }
218  else
219  if ( f2.m_loiv.lexLT( f1.m_loiv ) )
220  {
221  return false;
222  }
223  else
224  if ( f1.m_loIndex < f2.m_loIndex )
225  {
226  return true;
227  }
228  else
229  if ( f2.m_loIndex < f1.m_loIndex )
230  {
231  return false;
232  }
233  else
234  if ( f1.m_hiiv.lexLT( f2.m_hiiv ) )
235  {
236  return true;
237  }
238  else
239  if ( f2.m_hiiv.lexLT( f1.m_hiiv ) )
240  {
241  return false;
242  }
243  else
244  if ( f1.m_hiIndex < f2.m_hiIndex )
245  {
246  return true;
247  }
248  else
249  if ( f2.m_hiIndex < f1.m_hiIndex )
250  {
251  return false;
252  }
253  else
254  if ( f1.m_direction < f2.m_direction )
255  {
256  return true;
257  }
258  else
259  if ( f2.m_direction < f1.m_direction )
260  {
261  return false;
262  }
263  else
264  if ( f1.m_isBoundary && (!f2.m_isBoundary) )
265  {
266  return true;
267  }
268  else
269  if ( (!f1.m_isBoundary) && f2.m_isBoundary )
270  {
271  return false;
272  }
273 
274  return false;
275 }
276 
277 
278 template < >
279 int linearSize(const FaceIndex& findex);
280 
281 //FaceIndex specialization of linearIn
282 template < >
283 void linearIn(FaceIndex& a_outputT, const void* const inBuf);
284 
285 //FaceIndex specialization of linearOut
286 template < >
287 void linearOut(void* const a_outBuf, const FaceIndex& a_inputT);
288 
289 #include "NamespaceFooter.H"
290 #endif
int linearSize(const FaceIndex &findex)
IntVect m_loiv
the intvect of the low vof
Definition: FaceIndex.H:169
Definition: FaceIndex.H:28
bool operator==(const FaceIndex &a_facein) const
void shift(const IntVect &a_iv)
for stencil gymnastics
Definition: FaceIndex.H:158
friend ostream & operator<<(ostream &out, const FaceIndex &fi)
void linearOut(void *const a_outBuf, const FaceIndex &a_inputT)
const IntVect & gridIndex(const Side::LoHiSide &a_sd) const
bool m_isBoundary
Definition: FaceIndex.H:206
int m_hiIndex
Definition: FaceIndex.H:190
index for other indicies to inherit
Definition: BaseIndex.H:26
static size_t lo_offset
Definition: FaceIndex.H:154
const int & direction() const
IntVect m_hiiv
the intvect of the high vof
Definition: FaceIndex.H:174
const bool & isBoundary() const
FaceIndex & operator=(const FaceIndex &a_facein)
LoHiSide
Definition: LoHiSide.H:27
int m_direction
direction of the face.
Definition: FaceIndex.H:193
static int initializeOffsets()
static size_t rest_offset
Definition: FaceIndex.H:154
bool operator!=(const FaceIndex &a_facein) const
void define(const VolIndex &a_vof1, const VolIndex &a_vof2, const int &a_direction)
An integer Vector in SpaceDim-dimensional space.
Definition: CHArray.H:42
const bool & isDefined() const
int m_loIndex
Definition: FaceIndex.H:182
VolIndex getVoF(const Side::LoHiSide &a_sd) const
Volume of Fluid Index.
Definition: VolIndex.H:31
void linearIn(FaceIndex &a_outputT, const void *const inBuf)
int faceSign(const VolIndex &a_vof) const
static size_t hi_offset
Definition: FaceIndex.H:154
const int & cellIndex(const Side::LoHiSide &a_sd) const
bool m_isDefined
Definition: FaceIndex.H:199
friend bool operator<(const FaceIndex &f1, const FaceIndex &f2)
Definition: FaceIndex.H:212
bool lexLT(const IntVect &s) const
Definition: IntVect.H:898