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