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 protected:
00096
00097 RefCountedPtr<LevelData<BaseIVFAB<Real> > > m_data;
00098 bool m_dataBased;
00099
00100 };
00101
00102
00103
00104
00105 class ViscousBaseEBBC: public BaseEBBC
00106 {
00107 public:
00108
00109
00110
00111 ViscousBaseEBBC()
00112 {
00113 m_coefSet = false;
00114 m_value = 12345.6789;
00115 m_func = RefCountedPtr<BaseBCFuncEval>();
00116 m_isFunction = false;
00117 }
00118 virtual ~ViscousBaseEBBC()
00119 {
00120 }
00121
00122
00123
00124
00125 void setCoef(EBLevelGrid & a_eblg,
00126 Real & a_beta,
00127 RefCountedPtr<LevelData<BaseIVFAB<Real> > >& a_eta,
00128 RefCountedPtr<LevelData<BaseIVFAB<Real> > >& a_lambda)
00129 {
00130 m_coefSet = true;
00131 m_beta = a_beta;
00132 m_eblg = a_eblg;
00133 m_eta = a_eta;
00134 m_lambda = a_lambda;
00135 }
00136
00137
00138
00139
00140 virtual void setValue(Real a_value)
00141 {
00142 m_value = a_value;
00143 m_func = RefCountedPtr<BaseBCFuncEval>();
00144
00145 m_isFunction = false;
00146 }
00147
00148
00149
00150
00151
00152 virtual void setFunction(RefCountedPtr<BaseBCFuncEval> a_func)
00153 {
00154 m_value = 12345.6789;
00155 m_func = a_func;
00156
00157 m_isFunction = true;
00158 }
00159
00160 void
00161 getBoundaryGrad(Real a_grad[CH_SPACEDIM][CH_SPACEDIM],
00162 const VolIndex& a_vof,
00163 const RealVect& a_dx,
00164 const RealVect& a_probLo,
00165 const EBISBox& a_ebisBox)
00166 {
00167 for (int comp = 0; comp < SpaceDim; comp++)
00168 {
00169 for (int derivDir = 0; derivDir < SpaceDim; derivDir++)
00170 {
00171 Real value;
00172 if (m_isFunction)
00173 {
00174
00175 RealVect startPt = a_ebisBox.bndryCentroid(a_vof);
00176 startPt *= a_dx[0];
00177 startPt += a_probLo;
00178 RealVect point = EBArith::getVofLocation(a_vof, a_dx, startPt);
00179 value = m_func->derivative(point, comp, derivDir);
00180 }
00181 else
00182 {
00183 value = m_value;
00184 }
00185 a_grad[comp][derivDir] = value;
00186 }
00187 }
00188 }
00189
00190 void
00191 getFluxFromGrad(Real a_flux[CH_SPACEDIM][CH_SPACEDIM],
00192 const Real a_grad[CH_SPACEDIM][CH_SPACEDIM],
00193 const VolIndex& a_vof,
00194 const DataIndex& a_dit)
00195 {
00196
00197 Real divergence = 0;
00198 for (int divDir = 0; divDir < SpaceDim; divDir++)
00199 {
00200 divergence += a_grad[divDir][divDir];
00201 }
00202
00203 Real lambda = (*m_lambda)[a_dit](a_vof, 0);
00204 Real eta = (*m_eta)[a_dit](a_vof, 0);
00205
00206 for (int comp = 0; comp < SpaceDim; comp++)
00207 {
00208 for (int derivDir = 0; derivDir < SpaceDim; derivDir++)
00209 {
00210 a_flux[comp][derivDir] = eta*(a_grad[comp][derivDir] + a_grad[derivDir][comp]);
00211 if (comp == derivDir)
00212 {
00213 a_flux[comp][derivDir] += lambda*divergence;
00214 }
00215 }
00216 }
00217 }
00218
00219 void
00220 getChangeInSolution(Real a_deltaLph[CH_SPACEDIM],
00221 const Real a_flux[CH_SPACEDIM][CH_SPACEDIM],
00222 const RealVect& a_dx,
00223 const VolIndex& a_vof,
00224 const DataIndex& a_dit,
00225 const EBISBox& a_ebisBox)
00226 {
00227 Real beta = m_beta;
00228 RealVect normal = a_ebisBox.normal(a_vof);
00229 Real areaFrac = a_ebisBox.bndryArea(a_vof);
00230
00231
00232
00233 for (int comp = 0; comp < SpaceDim; comp++)
00234 {
00235 a_deltaLph[comp] = 0;
00236 for (int derivDir = 0; derivDir < SpaceDim; derivDir++)
00237 {
00238 a_deltaLph[comp] -= a_flux[comp][derivDir]*beta*areaFrac*normal[derivDir]/a_dx[0];
00239 }
00240 }
00241 }
00242 protected:
00243 bool m_isFunction;
00244
00245
00246 Real m_value;
00247 RefCountedPtr<BaseBCFuncEval> m_func;
00248
00249
00250 EBLevelGrid m_eblg;
00251 bool m_coefSet;
00252 Real m_beta;
00253 RefCountedPtr<LevelData<BaseIVFAB<Real> > > m_eta;
00254 RefCountedPtr<LevelData<BaseIVFAB<Real> > > m_lambda;
00255
00256 };
00257
00258
00259
00260
00261 class ConductivityBaseEBBC: public BaseEBBC
00262 {
00263 public:
00264
00265
00266
00267 ConductivityBaseEBBC()
00268 {
00269 m_coefSet = false;
00270 m_dataBased = false;
00271 }
00272
00273 virtual ~ConductivityBaseEBBC()
00274 {
00275 }
00276
00277
00278
00279
00280
00281 void setCoef(EBLevelGrid & a_eblg,
00282 Real & a_beta,
00283 RefCountedPtr<LevelData<BaseIVFAB<Real> > >& a_bcoe)
00284 {
00285 m_coefSet = true;
00286 m_beta = a_beta;
00287 m_eblg = a_eblg;
00288 m_bcoe = a_bcoe;
00289 }
00290
00291
00292 protected:
00293
00294 EBLevelGrid m_eblg;
00295 bool m_coefSet;
00296 Real m_beta;
00297 RefCountedPtr<LevelData<BaseIVFAB<Real> > > m_bcoe;
00298
00299 };
00300
00301
00302
00303 class BaseEBBCFactory
00304 {
00305 public:
00306 BaseEBBCFactory()
00307 {
00308 }
00309
00310 virtual ~BaseEBBCFactory()
00311 {
00312 }
00313
00314
00315
00316
00317 virtual BaseEBBC* create(const ProblemDomain& a_domain,
00318 const EBISLayout& a_layout,
00319 const RealVect& a_dx,
00320 const IntVect* a_ghostCellsPhi=0,
00321 const IntVect* a_ghostCellsRhs=0 ) = 0;
00322 };
00323
00324 #include "NamespaceFooter.H"
00325 #endif