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 _NODECOARSEAVERAGE_H_ 00012 #define _NODECOARSEAVERAGE_H_ 00013 00014 #include "REAL.H" 00015 #include "BaseFab.H" 00016 #include "IntVectSet.H" 00017 #include "NodeFArrayBox.H" 00018 #include "LevelData.H" 00019 #include "DisjointBoxLayout.H" 00020 #include "BitSet.H" 00021 #include "NamespaceHeader.H" 00022 00023 /// Replaces coarse-level data with an average of fine-level data 00024 00025 class NodeCoarseAverage 00026 /** 00027 This class replaces data at a coarse level of refinement with an 00028 average of data at a finer level of refinement, in areas where fine 00029 data is present. Coarse-level data is not modified where fine-level 00030 data is not present. 00031 */ 00032 { 00033 public: 00034 00035 /** 00036 \name Constructors, destructor and defines 00037 */ 00038 /*@{*/ 00039 00040 /// 00041 /** Default constructor. User must subsequently call define(). 00042 */ 00043 NodeCoarseAverage(); 00044 00045 /// 00046 /** Defining constructor. Calls define() function with 00047 identical arguments. 00048 */ 00049 NodeCoarseAverage(const DisjointBoxLayout& a_gridsFine, 00050 const DisjointBoxLayout& a_gridsCoarse, 00051 int a_numcomps, 00052 int a_refRatio, 00053 const ProblemDomain& a_domainFine); 00054 00055 /// 00056 /** Defining constructor. Calls define() function with 00057 identical arguments. 00058 */ 00059 NodeCoarseAverage(const DisjointBoxLayout& a_gridsFine, 00060 const DisjointBoxLayout& a_gridsCoarse, 00061 int a_numcomps, 00062 int a_refRatio, 00063 const Box& a_domainFine); 00064 00065 /// 00066 /** Defining constructor. Calls define() function with 00067 identical arguments. 00068 */ 00069 NodeCoarseAverage(const DisjointBoxLayout& a_gridsCoarse, 00070 int a_numcomps, 00071 int a_refRatio, 00072 const ProblemDomain& a_domainFine); 00073 00074 /// 00075 /** Defining constructor. Calls define() function with 00076 identical arguments. 00077 */ 00078 NodeCoarseAverage(const DisjointBoxLayout& a_gridsCoarse, 00079 int a_numcomps, 00080 int a_refRatio, 00081 const Box& a_domainFine); 00082 00083 /// 00084 /** Destructor. 00085 */ 00086 ~NodeCoarseAverage(); 00087 00088 /// 00089 /** Defines this object. Existing information is overriden. 00090 */ 00091 void define(/// CELL-centered grids at the fine level 00092 const DisjointBoxLayout& a_gridsFine, 00093 /// CELL-centered grids at the coarse level 00094 const DisjointBoxLayout& a_gridsCoarse, 00095 /// number of components of data 00096 int a_numcomps, 00097 /// refinement ratio between the two levels 00098 int a_refRatio, 00099 /// CELL-centered physical domain at the fine level 00100 const ProblemDomain& a_domainFine); 00101 00102 /// 00103 /** Defines this object. Existing information is overriden. 00104 */ 00105 void define(/// CELL-centered grids at the fine level 00106 const DisjointBoxLayout& a_gridsFine, 00107 /// CELL-centered grids at the coarse level 00108 const DisjointBoxLayout& a_gridsCoarse, 00109 /// number of components of data 00110 int a_numcomps, 00111 /// refinement ratio between the two levels 00112 int a_refRatio, 00113 /// CELL-centered physical domain at the fine level 00114 const Box& a_domainFine); 00115 00116 00117 /// 00118 /** Defines this object. Existing information is overriden. 00119 Fine grids are refinements of coarse grids. 00120 */ 00121 void define(/// CELL-centered grids at the coarse level 00122 const DisjointBoxLayout& a_gridsCoarse, 00123 /// number of components of data 00124 int a_numcomps, 00125 /// refinement ratio between the two levels 00126 int a_refRatio, 00127 /// CELL-centered physical domain at the fine level 00128 const ProblemDomain& a_domainFine); 00129 00130 /// 00131 /** Defines this object. Existing information is overriden. 00132 Fine grids are refinements of coarse grids. 00133 */ 00134 void define(/// CELL-centered grids at the coarse level 00135 const DisjointBoxLayout& a_gridsCoarse, 00136 /// number of components of data 00137 int a_numcomps, 00138 /// refinement ratio between the two levels 00139 int a_refRatio, 00140 /// CELL-centered physical domain at the fine level 00141 const Box& a_domainFine); 00142 00143 /*@}*/ 00144 00145 /** 00146 \name Access functions 00147 */ 00148 /*@{*/ 00149 00150 /// 00151 /** Returns <tt>true</tt> if this object was created with the defining 00152 constructor or if define() has been called. 00153 */ 00154 bool isDefined() const; 00155 00156 /// 00157 /** Set whether the solver gives output while solving. 00158 Default is <tt>true</tt>. 00159 */ 00160 void setVerbose( bool a_verbose ); 00161 00162 00163 /*@}*/ 00164 00165 /** 00166 \name Data modification functions 00167 */ 00168 /*@{*/ 00169 00170 /// 00171 /** Replaces coarse data with the average of nearby cells' fine data 00172 on the interior nodes of the coarsened fine-level domain. 00173 Elsewhere, the coarse data is unchanged. 00174 00175 It is an error to call if not this->isDefined(). 00176 00177 The domain of <i>a_fine</i> should be the same as <i>a_gridsFine</i> 00178 specified in the most recent call to define(). 00179 00180 It is expected that the coarse and fine levels' 00181 domains are properly nested. Both <i>a_coarse</i> and <i>a_fine</i> 00182 should have the same number of components specified in 00183 the most recent call to define(). 00184 00185 The fine data is modified only in exchange(). 00186 A work array is also modified. 00187 */ 00188 // this method would like to be const, but the work array is changed. 00189 // this suggests that the work array should not be persistent. 00190 void averageToCoarse(/// coarse data 00191 LevelData<NodeFArrayBox>& a_coarse, 00192 /// fine data, modified in exchange() 00193 LevelData<NodeFArrayBox>& a_fine); 00194 00195 /*@}*/ 00196 00197 protected: 00198 00199 /** has this NodeCoarseAverage object been defined yet? 00200 */ 00201 bool is_defined; 00202 00203 /** flag for verbose output 00204 */ 00205 bool m_verbose; 00206 00207 /** the refinement ratio between the two levels 00208 */ 00209 int m_refRatio; 00210 00211 /** the number of components of data, used in work array 00212 */ 00213 int m_numcomps; 00214 00215 /** CELL-centered physical domain at the coarser level 00216 */ 00217 ProblemDomain m_domainCoarse; 00218 00219 /** box with indices from -<i>m_refRatio</i>/2 to +<i>m_refRatio</i>/2 00220 in all directions 00221 */ 00222 Box m_refbox; 00223 00224 /** weights for coarsening 00225 */ 00226 FArrayBox m_weights; 00227 00228 /** are the fine grids merely refined versions of the coarse grids? 00229 */ 00230 bool m_sameGrids; 00231 00232 /** CELL-centered grids at the finer level, coarsened by <i>m_refRatio</i> 00233 */ 00234 DisjointBoxLayout m_coarsenedGrids; 00235 00236 /** work array for the coarsening of the fine data, based on the layout 00237 <i>m_coarsenedGrids</i> */ 00238 LevelData<NodeFArrayBox> m_coarsenedFine; 00239 00240 /** interior boundary nodes of coarsened finer-level grids, 00241 distributed among the coarser-level grids */ 00242 LayoutData< Vector<IntVectSet> > m_IVSV; 00243 00244 /** whether each section of <i>m_IVSVsame</i> is a complete box 00245 */ 00246 LayoutData< BitSet > m_IVSVfull; 00247 00248 /** interior boundary nodes of coarsened finer-level grids, 00249 distributed among the same grids */ 00250 LayoutData< Vector<IntVectSet> > m_IVSVsame; 00251 }; 00252 00253 #include "NamespaceFooter.H" 00254 #endif