Chombo + EB  3.0
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 private:
91 
92  //cell of the VolIndex
94 
95  //which VoF in the cell (0 to nVoF-1)
97 
99 };
100 
101 std::ostream& operator<< (std::ostream& os,
102  const VolIndex& iv);
103 
104 inline bool VolIndex::operator<(const VolIndex& rhs) const
105 {
106  if (m_iv.lexLT(rhs.m_iv))
107  {
108  return true;
109  }
110  if (m_iv == rhs.m_iv)
111  {
112  return m_cellIndex < rhs.m_cellIndex;
113  }
114  return false;
115 }
116 /*****************************************/
117 inline
118 const IntVect&
120 {
121  return m_iv;
122 }
123 
124 /*****************************************/
125 inline
126 int
128 {
129  return m_cellIndex;
130 }
131 /*****************************************/
132 inline void
133 VolIndex::define(const IntVect& a_ix,const int& a_vofID)
134 {
135  m_isDefined = true;
136  m_iv = a_ix;
137  m_cellIndex = a_vofID;
138 }
139 /*****************************************/
140 inline
141 VolIndex::VolIndex(const IntVect& a_ix,const int& a_vofID)
142  :BaseIndex(),m_iv(a_ix), m_cellIndex(a_vofID), m_isDefined(true)
143 {
144  ;
145 }
146 /*****************************************/
147 inline bool
149 {
150  return m_isDefined;
151 }
152 
153 /*****************************************/
154 inline
156 :m_iv(IntVect::Zero), m_cellIndex(-1), m_isDefined(false)
157 {
158  //set index to bogus number to make undefined
159  //ones catchable.
160 
161 }
162 
163 inline bool
164 VolIndex::operator== (const VolIndex& a_vofin) const
165 {
166  return ((m_iv == a_vofin.m_iv)&&
167  (m_cellIndex == a_vofin.m_cellIndex));
168 }
169 
170 inline bool
172 {
173  return !(*this == rhs);
174 }
175 
176 #include "NamespaceFooter.H"
177 #endif
std::ostream & operator<<(std::ostream &os, const VolIndex &iv)
bool operator<(const VolIndex &rhs) const
Definition: VolIndex.H:104
IntVect m_iv
Definition: VolIndex.H:93
const IntVect & gridIndex() const
Definition: VolIndex.H:119
int m_cellIndex
Definition: VolIndex.H:96
bool operator==(const VolIndex &a_vofin) const
Definition: VolIndex.H:164
index for other indicies to inherit
Definition: BaseIndex.H:26
virtual ~VolIndex()
VolIndex()
Definition: VolIndex.H:155
bool operator!=(const VolIndex &rhs) const
Definition: VolIndex.H:171
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:148
int linearSize() const
int cellIndex() const
Definition: VolIndex.H:127
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:98
bool lexLT(const IntVect &s) const
Definition: IntVect.H:814