Chombo + EB  3.0
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 private:
157 
158  ///the intvect of the low vof
159  /**
160  */
162 
163  ///the intvect of the high vof
164  /**
165  */
167 
168  ///
169  /**
170  The index of the low vof.
171  This = -1 if the face is set to be a boundary
172  face on the low side of the domain.
173  */
175 
176  ///
177  /**
178  The index of the high vof.
179  This = -1 if the face is set to be a boundary
180  face on the high side of the domain.
181  */
183 
184  ///direction of the face.
186 
187  ///
188  /**
189  true if one of the define functions has been called.
190  */
192 
193  ///
194  /**
195  true if the face is constructed
196  using the boundary face constructor
197  */
199 
200 };
201 
202 /** Friend of class FaceIndex */
203 inline
204 bool operator<( const FaceIndex& f1, const FaceIndex& f2 )
205 {
206  if ( f1.m_loiv.lexLT( f2.m_loiv ) )
207  {
208  return true;
209  }
210  else
211  if ( f2.m_loiv.lexLT( f1.m_loiv ) )
212  {
213  return false;
214  }
215  else
216  if ( f1.m_loIndex < f2.m_loIndex )
217  {
218  return true;
219  }
220  else
221  if ( f2.m_loIndex < f1.m_loIndex )
222  {
223  return false;
224  }
225  else
226  if ( f1.m_hiiv.lexLT( f2.m_hiiv ) )
227  {
228  return true;
229  }
230  else
231  if ( f2.m_hiiv.lexLT( f1.m_hiiv ) )
232  {
233  return false;
234  }
235  else
236  if ( f1.m_hiIndex < f2.m_hiIndex )
237  {
238  return true;
239  }
240  else
241  if ( f2.m_hiIndex < f1.m_hiIndex )
242  {
243  return false;
244  }
245  else
246  if ( f1.m_direction < f2.m_direction )
247  {
248  return true;
249  }
250  else
251  if ( f2.m_direction < f1.m_direction )
252  {
253  return false;
254  }
255  else
256  if ( f1.m_isBoundary && (!f2.m_isBoundary) )
257  {
258  return true;
259  }
260  else
261  if ( (!f1.m_isBoundary) && f2.m_isBoundary )
262  {
263  return false;
264  }
265 
266  return false;
267 }
268 
269 
270 template < >
271 int linearSize(const FaceIndex& findex);
272 
273 //FaceIndex specialization of linearIn
274 template < >
275 void linearIn(FaceIndex& a_outputT, const void* const inBuf);
276 
277 //FaceIndex specialization of linearOut
278 template < >
279 void linearOut(void* const a_outBuf, const FaceIndex& a_inputT);
280 
281 #include "NamespaceFooter.H"
282 #endif
int linearSize(const FaceIndex &findex)
IntVect m_loiv
the intvect of the low vof
Definition: FaceIndex.H:161
Definition: FaceIndex.H:28
bool operator==(const FaceIndex &a_facein) const
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:198
int m_hiIndex
Definition: FaceIndex.H:182
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:166
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:185
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:174
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:191
friend bool operator<(const FaceIndex &f1, const FaceIndex &f2)
Definition: FaceIndex.H:204
bool lexLT(const IntVect &s) const
Definition: IntVect.H:814