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
00028
00029
00030
00031 class BaseEBBC
00032 {
00033 public:
00034 BaseEBBC()
00035 {
00036 m_dataBased = false;
00037 }
00038
00039 virtual ~BaseEBBC()
00040 {
00041 }
00042
00043 virtual void define(const LayoutData<IntVectSet>& a_cfivs,
00044 const Real& a_factor) = 0;
00045
00046
00047 virtual void getEBFlux(Real& a_flux,
00048 const VolIndex& a_vof,
00049 const LevelData<EBCellFAB>& a_phi,
00050 const LayoutData<IntVectSet>& a_cfivs,
00051 const DataIndex& a_dit,
00052 const RealVect& a_probLo,
00053 const RealVect& a_dx,
00054 const bool& a_useHomogeneous,
00055 const Real& a_time,
00056 const pair<int,Real>* a_cacheHint=0 )
00057 {
00058
00059 MayDay::Error("how did this get called?");
00060 }
00061
00062
00063
00064
00065
00066
00067
00068 virtual LayoutData<BaseIVFAB<VoFStencil> >* getFluxStencil(int ivar)= 0;
00069
00070
00071
00072
00073
00074 virtual void applyEBFlux(EBCellFAB& a_lphi,
00075 const EBCellFAB& a_phi,
00076 VoFIterator& a_vofit,
00077 const LayoutData<IntVectSet>& a_cfivs,
00078 const DataIndex& a_dit,
00079 const RealVect& a_probLo,
00080 const RealVect& a_dx,
00081 const Real& a_factor,
00082 const bool& a_useHomogeneous,
00083 const Real& a_time) = 0;
00084
00085 virtual void setData( RefCountedPtr<LevelData<BaseIVFAB<Real> > >& a_data)
00086 {
00087 m_data = a_data;
00088 m_dataBased = true;
00089 }
00090
00091 bool dataBased() const
00092 {
00093 return m_dataBased;
00094 }
00095
00096 virtual void setType( RefCountedPtr<LevelData<BaseIVFAB<int> > >& a_type)
00097 {
00098 }
00099
00100 protected:
00101
00102 RefCountedPtr<LevelData<BaseIVFAB<Real> > > m_data;
00103 bool m_dataBased;
00104 };
00105
00106
00107
00108
00109 class ViscousBaseEBBC: public BaseEBBC
00110 {
00111 public:
00112
00113
00114
00115 ViscousBaseEBBC()
00116 {
00117 m_coefSet = false;
00118 m_value = 12345.6789;
00119 m_func = RefCountedPtr<BaseBCFuncEval>();
00120 m_isFunction = false;
00121 }
00122 virtual ~ViscousBaseEBBC()
00123 {
00124 }
00125
00126
00127
00128
00129 void setCoef(EBLevelGrid & a_eblg,
00130 Real & a_beta,
00131 RefCountedPtr<LevelData<BaseIVFAB<Real> > >& a_eta,
00132 RefCountedPtr<LevelData<BaseIVFAB<Real> > >& a_lambda,
00133 RefCountedPtr<LevelData< EBFluxFAB > >& a_etaOpen,
00134 RefCountedPtr<LevelData< EBFluxFAB > >& a_lambdaOpen
00135 )
00136 {
00137 m_coefSet = true;
00138 m_beta = a_beta;
00139 m_eblg = a_eblg;
00140 m_eta = a_eta;
00141 m_lambda = a_lambda;
00142 m_etaOpen = a_etaOpen;
00143 m_lambdaOpen = a_lambdaOpen;
00144 }
00145
00146
00147
00148
00149 virtual void setValue(Real a_value)
00150 {
00151 m_value = a_value;
00152 m_func = RefCountedPtr<BaseBCFuncEval>();
00153
00154 m_isFunction = false;
00155 }
00156
00157
00158
00159
00160
00161 virtual void setFunction(RefCountedPtr<BaseBCFuncEval> a_func)
00162 {
00163 m_value = 12345.6789;
00164 m_func = a_func;
00165
00166 m_isFunction = true;
00167 }
00168
00169 void
00170 getBoundaryGrad(Real a_grad[CH_SPACEDIM][CH_SPACEDIM],
00171 const VolIndex& a_vof,
00172 const RealVect& a_dx,
00173 const RealVect& a_probLo,
00174 const EBISBox& a_ebisBox)
00175 {
00176 for (int comp = 0; comp < SpaceDim; comp++)
00177 {
00178 for (int derivDir = 0; derivDir < SpaceDim; derivDir++)
00179 {
00180 Real value;
00181 if (m_isFunction)
00182 {
00183
00184 RealVect startPt = a_ebisBox.bndryCentroid(a_vof);
00185 startPt *= a_dx[0];
00186 startPt += a_probLo;
00187 RealVect point = EBArith::getVofLocation(a_vof, a_dx, startPt);
00188 value = m_func->derivative(point, comp, derivDir);
00189 }
00190 else
00191 {
00192 value = m_value;
00193 }
00194 a_grad[comp][derivDir] = value;
00195 }
00196 }
00197 }
00198
00199 void
00200 getFluxFromGrad(Real a_flux[CH_SPACEDIM][CH_SPACEDIM],
00201 const Real a_grad[CH_SPACEDIM][CH_SPACEDIM],
00202 const VolIndex& a_vof,
00203 const DataIndex& a_dit)
00204 {
00205
00206 Real divergence = 0;
00207 for (int divDir = 0; divDir < SpaceDim; divDir++)
00208 {
00209 divergence += a_grad[divDir][divDir];
00210 }
00211
00212 Real lambda = (*m_lambda)[a_dit](a_vof, 0);
00213 Real eta = (*m_eta)[a_dit](a_vof, 0);
00214
00215 for (int comp = 0; comp < SpaceDim; comp++)
00216 {
00217 for (int derivDir = 0; derivDir < SpaceDim; derivDir++)
00218 {
00219 a_flux[comp][derivDir] = eta*(a_grad[comp][derivDir] + a_grad[derivDir][comp]);
00220 if (comp == derivDir)
00221 {
00222 a_flux[comp][derivDir] += lambda*divergence;
00223 }
00224 }
00225 }
00226 }
00227
00228 void
00229 getChangeInSolution(Real a_deltaLph[CH_SPACEDIM],
00230 const Real a_flux[CH_SPACEDIM][CH_SPACEDIM],
00231 const RealVect& a_dx,
00232 const VolIndex& a_vof,
00233 const DataIndex& a_dit,
00234 const EBISBox& a_ebisBox)
00235 {
00236 Real beta = m_beta;
00237 RealVect normal = a_ebisBox.normal(a_vof);
00238 Real areaFrac = a_ebisBox.bndryArea(a_vof);
00239
00240
00241
00242 for (int comp = 0; comp < SpaceDim; comp++)
00243 {
00244 a_deltaLph[comp] = 0;
00245 for (int derivDir = 0; derivDir < SpaceDim; derivDir++)
00246 {
00247 a_deltaLph[comp] -= a_flux[comp][derivDir]*beta*areaFrac*normal[derivDir]/a_dx[0];
00248 }
00249 }
00250 }
00251 protected:
00252 bool m_isFunction;
00253
00254
00255 Real m_value;
00256 RefCountedPtr<BaseBCFuncEval> m_func;
00257
00258
00259 EBLevelGrid m_eblg;
00260 bool m_coefSet;
00261 Real m_beta;
00262 RefCountedPtr<LevelData<BaseIVFAB<Real> > > m_eta;
00263 RefCountedPtr<LevelData<BaseIVFAB<Real> > > m_lambda;
00264
00265 RefCountedPtr<LevelData<EBFluxFAB > > m_etaOpen;
00266 RefCountedPtr<LevelData<EBFluxFAB > > m_lambdaOpen;
00267
00268 };
00269
00270
00271
00272
00273 class ConductivityBaseEBBC: public BaseEBBC
00274 {
00275 public:
00276
00277
00278
00279 ConductivityBaseEBBC()
00280 {
00281 m_coefSet = false;
00282 m_dataBased = false;
00283 }
00284
00285 virtual ~ConductivityBaseEBBC()
00286 {
00287 }
00288
00289
00290
00291
00292
00293 void setCoef(EBLevelGrid & a_eblg,
00294 Real & a_beta,
00295 RefCountedPtr<LevelData<BaseIVFAB<Real> > >& a_bcoe)
00296 {
00297 m_coefSet = true;
00298 m_beta = a_beta;
00299 m_eblg = a_eblg;
00300 m_bcoe = a_bcoe;
00301 }
00302
00303
00304 protected:
00305
00306 EBLevelGrid m_eblg;
00307 bool m_coefSet;
00308 Real m_beta;
00309 RefCountedPtr<LevelData<BaseIVFAB<Real> > > m_bcoe;
00310
00311 };
00312
00313
00314
00315 class BaseEBBCFactory
00316 {
00317 public:
00318 BaseEBBCFactory()
00319 {
00320 }
00321
00322 virtual ~BaseEBBCFactory()
00323 {
00324 }
00325
00326
00327
00328
00329 virtual BaseEBBC* create(const ProblemDomain& a_domain,
00330 const EBISLayout& a_layout,
00331 const RealVect& a_dx,
00332 const IntVect* a_ghostCellsPhi=0,
00333 const IntVect* a_ghostCellsRhs=0 ) = 0;
00334 };
00335
00336 #include "NamespaceFooter.H"
00337 #endif