00001 #ifdef CH_LANG_CC 00002 /* 00003 * _______ __ 00004 * / ___/ / ___ __ _ / / ___ 00005 * / /__/ _ \/ _ \/ V \/ _ \/ _ \ 00006 * \___/_//_/\___/_/_/_/_.__/\___/ 00007 * Please refer to Copyright.txt, in Chombo's root directory. 00008 */ 00009 #endif 00010 00011 #ifndef _CFIVS_H_ 00012 #define _CFIVS_H_ 00013 00014 #include "REAL.H" 00015 #include "DataIndex.H" 00016 #include "IntVect.H" 00017 #include "Box.H" 00018 #include "IntVectSet.H" 00019 #include "NamespaceHeader.H" 00020 00021 //--Forward declarations 00022 00023 class DisjointBoxLayout; 00024 class ProblemDomain; 00025 class LoHiSide; 00026 00027 00028 /// Internal class to find parts of a box outside the valid region of a level 00029 /** 00030 * Typically used to find the ghost cells between this and a coarser level. 00031 * These cells are represented by an IntVectSet and, if possible, packed into 00032 * a box. This class should only be used through a CFRegion which breaks down 00033 * the parts of a box into regions that have a high probability of being 00034 * packed. 00035 */ 00036 00037 class CFIVS 00038 { 00039 public: 00040 /// Null constructor 00041 CFIVS(); 00042 00043 /// Destructor 00044 ~CFIVS(); 00045 00046 /// Explicit define based on an IntVectSet 00047 // Using this means the cells to store in the IVS have been identified 00048 // elsewhere! 00049 void define(const IntVectSet & a_IVS); 00050 00051 /// General define for any box using NeighborIterators 00052 // WARNING! To use this, neighbors must be defined in the DBL. Otherwise 00053 // continue to use the legacy define functions. 00054 void define(const DataIndex& a_dataIndex, 00055 const DisjointBoxLayout& a_grids, 00056 const Box& a_ghostBox); 00057 00058 /// Coarsen the stored cells 00059 void coarsen(int a_ref); 00060 00061 /// Returns packed box for when isPacked() is true. 00062 const Box& packedBox() const; 00063 00064 /// Returns minbox for when isPacked() is false (but can also be used if true) 00065 const Box& minBox() const; 00066 00067 /// Get the set of IntVects 00068 const IntVectSet& getIVS() const; 00069 00070 /// Returns "true" if this CF IntVectSet can be represented as a simple Box. 00071 bool isPacked() const; 00072 00073 /// Returns "true" if the defined IVS is empty 00074 bool isEmpty() const; 00075 00076 /// Returns "true" if the object has been defined 00077 bool isDefined() const; 00078 00079 protected: 00080 // For internal use 00081 void setDefaultValues(); 00082 00083 /// Decrement counts (during redefine) 00084 void decrementCounts(); 00085 00086 /// Pack the IVS 00087 void packIVS(); 00088 00089 public: 00090 static long long s_packCount, s_sparseCount; 00091 00092 protected: 00093 IntVectSet m_IVS; ///< IntVects that are outside the level 00094 Box m_packedBox; ///< If m_packed is true, the Box with 00095 ///< which the coarse-fine IntVectSet can 00096 ///< be represented. If m_packed is 00097 ///< false, same as m_IVS.minBox(). 00098 bool m_packed; ///< Can the coarse-fine IntVectSet be 00099 ///< represented as a Box? Set to false 00100 ///< if the IVS is empty 00101 bool m_empty; ///< Is the IVS empty - cached here for 00102 ///< fast lookup 00103 bool m_defined; ///< Has this object been defined? 00104 00105 00106 /*============================================================================*/ 00107 /** \name Legacy members 00108 * 00109 * New uses of CFIVS should avoid these routines 00110 *//*=========================================================================*/ 00111 00112 public: 00113 //@{ 00114 /// (Deprecated) constructor 00115 /** The ProblemDomain class has replaced the Box domain 00116 Replaces Box domain with a ProblemDomain and calls define fn. 00117 */ 00118 CFIVS(const Box& a_domain, 00119 const Box& a_boxIn, 00120 const DisjointBoxLayout& a_fineBoxes, 00121 int a_direction, 00122 Side::LoHiSide a_hiorlo); 00123 00124 /// (Deprecated) full constructor 00125 /** CFRegion should specify the region and call general define for a box 00126 Calls corresponding define function. 00127 */ 00128 CFIVS(const ProblemDomain& a_domain, 00129 const Box& a_boxIn, 00130 const DisjointBoxLayout& a_fineBoxes, 00131 int a_direction, 00132 Side::LoHiSide a_hiorlo); 00133 00134 /// (Deprecated) define function 00135 /** CFRegion should specify the region and call general define for a box 00136 Replaces Box domain with a ProblemDomain and calls define fn. 00137 */ 00138 void define(const Box& a_domain, 00139 const Box& a_boxIn, 00140 const DisjointBoxLayout& a_fineBoxes, 00141 int a_direction, 00142 Side::LoHiSide a_hiorlo); 00143 00144 /// (Deprecated) full define function 00145 /** CFRegion should specify the region and call general define for a box 00146 */ 00147 void define (const ProblemDomain& a_domain, /// Problem domain at the fine level 00148 const Box& a_boxIn, /// fine-level grid box 00149 const DisjointBoxLayout& a_fineBoxes, /// fine-level grids 00150 int a_direction, /// direction of the face of interest 00151 Side::LoHiSide a_hiorlo); /// is the face on the hi or lo side of the box? 00152 00153 /// (Deprecated) faster define function. Requires the use of CFStencil::buildPeriodicVector static function. 00154 /** CFRegion should specify the region and call general define for a box 00155 */ 00156 void define(const ProblemDomain& a_domain, 00157 const Box& a_boxIn, 00158 const Vector<Box>& a_periodicfineBoxes, 00159 int a_direction, 00160 Side::LoHiSide a_hiorlo); 00161 00162 /// (Deprecated) Updated define function that uses NeighborIterators instead of traversing the 00163 /// entire list of boxes. 00164 /** CFRegion should specify the region and call general define for a box. 00165 * However, at least this one is using the recommended technology, Neighbor 00166 * iterators. 00167 */ 00168 void define(const ProblemDomain& a_domain, 00169 const DataIndex& a_dataIndex, 00170 const DisjointBoxLayout& a_grids, 00171 int a_direction, 00172 Side::LoHiSide a_hiorlo); 00173 00174 /// Get fine intvects which need to be interpolated. 00175 /** Renamed to getIVS() since CFIV has a general purpose now. 00176 * This will be empty if isEmpty() returns true 00177 */ 00178 const IntVectSet& getFineIVS() const; 00179 //@} 00180 }; 00181 00182 // Returns packed box for when isPacked() is true. 00183 inline const Box& CFIVS::packedBox() const 00184 { 00185 CH_assert(isPacked()); 00186 return m_packedBox; 00187 } 00188 00189 // Returns minbox for when isPacked() is false (but can also be used if true) 00190 inline const Box& CFIVS::minBox() const 00191 { 00192 return m_packedBox; 00193 } 00194 00195 // Get the set of IntVects 00196 inline const IntVectSet& 00197 CFIVS::getIVS() const 00198 { 00199 return m_IVS; 00200 } 00201 00202 // Get fine intvects which need to be interpolated (deprecated). 00203 inline const IntVectSet& 00204 CFIVS::getFineIVS() const 00205 { 00206 return m_IVS; 00207 } 00208 00209 // Returns "true" if this CF IntVectSet can be represented as a simple Box. 00210 /** Returns 'true' if this coarse-fine IntVectSet can be represented 00211 as just a Box, ie. a user can perform a dense computation instead of 00212 a pointwise calculation using IVSIterator. 00213 */ 00214 inline bool 00215 CFIVS::isPacked() const 00216 { 00217 CH_assert(m_defined); 00218 return m_packed; 00219 } 00220 00221 // Returns "true" if the defined IVS is empty 00222 inline bool 00223 CFIVS::isEmpty() const 00224 { 00225 CH_assert(m_defined); 00226 return m_empty; 00227 } 00228 00229 // Returns "true" if the object has been defined 00230 inline bool 00231 CFIVS::isDefined() const 00232 { 00233 return m_defined; 00234 } 00235 00236 #include "NamespaceFooter.H" 00237 #endif