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 "ProblemDomain.H"
00018 #include "RefCountedPtr.H"
00019 #include "NamespaceHeader.H"
00020
00022
00028 typedef void(*BCFunc)(FArrayBox& a_state,
00029 const Box& a_valid,
00030 const ProblemDomain& a_domain,
00031 Real a_dx,
00032 bool a_homogeneous);
00033
00034 class BCFunction
00035 {
00036 public:
00037 virtual ~BCFunction()
00038 {
00039 }
00040
00041 virtual void operator()(FArrayBox& a_state,
00042 const Box& a_valid,
00043 const ProblemDomain& a_domain,
00044 Real a_dx,
00045 bool a_homogeneous) = 0;
00046 };
00047
00048 class BCHolder
00049 {
00050 public:
00051 BCHolder():m_funcptr(NULL){;}
00052 BCHolder(BCFunc funcptr):m_funcptr(funcptr){;}
00053 BCHolder(RefCountedPtr<BCFunction> refptr):m_funcptr(NULL),m_bc(refptr){;}
00054 void operator()(FArrayBox& a_state,
00055 const Box& a_valid,
00056 const ProblemDomain& a_domain,
00057 Real a_dx,
00058 bool a_homogeneous)
00059 {
00060 if (m_funcptr != NULL)
00061 {
00062 m_funcptr(a_state, a_valid, a_domain, a_dx, a_homogeneous);
00063 }
00064 else
00065 {
00066 m_bc->operator()(a_state, a_valid, a_domain, a_dx, a_homogeneous);
00067 }
00068 }
00069
00070 protected:
00071 BCFunc m_funcptr;
00072 RefCountedPtr<BCFunction> m_bc;
00073 };
00074
00076
00084 typedef void(*BCValueFunc)(Real* a_pos,
00085 int* a_dir,
00086 Side::LoHiSide* a_side,
00087 Real* a_value);
00088
00089 class BCValueFunction
00090 {
00091 public:
00092 virtual ~BCValueFunction()
00093 {
00094 }
00095
00096 virtual void operator()(Real* a_pos,
00097 int* a_dir,
00098 Side::LoHiSide* a_side,
00099 Real* a_value) = 0;
00100 };
00101
00102 class BCValueHolder
00103 {
00104 public:
00105 BCValueHolder():m_funcptr(NULL){;}
00106 BCValueHolder(BCValueFunc funcptr):m_funcptr(funcptr){;}
00107 BCValueHolder(RefCountedPtr<BCValueFunction> refptr):m_funcptr(NULL),m_bc(refptr){;}
00108
00109 virtual ~BCValueHolder(){;}
00110
00111 virtual void operator()(Real* a_pos,
00112 int* a_dir,
00113 Side::LoHiSide* a_side,
00114 Real* a_value)
00115 {
00116 if (m_funcptr != NULL)
00117 {
00118 m_funcptr(a_pos, a_dir, a_side, a_value);
00119 }
00120 else
00121 {
00122 m_bc->operator()(a_pos, a_dir, a_side, a_value);
00123 }
00124 }
00125
00126 protected:
00127 BCValueFunc m_funcptr;
00128 RefCountedPtr<BCValueFunction> m_bc;
00129 };
00130
00131
00132
00133 class ConstBCFunction: public BCFunction
00134 {
00135 public:
00136 ConstBCFunction(const IntVect& a_loSideType,
00137 const RealVect& a_loSideValue,
00138 const IntVect& a_hiSideType,
00139 const RealVect& a_hiSideValue);
00140
00141 ~ConstBCFunction();
00142
00143 virtual void operator()(FArrayBox& a_state,
00144 const Box& a_valid,
00145 const ProblemDomain& a_domain,
00146 Real a_dx,
00147 bool a_homogeneous);
00148
00149 protected:
00150 IntVect m_loSideType;
00151 RealVect m_loSideValue;
00152
00153 IntVect m_hiSideType;
00154 RealVect m_hiSideValue;
00155 };
00156
00158
00178 RefCountedPtr<BCFunction> ConstDiriNeumBC(const IntVect& a_loSideType,
00179 const RealVect& a_loSideValue,
00180 const IntVect& a_hiSideType,
00181 const RealVect& a_hiSideValue);
00182
00184
00188 void NeumBC(FArrayBox& a_state,
00189 const Box& a_valid,
00190 Real a_dx,
00191 bool a_homogeneous,
00192 const BCValueHolder& a_value,
00193 int a_dir,
00194 Side::LoHiSide a_side);
00195
00197
00201 void NeumBC(FArrayBox& a_state,
00202 const Box& a_valid,
00203 Real a_dx,
00204 bool a_homogeneous,
00205 BCValueHolder a_value);
00206
00208
00212 void DiriBC(FArrayBox& a_state,
00213 const Box& a_valid,
00214 Real a_dx,
00215 bool a_homogeneous,
00216 BCValueHolder a_value,
00217 int a_dir,
00218 Side::LoHiSide a_side,
00219 int a_order = 1);
00220
00222
00226 void DiriBC(FArrayBox& a_state,
00227 const Box& a_valid,
00228 Real a_dx,
00229 bool a_homogeneous,
00230 BCValueHolder a_value,
00231 int a_order = 1);
00232
00234
00239 void NoSlipVectorBC(FArrayBox& a_state,
00240 const Box& a_valid,
00241 Real a_dx,
00242 int a_dir,
00243 Side::LoHiSide a_side,
00244 int a_order = 2);
00245
00247
00252 void ReflectiveVectorBC(FArrayBox& a_state,
00253 const Box& a_valid,
00254 Real a_dx,
00255 int a_dir,
00256 Side::LoHiSide a_side,
00257 int a_order = 2);
00258
00259 #include "NamespaceFooter.H"
00260 #endif