Chombo + EB + MF  3.2
VolIndex.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 _VOLINDEX_H_
14 #define _VOLINDEX_H_
15 
16 #include "REAL.H"
17 #include "IntVect.H"
18 #include "SPMD.H"
19 #include "BaseIndex.H"
20 #include "NamespaceHeader.H"
21 
22 /// Volume of Fluid Index
23 /**
24  VolIndex is a very lightweight object
25  to be used to distinguish between volumes of
26  fluid in a cell. We use VolIndex for
27  array indexing. Non-trivial constructors
28  are all private because only EBISBox
29  is supposed to make valid volume indicies.
30 */
31 class VolIndex: public BaseIndex
32 {
33 public:
34  ///
35  VolIndex();
36 
37  virtual ~VolIndex();
38 
39  ///
40  //VolIndex& operator= (const VolIndex& a_vofin);
41 
42  ///
43  inline
44  bool operator== (const VolIndex& a_vofin) const;
45 
46  ///
47  inline
48  const IntVect& gridIndex() const;
49 
50  ///
51  inline
52  int cellIndex() const;
53 
54  ///
55  inline
56  bool isDefined() const;
57 
58  ///
59  // VolIndex(const VolIndex& a_vofin);
60 
61  ///
62  void define(const VolIndex& a_vofin);
63 
64  ///
65  inline
66  VolIndex(const IntVect& a_ix,const int& a_vofID);
67 
68  ///
69  inline
70  void define(const IntVect& a_ix,const int& a_vofID);
71 
72  inline
73  bool operator<(const VolIndex& rhs) const;
74 
75  inline
76  bool operator!=(const VolIndex& rhs) const;
77  /**
78  /name linearization routines
79  */
80  /*@{*/
81  int linearSize() const;
82  void linearOut(void* const a_outBuf) const;
83  void linearIn(const void* const inBuf);
84  /*@}*/
85 
86  // not for users
87  static size_t iv_offset, index_offset;
88  static int initializeOffsets();
89 
90  ///for stencil gymnastics
91  void shift(const IntVect& a_iv)
92  {
93  m_iv += a_iv;
94  }
95 
96 private:
97 
98  //cell of the VolIndex
100 
101  //which VoF in the cell (0 to nVoF-1)
103 
105 };
106 
107 std::ostream& operator<< (std::ostream& os,
108  const VolIndex& iv);
109 
110 inline bool VolIndex::operator<(const VolIndex& rhs) const
111 {
112  if (m_iv.lexLT(rhs.m_iv))
113  {
114  return true;
115  }
116  if (m_iv == rhs.m_iv)
117  {
118  return m_cellIndex < rhs.m_cellIndex;
119  }
120  return false;
121 }
122 /*****************************************/
123 inline
124 const IntVect&
126 {
127  return m_iv;
128 }
129 
130 /*****************************************/
131 inline
132 int
134 {
135  return m_cellIndex;
136 }
137 /*****************************************/
138 inline void
139 VolIndex::define(const IntVect& a_ix,const int& a_vofID)
140 {
141  m_isDefined = true;
142  m_iv = a_ix;
143  m_cellIndex = a_vofID;
144 }
145 /*****************************************/
146 inline
147 VolIndex::VolIndex(const IntVect& a_ix,const int& a_vofID)
148  :BaseIndex(),m_iv(a_ix), m_cellIndex(a_vofID), m_isDefined(true)
149 {
150  ;
151 }
152 /*****************************************/
153 inline bool
155 {
156  return m_isDefined;
157 }
158 
159 /*****************************************/
160 inline
162 :m_iv(IntVect::Zero), m_cellIndex(-1), m_isDefined(false)
163 {
164  //set index to bogus number to make undefined
165  //ones catchable.
166 
167 }
168 
169 inline bool
170 VolIndex::operator== (const VolIndex& a_vofin) const
171 {
172  return ((m_iv == a_vofin.m_iv)&&
173  (m_cellIndex == a_vofin.m_cellIndex));
174 }
175 
176 inline bool
178 {
179  return !(*this == rhs);
180 }
181 
182 #include "NamespaceFooter.H"
183 #endif
std::ostream & operator<<(std::ostream &os, const VolIndex &iv)
bool operator<(const VolIndex &rhs) const
Definition: VolIndex.H:110
IntVect m_iv
Definition: VolIndex.H:99
const IntVect & gridIndex() const
Definition: VolIndex.H:125
int m_cellIndex
Definition: VolIndex.H:102
bool operator==(const VolIndex &a_vofin) const
Definition: VolIndex.H:170
index for other indicies to inherit
Definition: BaseIndex.H:26
virtual ~VolIndex()
VolIndex()
Definition: VolIndex.H:161
bool operator!=(const VolIndex &rhs) const
Definition: VolIndex.H:177
static size_t index_offset
Definition: VolIndex.H:87
void linearIn(const void *const inBuf)
void linearOut(void *const a_outBuf) const
void define(const VolIndex &a_vofin)
static int initializeOffsets()
bool isDefined() const
Definition: VolIndex.H:154
int linearSize() const
int cellIndex() const
Definition: VolIndex.H:133
An integer Vector in SpaceDim-dimensional space.
Definition: CHArray.H:42
Volume of Fluid Index.
Definition: VolIndex.H:31
static size_t iv_offset
Definition: VolIndex.H:87
bool m_isDefined
Definition: VolIndex.H:104
void shift(const IntVect &a_iv)
for stencil gymnastics
Definition: VolIndex.H:91
bool lexLT(const IntVect &s) const
Definition: IntVect.H:917