00001 #ifdef CH_LANG_CC
00002
00003
00004
00005
00006
00007
00008
00009 #endif
00010
00011 #ifndef _BASEEBBC_H_
00012 #define _BASEEBBC_H_
00013
00014 #include "RealVect.H"
00015 #include "ProblemDomain.H"
00016
00017 #include "VolIndex.H"
00018 #include "EBISLayout.H"
00019 #include "EBCellFAB.H"
00020 #include "EBFluxFAB.H"
00021 #include "EBStencil.H"
00022 #include "Stencils.H"
00023 #include "EBLevelGrid.H"
00024 #include "BaseBCFuncEval.H"
00025 #include "NamespaceHeader.H"
00026
00027
00029
00031 class BaseEBBC
00032 {
00033 public:
00034 BaseEBBC() {};
00035
00036 virtual ~BaseEBBC() {};
00037
00038 virtual void define(const LayoutData<IntVectSet>& a_cfivs,
00039 const Real& a_factor) = 0;
00040
00042 virtual void getEBFlux(Real& a_flux,
00043 const VolIndex& a_vof,
00044 const LevelData<EBCellFAB>& a_phi,
00045 const LayoutData<IntVectSet>& a_cfivs,
00046 const DataIndex& a_dit,
00047 const RealVect& a_probLo,
00048 const RealVect& a_dx,
00049 const bool& a_useHomogeneous,
00050 const Real& a_time,
00051 const pair<int,Real>* a_cacheHint=0 ) = 0;
00052
00054
00059 virtual LayoutData<BaseIVFAB<VoFStencil> >* getFluxStencil(int ivar)= 0;
00060
00062
00065 virtual void applyEBFlux(EBCellFAB& a_lphi,
00066 const EBCellFAB& a_phi,
00067 VoFIterator& a_vofit,
00068 const LayoutData<IntVectSet>& a_cfivs,
00069 const DataIndex& a_dit,
00070 const RealVect& a_probLo,
00071 const RealVect& a_dx,
00072 const Real& a_factor,
00073 const bool& a_useHomogeneous,
00074 const Real& a_time) = 0;
00075
00077
00083 virtual int whichBC()
00084 {
00085 return -777;
00086 }
00087
00088 };
00089
00091
00093 class ViscousBaseEBBC: public BaseEBBC
00094 {
00095 public:
00097
00099 ViscousBaseEBBC()
00100 {
00101 m_coefSet = false;
00102 m_value = 12345.6789;
00103 m_func = RefCountedPtr<BaseBCFuncEval>();
00104 m_isFunction = false;
00105 }
00106 virtual ~ViscousBaseEBBC()
00107 {
00108 }
00109
00111
00113 void setCoef(EBLevelGrid & a_eblg,
00114 Real & a_beta,
00115 RefCountedPtr<LevelData<BaseIVFAB<Real> > >& a_eta,
00116 RefCountedPtr<LevelData<BaseIVFAB<Real> > >& a_lambda)
00117 {
00118 m_coefSet = true;
00119 m_beta = a_beta;
00120 m_eblg = a_eblg;
00121 m_eta = a_eta;
00122 m_lambda = a_lambda;
00123 }
00124
00126
00128 virtual void setValue(Real a_value)
00129 {
00130 m_value = a_value;
00131 m_func = RefCountedPtr<BaseBCFuncEval>();
00132
00133 m_isFunction = false;
00134 }
00135
00136
00138
00140 virtual void setFunction(RefCountedPtr<BaseBCFuncEval> a_func)
00141 {
00142 m_value = 12345.6789;
00143 m_func = a_func;
00144
00145 m_isFunction = true;
00146 }
00147
00148 void
00149 getBoundaryGrad(Real a_grad[CH_SPACEDIM][CH_SPACEDIM],
00150 const VolIndex& a_vof,
00151 const RealVect& a_dx,
00152 const RealVect& a_probLo,
00153 const EBISBox& a_ebisBox)
00154 {
00155 for(int comp = 0; comp < SpaceDim; comp++)
00156 {
00157 for(int derivDir = 0; derivDir < SpaceDim; derivDir++)
00158 {
00159 Real value;
00160 if (m_isFunction)
00161 {
00162
00163 RealVect startPt = a_ebisBox.bndryCentroid(a_vof);
00164 startPt *= a_dx[0];
00165 startPt += a_probLo;
00166 RealVect point = EBArith::getVofLocation(a_vof, a_dx, startPt);
00167 value = m_func->derivative(point, comp, derivDir);
00168 }
00169 else
00170 {
00171 value = m_value;
00172 }
00173 a_grad[comp][derivDir] = value;
00174 }
00175 }
00176 }
00177
00178 void
00179 getFluxFromGrad(Real a_flux[CH_SPACEDIM][CH_SPACEDIM],
00180 const Real a_grad[CH_SPACEDIM][CH_SPACEDIM],
00181 const VolIndex& a_vof,
00182 const DataIndex& a_dit)
00183 {
00184
00185 Real divergence = 0;
00186 for(int divDir = 0; divDir < SpaceDim; divDir++)
00187 {
00188 divergence += a_grad[divDir][divDir];
00189 }
00190
00191 Real lambda = (*m_lambda)[a_dit](a_vof, 0);
00192 Real eta = (*m_eta)[a_dit](a_vof, 0);
00193
00194 for(int comp = 0; comp < SpaceDim; comp++)
00195 {
00196 for(int derivDir = 0; derivDir < SpaceDim; derivDir++)
00197 {
00198 a_flux[comp][derivDir] = eta*(a_grad[comp][derivDir] + a_grad[derivDir][comp]);
00199 if(comp == derivDir)
00200 {
00201 a_flux[comp][derivDir] += lambda*divergence;
00202 }
00203 }
00204 }
00205 }
00206
00207 void
00208 getChangeInSolution(Real a_deltaLph[CH_SPACEDIM],
00209 const Real a_flux[CH_SPACEDIM][CH_SPACEDIM],
00210 const RealVect& a_dx,
00211 const VolIndex& a_vof,
00212 const DataIndex& a_dit,
00213 const EBISBox& a_ebisBox)
00214 {
00215 Real beta = m_beta;
00216 RealVect normal = a_ebisBox.normal(a_vof);
00217 Real areaFrac = a_ebisBox.bndryArea(a_vof);
00218
00219
00220
00221 for(int comp = 0; comp < SpaceDim; comp++)
00222 {
00223 a_deltaLph[comp] = 0;
00224 for(int derivDir = 0; derivDir < SpaceDim; derivDir++)
00225 {
00226 a_deltaLph[comp] -= a_flux[comp][derivDir]*beta*areaFrac*normal[derivDir]/a_dx[0];
00227 }
00228 }
00229 }
00230 protected:
00231 bool m_isFunction;
00232
00233
00234 Real m_value;
00235 RefCountedPtr<BaseBCFuncEval> m_func;
00236
00237
00238 EBLevelGrid m_eblg;
00239 bool m_coefSet;
00240 Real m_beta;
00241 RefCountedPtr<LevelData<BaseIVFAB<Real> > > m_eta;
00242 RefCountedPtr<LevelData<BaseIVFAB<Real> > > m_lambda;
00243
00244 };
00245
00247
00249 class ConductivityBaseEBBC: public BaseEBBC
00250 {
00251 public:
00253
00255 ConductivityBaseEBBC()
00256 {
00257 m_coefSet = false;
00258 }
00259
00260 virtual ~ConductivityBaseEBBC()
00261 {
00262 }
00263
00265
00267 void setCoef(EBLevelGrid & a_eblg,
00268 Real & a_beta,
00269 RefCountedPtr<LevelData<BaseIVFAB<Real> > >& a_bcoe)
00270 {
00271 m_coefSet = true;
00272 m_beta = a_beta;
00273 m_eblg = a_eblg;
00274 m_bcoe = a_bcoe;
00275 }
00276
00277
00278 protected:
00279
00280 EBLevelGrid m_eblg;
00281 bool m_coefSet;
00282 Real m_beta;
00283 RefCountedPtr<LevelData<BaseIVFAB<Real> > > m_bcoe;
00284 };
00286
00288 class BaseEBBCFactory
00289 {
00290 public:
00291 BaseEBBCFactory() {};
00292
00293 virtual ~BaseEBBCFactory() {};
00294
00296
00298 virtual BaseEBBC* create(const ProblemDomain& a_domain,
00299 const EBISLayout& a_layout,
00300 const RealVect& a_dx,
00301 const IntVect* a_ghostCellsPhi=0,
00302 const IntVect* a_ghostCellsRhs=0 ) = 0;
00303 };
00304
00305 #include "NamespaceFooter.H"
00306 #endif