00001 #ifdef CH_LANG_CC
00002
00003
00004
00005
00006
00007
00008
00009 #endif
00010
00011
00012
00013 #ifndef _VOLINDEX_H_
00014 #define _VOLINDEX_H_
00015
00016 #include "REAL.H"
00017 #include "IntVect.H"
00018 #include "SPMD.H"
00019 #include "BaseIndex.H"
00020 #include "NamespaceHeader.H"
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031 class VolIndex: public BaseIndex
00032 {
00033 public:
00034
00035 VolIndex();
00036
00037 virtual ~VolIndex();
00038
00039
00040
00041
00042
00043 inline
00044 bool operator== (const VolIndex& a_vofin) const;
00045
00046
00047 inline
00048 const IntVect& gridIndex() const;
00049
00050
00051 inline
00052 int cellIndex() const;
00053
00054
00055 inline
00056 bool isDefined() const;
00057
00058
00059
00060
00061
00062 void define(const VolIndex& a_vofin);
00063
00064
00065 inline
00066 VolIndex(const IntVect& a_ix,const int& a_vofID);
00067
00068
00069 inline
00070 void define(const IntVect& a_ix,const int& a_vofID);
00071
00072 inline
00073 bool operator<(const VolIndex& rhs) const;
00074
00075 inline
00076 bool operator!=(const VolIndex& rhs) const;
00077
00078
00079
00080
00081 int linearSize() const;
00082 void linearOut(void* const a_outBuf) const;
00083 void linearIn(const void* const inBuf);
00084
00085
00086
00087 static size_t iv_offset, index_offset;
00088 static int initializeOffsets();
00089
00090 private:
00091
00092
00093 IntVect m_iv;
00094
00095
00096 int m_cellIndex;
00097
00098 bool m_isDefined;
00099 };
00100
00101 std::ostream& operator<< (std::ostream& os,
00102 const VolIndex& iv);
00103
00104 inline bool VolIndex::operator<(const VolIndex& rhs) const
00105 {
00106 if (m_iv.lexLT(rhs.m_iv))
00107 {
00108 return true;
00109 }
00110 if (m_iv == rhs.m_iv)
00111 {
00112 return m_cellIndex < rhs.m_cellIndex;
00113 }
00114 return false;
00115 }
00116
00117 inline
00118 const IntVect&
00119 VolIndex::gridIndex() const
00120 {
00121 return m_iv;
00122 }
00123
00124
00125 inline
00126 int
00127 VolIndex::cellIndex() const
00128 {
00129 return m_cellIndex;
00130 }
00131
00132 inline void
00133 VolIndex::define(const IntVect& a_ix,const int& a_vofID)
00134 {
00135 m_isDefined = true;
00136 m_iv = a_ix;
00137 m_cellIndex = a_vofID;
00138 }
00139
00140 inline
00141 VolIndex::VolIndex(const IntVect& a_ix,const int& a_vofID)
00142 :BaseIndex(),m_iv(a_ix), m_cellIndex(a_vofID), m_isDefined(true)
00143 {
00144 ;
00145 }
00146
00147 inline bool
00148 VolIndex::isDefined() const
00149 {
00150 return m_isDefined;
00151 }
00152
00153
00154 inline
00155 VolIndex::VolIndex()
00156 :m_iv(IntVect::Zero), m_cellIndex(-1), m_isDefined(false)
00157 {
00158
00159
00160
00161 }
00162
00163 inline bool
00164 VolIndex::operator== (const VolIndex& a_vofin) const
00165 {
00166 return ((m_iv == a_vofin.m_iv)&&
00167 (m_cellIndex == a_vofin.m_cellIndex));
00168 }
00169
00170 inline bool
00171 VolIndex::operator!=(const VolIndex& rhs) const
00172 {
00173 return !(*this == rhs);
00174 }
00175
00176 #include "NamespaceFooter.H"
00177 #endif