00001 #ifdef CH_LANG_CC
00002
00003
00004
00005
00006
00007
00008
00009 #endif
00010
00011 #ifndef _EBAMRTESTCOMMON_H_
00012 #define _EBAMRTESTCOMMON_H_
00013
00014 #include "IntVect.H"
00015 #include "IntVectSet.H"
00016 #include "Box.H"
00017 #include "DisjointBoxLayout.H"
00018 #include "ParmParse.H"
00019 #include "EBIndexSpace.H"
00020 #include "EBISLayout.H"
00021 #include "BoxIterator.H"
00022 #include "ParmParse.H"
00023 #include "BRMeshRefine.H"
00024 #include "LoadBalance.H"
00025 #include "GeometryShop.H"
00026 #include "PolyGeom.H"
00027 #include "LevelData.H"
00028 #include "EBCellFAB.H"
00029 #include "EBCellFactory.H"
00030 #include "VoFIterator.H"
00031 #include "EBArith.H"
00032 #include "AllRegularService.H"
00033 #include "PlaneIF.H"
00034 #include "SphereIF.H"
00035 #include "MultiSphereIF.H"
00036 #include "EBTensorCFInterp.H"
00037 #include "EBAMRIO.H"
00038 #include "EBLevelGrid.H"
00039
00040 #include "NamespaceHeader.H"
00041
00042
00043
00044
00045 class BaseAnalytic
00046 {
00047 public:
00048
00049
00050
00051 virtual void veloVal(Real a_vel[SpaceDim], const RealVect& a_point) = 0;
00052
00053
00054
00055
00056 virtual void gradVal(Real a_grad[SpaceDim*SpaceDim], const RealVect& a_point) = 0;
00057
00058 BaseAnalytic()
00059 {;}
00060
00061 virtual ~BaseAnalytic()
00062 {;}
00063 };
00064
00065
00066
00067
00068 class LinearAnalytic: public BaseAnalytic
00069 {
00070 public:
00071
00072
00073
00074 virtual void veloVal(Real a_vel[SpaceDim], const RealVect& a_point)
00075 {
00076 for (int idir = 0; idir < SpaceDim; idir++)
00077 {
00078 a_vel[idir] = 0;
00079 for (int jdir = 0; jdir < SpaceDim; jdir++)
00080 {
00081 a_vel[idir] += m_coeff[jdir]*a_point[jdir];
00082 }
00083 }
00084 }
00085
00086
00087
00088
00089 virtual void gradVal(Real a_grad[SpaceDim*SpaceDim], const RealVect& a_point)
00090 {
00091 for (int idir = 0; idir < SpaceDim; idir++)
00092 {
00093 for (int jdir = 0; jdir < SpaceDim; jdir++)
00094 {
00095 int iindex = TensorCFInterp::gradIndex(idir, jdir);
00096 a_grad[iindex] = m_coeff[jdir];
00097 }
00098 }
00099
00100 }
00101 LinearAnalytic()
00102 {
00103 for (int idir = 0; idir < SpaceDim; idir++)
00104 {
00105 m_coeff[idir] = Real(idir + 1);
00106 }
00107 }
00108 virtual ~LinearAnalytic()
00109 {;}
00110
00111 RealVect m_coeff;
00112 };
00113
00114
00115
00116
00117 class ConstAnalytic: public BaseAnalytic
00118 {
00119 public:
00120
00121
00122
00123 virtual void veloVal(Real a_vel[SpaceDim], const RealVect& a_point)
00124 {
00125 for (int idir = 0; idir < SpaceDim; idir++)
00126 {
00127 for (int jdir = 0; jdir < SpaceDim; jdir++)
00128 {
00129 a_vel[idir] = m_coeff[jdir];
00130 }
00131 }
00132 }
00133
00134
00135
00136
00137 virtual void gradVal(Real a_grad[SpaceDim*SpaceDim], const RealVect& a_point)
00138 {
00139 for (int ivar = 0; ivar < SpaceDim; ivar++)
00140 {
00141 for (int jdir = 0; jdir < SpaceDim; jdir++)
00142 {
00143 int iindex = TensorCFInterp::gradIndex(ivar, jdir);
00144 a_grad[iindex] = 0.;
00145 }
00146 }
00147
00148 }
00149 ConstAnalytic()
00150 {
00151 for (int idir = 0; idir < SpaceDim; idir++)
00152 {
00153 m_coeff[idir] = Real(idir + 1);
00154 }
00155 }
00156 virtual ~ConstAnalytic()
00157 {;}
00158
00159 RealVect m_coeff;
00160 };
00161
00162
00163
00164
00165
00166 class QuadAnalytic: public BaseAnalytic
00167 {
00168 public:
00169
00170
00171
00172 virtual void veloVal(Real a_vel[SpaceDim], const RealVect& a_point)
00173 {
00174 for (int ivar = 0; ivar < SpaceDim; ivar++)
00175 {
00176 a_vel[ivar] = 0;
00177 for (int jdir = 0; jdir < SpaceDim; jdir++)
00178 {
00179 a_vel[ivar] += m_coeff[jdir]*a_point[jdir]*a_point[jdir];
00180 }
00181 }
00182 }
00183
00184
00185
00186
00187 virtual void gradVal(Real a_grad[SpaceDim*SpaceDim], const RealVect& a_point)
00188 {
00189 for (int ivar = 0; ivar < SpaceDim; ivar++)
00190 {
00191 for (int jdir = 0; jdir < SpaceDim; jdir++)
00192 {
00193 int iindex = TensorCFInterp::gradIndex(ivar, jdir);
00194 a_grad[iindex] = 2.*m_coeff[jdir]*a_point[jdir];
00195 }
00196 }
00197
00198 }
00199
00200
00201
00202
00203 QuadAnalytic()
00204 {
00205 for (int ivar = 0; ivar < SpaceDim; ivar++)
00206 {
00207 m_coeff[ivar] = Real(ivar + 1);
00208 }
00209 }
00210 virtual ~QuadAnalytic()
00211 {;}
00212
00213 RealVect m_coeff;
00214 };
00215
00216 class CubeAnalytic: public BaseAnalytic
00217 {
00218 public:
00219
00220
00221
00222 virtual void veloVal(Real a_vel[SpaceDim], const RealVect& a_point)
00223 {
00224 for (int ivar = 0; ivar < SpaceDim; ivar++)
00225 {
00226 for (int jdir = 0; jdir < SpaceDim; jdir++)
00227 {
00228 a_vel[ivar] += m_coeff[jdir]*a_point[jdir]*a_point[jdir]*a_point[jdir];
00229 }
00230 }
00231 }
00232
00233
00234
00235
00236 virtual void gradVal(Real a_grad[SpaceDim*SpaceDim], const RealVect& a_point)
00237 {
00238 for (int ivar = 0; ivar < SpaceDim; ivar++)
00239 {
00240 for (int jdir = 0; jdir < SpaceDim; jdir++)
00241 {
00242 int iindex = TensorCFInterp::gradIndex(ivar, jdir);
00243 a_grad[iindex] = 3.*m_coeff[jdir]*a_point[jdir]*a_point[jdir];
00244 }
00245 }
00246
00247 }
00248
00249 CubeAnalytic()
00250 {
00251 for (int ivar = 0; ivar < SpaceDim; ivar++)
00252 {
00253 m_coeff[ivar] = Real(ivar + 1);
00254 }
00255 }
00256 virtual ~CubeAnalytic()
00257 {;}
00258
00259 RealVect m_coeff;
00260 };
00261
00262
00263
00264
00265 class EBAMRTestCommon
00266 {
00267 public:
00268
00269
00270
00271 static int compareError(const LevelData<EBCellFAB>& a_errorFine,
00272 const EBISLayout& a_ebislFine,
00273 const DisjointBoxLayout& a_gridsFine,
00274 const Box& a_domainFine,
00275 const LevelData<EBCellFAB>& a_errorCoar,
00276 const EBISLayout& a_ebislCoar,
00277 const DisjointBoxLayout& a_gridsCoar,
00278 const Box& a_domainCoar);
00279
00280
00281
00282
00283 static int makeEBISL(EBISLayout& a_ebisl,
00284 const DisjointBoxLayout& a_grids,
00285 const Box& a_domain,
00286 const int& a_nghost);
00287
00288
00289
00290
00291 static int
00292 makeHalfLayouts(DisjointBoxLayout& a_gridsFine,
00293 EBISLayout& a_ebislFine,
00294 DisjointBoxLayout& a_gridsCoar,
00295 EBISLayout& a_ebislCoar,
00296 const Box& a_domainFine,
00297 const Box& a_domainCoar,
00298 int a_refrat, int a_halfDir);
00299
00300
00301
00302
00303 static int makeGeometry(Box& a_domain,
00304 RealVect& a_dx);
00305
00306
00307
00308
00309 static int
00310 checkForZero(const LevelData<EBCellFAB>& a_errorVelo,
00311 const DisjointBoxLayout& a_gridsFine,
00312 const EBISLayout& a_ebislFine,
00313 const Box& a_domainFine,
00314 string a_funcname);
00315
00316
00317
00318
00319
00320 static void
00321 outputError(const LevelData<EBCellFAB>& a_errorFine,
00322 const LevelData<EBCellFAB>& a_errorCoar,
00323 const DisjointBoxLayout& a_gridsFine,
00324 const DisjointBoxLayout& a_gridsCoar,
00325 const Box& a_domainFine,
00326 const Box& a_domainCoar,
00327 const string& a_fileFine,
00328 const string& a_fileCoar);
00329 };
00330
00331 #include "NamespaceFooter.H"
00332
00333 #endif