00001 #ifdef CH_LANG_CC
00002
00003
00004
00005
00006
00007
00008
00009 #endif
00010
00011 #ifndef _BCFUNC_H_
00012 #define _BCFUNC_H_
00013
00014 #include "IntVect.H"
00015 #include "RealVect.H"
00016 #include "FArrayBox.H"
00017 #include "LevelData.H"
00018 #include "ProblemDomain.H"
00019 #include "RefCountedPtr.H"
00020 #include "DataIndex.H"
00021 #include "NamespaceHeader.H"
00022
00023
00024
00025
00026
00027
00028
00029
00030 typedef void(*BCFunc)(FArrayBox& a_state,
00031 const Box& a_valid,
00032 const ProblemDomain& a_domain,
00033 Real a_dx,
00034 bool a_homogeneous);
00035
00036
00037 void doNothingBC(FArrayBox& a_state,
00038 const Box& a_valid,
00039 const ProblemDomain& a_domain,
00040 Real a_dx,
00041 bool a_homogeneous);
00042
00043
00044
00045
00046 class BCFunction
00047 {
00048 public:
00049
00050
00051 BCFunction()
00052 {
00053 }
00054
00055
00056 virtual ~BCFunction()
00057 {
00058 }
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068 virtual void operator()(FArrayBox& a_state,
00069 const Box& a_valid,
00070 const ProblemDomain& a_domain,
00071 Real a_dx,
00072 bool a_homogeneous) = 0;
00073
00074
00075
00076
00077
00078
00079
00080
00081
00082
00083 virtual void operator()(FArrayBox& a_state,
00084 const Box& a_valid,
00085 const ProblemDomain& a_domain,
00086 Real a_dx,
00087 const DataIndex& a_index,
00088 bool a_homogeneous)
00089 {
00090 operator()(a_state, a_valid, a_domain, a_dx, a_homogeneous);
00091 }
00092
00093
00094
00095
00096
00097 virtual void setTime(const Real& a_time)
00098 {
00099 }
00100
00101
00102 void fillGhostCells(const LevelData<FArrayBox>& phi, const Real dx,
00103 const bool homogeneous)
00104 {
00105 const DisjointBoxLayout& dbl = phi.disjointBoxLayout();
00106 LevelData<FArrayBox>& ph = (LevelData<FArrayBox>&) phi;
00107 for (DataIterator dit = ph.dataIterator(); dit.ok(); ++dit)
00108 operator()(ph[dit], dbl[dit], dbl.physDomain(), dx, homogeneous);
00109 }
00110
00111
00112 void fillGhostCells(const Vector<LevelData<FArrayBox>*>& phi,
00113 const Real dx0, const Vector<int>& refV,
00114 const bool homogeneous)
00115 {
00116 Real dx = dx0;
00117 for (int i=0; i<phi.size(); i++)
00118 {
00119 fillGhostCells(*phi[i], dx, homogeneous);
00120 if (i<phi.size()-1)
00121 dx /= refV[i];
00122 }
00123 }
00124
00125 private:
00126
00127
00128 BCFunction(const BCFunction&);
00129 BCFunction& operator=(const BCFunction&);
00130
00131 };
00132
00133
00134
00135
00136 class BCHolder
00137 {
00138 public:
00139
00140
00141
00142
00143 BCHolder():m_funcptr(NULL)
00144 {
00145 }
00146
00147
00148 BCHolder(BCFunc funcptr):m_funcptr(funcptr)
00149 {
00150 }
00151
00152
00153 BCHolder(RefCountedPtr<BCFunction> refptr):m_funcptr(NULL),m_bc(refptr)
00154 {
00155 }
00156
00157
00158
00159
00160 void operator()(FArrayBox& a_state,
00161 const Box& a_valid,
00162 const ProblemDomain& a_domain,
00163 Real a_dx,
00164 bool a_homogeneous,
00165 const DataIndex a_index = DataIndex())
00166 {
00167 if (m_funcptr != NULL)
00168 {
00169 m_funcptr(a_state, a_valid, a_domain, a_dx, a_homogeneous);
00170 }
00171 else
00172 {
00173 m_bc->operator()(a_state, a_valid, a_domain, a_dx, a_index, a_homogeneous);
00174 }
00175 }
00176
00177
00178
00179 void setTime(Real a_time)
00180 {
00181 if (!m_bc.isNull())
00182 m_bc->setTime(a_time);
00183 }
00184
00185
00186 RefCountedPtr<BCFunction> getBCFunction()
00187 {
00188 return RefCountedPtr<BCFunction>(m_bc);
00189 }
00190
00191 protected:
00192 BCFunc m_funcptr;
00193 RefCountedPtr<BCFunction> m_bc;
00194 };
00195
00196
00197
00198
00199
00200
00201
00202
00203
00204
00205 typedef void(*BCValueFunc)(Real* a_pos,
00206 int* a_dir,
00207 Side::LoHiSide* a_side,
00208 Real* a_value);
00209
00210 class BCValueFunction
00211 {
00212 public:
00213 virtual ~BCValueFunction()
00214 {
00215 }
00216
00217 virtual void operator()(Real* a_pos,
00218 int* a_dir,
00219 Side::LoHiSide* a_side,
00220 Real* a_value) = 0;
00221 };
00222
00223 class BCValueHolder
00224 {
00225 public:
00226 BCValueHolder():m_funcptr(NULL)
00227 {
00228 }
00229
00230 BCValueHolder(BCValueFunc funcptr):m_funcptr(funcptr)
00231 {
00232 }
00233
00234 BCValueHolder(RefCountedPtr<BCValueFunction> refptr):m_funcptr(NULL),m_bc(refptr)
00235 {
00236 }
00237
00238 virtual ~BCValueHolder()
00239 {
00240 }
00241
00242 virtual void operator()(Real* a_pos,
00243 int* a_dir,
00244 Side::LoHiSide* a_side,
00245 Real* a_value)
00246 {
00247 if (m_funcptr != NULL)
00248 {
00249 m_funcptr(a_pos, a_dir, a_side, a_value);
00250 }
00251 else
00252 {
00253 m_bc->operator()(a_pos, a_dir, a_side, a_value);
00254 }
00255 }
00256
00257 protected:
00258 BCValueFunc m_funcptr;
00259 RefCountedPtr<BCValueFunction> m_bc;
00260 };
00261
00262
00263 class BCFuncWrapper: public BCFunction
00264 {
00265 public:
00266 BCFuncWrapper():m_funcptr(NULL)
00267 {
00268 }
00269
00270 BCFuncWrapper(BCFunc funcptr):m_funcptr(funcptr)
00271 {
00272 }
00273
00274
00275 virtual ~BCFuncWrapper()
00276 {
00277 }
00278
00279
00280 virtual void operator()(FArrayBox& a_state,
00281 const Box& a_valid,
00282 const ProblemDomain& a_domain,
00283 Real a_dx,
00284 bool a_homogeneous)
00285 {
00286 CH_assert(m_funcptr != NULL);
00287 m_funcptr(a_state, a_valid, a_domain, a_dx, a_homogeneous);
00288 }
00289
00290
00291 BCFuncWrapper(const BCFuncWrapper& src):m_funcptr(src.m_funcptr)
00292 {
00293 }
00294
00295 virtual BCFuncWrapper& operator=(const BCFuncWrapper& src)
00296 {
00297 m_funcptr = src.m_funcptr;
00298 return *this;
00299 }
00300
00301 protected:
00302 BCFunc m_funcptr;
00303
00304 };
00305
00306
00307
00308
00309 class ConstBCFunction: public BCFunction
00310 {
00311 public:
00312 ConstBCFunction(const IntVect& a_loSideType,
00313 const RealVect& a_loSideValue,
00314 const IntVect& a_hiSideType,
00315 const RealVect& a_hiSideValue);
00316
00317 ~ConstBCFunction();
00318
00319 virtual void operator()(FArrayBox& a_state,
00320 const Box& a_valid,
00321 const ProblemDomain& a_domain,
00322 Real a_dx,
00323 bool a_homogeneous);
00324
00325 protected:
00326 IntVect m_loSideType;
00327 RealVect m_loSideValue;
00328
00329 IntVect m_hiSideType;
00330 RealVect m_hiSideValue;
00331 };
00332
00333
00334
00335
00336
00337
00338
00339
00340
00341
00342
00343
00344
00345
00346
00347
00348
00349
00350
00351
00352
00353
00354 RefCountedPtr<BCFunction> ConstDiriNeumBC(const IntVect& a_loSideType,
00355 const RealVect& a_loSideValue,
00356 const IntVect& a_hiSideType,
00357 const RealVect& a_hiSideValue);
00358
00359
00360
00361
00362
00363
00364 void NeumBC(FArrayBox& a_state,
00365 const Box& a_valid,
00366 Real a_dx,
00367 bool a_homogeneous,
00368 const BCValueHolder& a_value,
00369 int a_dir,
00370 Side::LoHiSide a_side,
00371 Interval& a_interval);
00372
00373
00374
00375
00376
00377
00378 void NeumBC(FArrayBox& a_state,
00379 const Box& a_valid,
00380 Real a_dx,
00381 bool a_homogeneous,
00382 const BCValueHolder& a_value,
00383 int a_dir,
00384 Side::LoHiSide a_side);
00385
00386
00387
00388
00389
00390
00391 void NeumBC(FArrayBox& a_state,
00392 const Box& a_valid,
00393 Real a_dx,
00394 bool a_homogeneous,
00395 BCValueHolder a_value);
00396
00397
00398
00399
00400
00401
00402 void DiriBC(FArrayBox& a_state,
00403 const Box& a_valid,
00404 Real a_dx,
00405 bool a_homogeneous,
00406 BCValueHolder a_value,
00407 int a_dir,
00408 Side::LoHiSide a_side,
00409 Interval& a_interval,
00410 int a_order = 1);
00411
00412
00413
00414
00415
00416
00417 void DiriBC(FArrayBox& a_state,
00418 const Box& a_valid,
00419 Real a_dx,
00420 bool a_homogeneous,
00421 BCValueHolder a_value,
00422 int a_dir,
00423 Side::LoHiSide a_side,
00424 int a_order = 1);
00425
00426
00427
00428
00429
00430
00431 void DiriBC(FArrayBox& a_state,
00432 const Box& a_valid,
00433 Real a_dx,
00434 bool a_homogeneous,
00435 BCValueHolder a_value,
00436 int a_order = 1);
00437
00438
00439
00440
00441
00442
00443
00444 void NoSlipVectorBC(FArrayBox& a_state,
00445 const Box& a_valid,
00446 Real a_dx,
00447 int a_dir,
00448 Side::LoHiSide a_side,
00449 int a_order = 2);
00450
00451
00452
00453
00454
00455
00456
00457 void ReflectiveVectorBC(FArrayBox& a_state,
00458 const Box& a_valid,
00459 Real a_dx,
00460 int a_dir,
00461 Side::LoHiSide a_side,
00462 int a_order = 2);
00463
00464
00465
00466
00467
00468
00469 void ExtrapolateBC(FArrayBox& a_state,
00470 const Box& a_valid,
00471 Real a_dx,
00472 int a_dir,
00473 Side::LoHiSide a_side,
00474 Interval& a_interval,
00475 int a_order = 1);
00476
00477
00478
00479
00480
00481
00482 void ExtrapolateBC(FArrayBox& a_state,
00483 const Box& a_valid,
00484 Real a_dx,
00485 int a_dir,
00486 Side::LoHiSide a_side,
00487 int a_order = 1);
00488
00489
00490
00491
00492
00493
00494 void ExtrapolateBC(FArrayBox& a_state,
00495 const Box& a_valid,
00496 Real a_dx,
00497 int a_order = 1);
00498
00499 #include "NamespaceFooter.H"
00500
00501 #endif