Chombo + EB  3.0
BaseEBBC.H
Go to the documentation of this file.
1 #ifdef CH_LANG_CC
2 /*
3  * _______ __
4  * / ___/ / ___ __ _ / / ___
5  * / /__/ _ \/ _ \/ V \/ _ \/ _ \
6  * \___/_//_/\___/_/_/_/_.__/\___/
7  * Please refer to Copyright.txt, in Chombo's root directory.
8  */
9 #endif
10 
11 #ifndef _BASEEBBC_H_
12 #define _BASEEBBC_H_
13 
14 #include "RealVect.H"
15 #include "ProblemDomain.H"
16 
17 #include "VolIndex.H"
18 #include "EBISLayout.H"
19 #include "EBCellFAB.H"
20 #include "EBFluxFAB.H"
21 #include "EBStencil.H"
22 #include "Stencils.H"
23 #include "EBLevelGrid.H"
24 #include "BaseBCFuncEval.H"
25 #include "NamespaceHeader.H"
26 
27 
28 ///
29 /**
30  */
31 class BaseEBBC
32 {
33 public:
35  {
36  m_dataBased = false;
37  }
38 
39  virtual ~BaseEBBC()
40  {
41  }
42 
43  virtual void define(const LayoutData<IntVectSet>& a_cfivs,
44  const Real& a_factor) = 0;
45 
46  ///deprecated interface.
47  virtual void getEBFlux(Real& a_flux,
48  const VolIndex& a_vof,
49  const LevelData<EBCellFAB>& a_phi,
50  const LayoutData<IntVectSet>& a_cfivs,
51  const DataIndex& a_dit,
52  const RealVect& a_probLo,
53  const RealVect& a_dx,
54  const bool& a_useHomogeneous,
55  const Real& a_time,
56  const pair<int,Real>* a_cacheHint=0 )
57  {
58  //if you want to call it, you have to implement it.
59  MayDay::Error("how did this get called?");
60  }
61 
62  ///
63  /**
64  Return a pointer to the homogenous flux stencil for the boundary condition.
65  contribution. In the case where there in no contribution in the homogeneous case
66  (ie. homogeneous Neumann) return NULL.
67  */
68  virtual LayoutData<BaseIVFAB<VoFStencil> >* getFluxStencil(int ivar)= 0;
69 
70  ///
71  /**
72  add change in lphi due to eb flux
73  */
74  virtual void applyEBFlux(EBCellFAB& a_lphi,
75  const EBCellFAB& a_phi,
76  VoFIterator& a_vofit,
77  const LayoutData<IntVectSet>& a_cfivs,
78  const DataIndex& a_dit,
79  const RealVect& a_probLo,
80  const RealVect& a_dx,
81  const Real& a_factor,
82  const bool& a_useHomogeneous,
83  const Real& a_time) = 0;
84 
85  virtual void setData( RefCountedPtr<LevelData<BaseIVFAB<Real> > >& a_data)
86  {
87  m_data = a_data;
88  m_dataBased = true;
89  }
90 
91  bool dataBased() const
92  {
93  return m_dataBased;
94  }
95 protected:
96 
99 
100 };
101 
102 ///
103 /**
104  */
106 {
107 public:
108  ///
109  /**
110  */
112  {
113  m_coefSet = false;
114  m_value = 12345.6789;
116  m_isFunction = false;
117  }
119  {
120  }
121 
122  ///
123  /**
124  */
125  void setCoef(EBLevelGrid & a_eblg,
126  Real & a_beta,
129  {
130  m_coefSet = true;
131  m_beta = a_beta;
132  m_eblg = a_eblg;
133  m_eta = a_eta;
134  m_lambda = a_lambda;
135  }
136 
137  ///
138  /**
139  */
140  virtual void setValue(Real a_value)
141  {
142  m_value = a_value;
144 
145  m_isFunction = false;
146  }
147 
148 
149  ///
150  /**
151  */
153  {
154  m_value = 12345.6789;
155  m_func = a_func;
156 
157  m_isFunction = true;
158  }
159 
160  void
162  const VolIndex& a_vof,
163  const RealVect& a_dx,
164  const RealVect& a_probLo,
165  const EBISBox& a_ebisBox)
166  {
167  for (int comp = 0; comp < SpaceDim; comp++)
168  {
169  for (int derivDir = 0; derivDir < SpaceDim; derivDir++)
170  {
171  Real value;
172  if (m_isFunction)
173  {
174  // Compute the bndryCentroid location in physical coordinates
175  RealVect startPt = a_ebisBox.bndryCentroid(a_vof);
176  startPt *= a_dx[0];
177  startPt += a_probLo;
178  RealVect point = EBArith::getVofLocation(a_vof, a_dx, startPt);
179  value = m_func->derivative(point, comp, derivDir);
180  }
181  else
182  {
183  value = m_value;
184  }
185  a_grad[comp][derivDir] = value;
186  }
187  }
188  }
189 
190  void
192  const Real a_grad[CH_SPACEDIM][CH_SPACEDIM],
193  const VolIndex& a_vof,
194  const DataIndex& a_dit)
195  {
196  //compute divergence at boundary face
197  Real divergence = 0;
198  for (int divDir = 0; divDir < SpaceDim; divDir++)
199  {
200  divergence += a_grad[divDir][divDir];
201  }
202 
203  Real lambda = (*m_lambda)[a_dit](a_vof, 0);
204  Real eta = (*m_eta)[a_dit](a_vof, 0);
205 
206  for (int comp = 0; comp < SpaceDim; comp++)
207  {
208  for (int derivDir = 0; derivDir < SpaceDim; derivDir++)
209  {
210  a_flux[comp][derivDir] = eta*(a_grad[comp][derivDir] + a_grad[derivDir][comp]);
211  if (comp == derivDir)
212  {
213  a_flux[comp][derivDir] += lambda*divergence;
214  }
215  }
216  }
217  }
218 
219  void
221  const Real a_flux[CH_SPACEDIM][CH_SPACEDIM],
222  const RealVect& a_dx,
223  const VolIndex& a_vof,
224  const DataIndex& a_dit,
225  const EBISBox& a_ebisBox)
226  {
227  Real beta = m_beta;
228  RealVect normal = a_ebisBox.normal(a_vof);
229  Real areaFrac = a_ebisBox.bndryArea(a_vof);
230  //change in solution from one flux is
231  // dphi = beta * div F = beta * bndryArea*(f dot normal)/dx
232  // = beta *sum_dir(F[comp][derivDir]*n_derivDir/dx
233  for (int comp = 0; comp < SpaceDim; comp++)
234  {
235  a_deltaLph[comp] = 0;
236  for (int derivDir = 0; derivDir < SpaceDim; derivDir++)
237  {
238  a_deltaLph[comp] -= a_flux[comp][derivDir]*beta*areaFrac*normal[derivDir]/a_dx[0];
239  }
240  }
241  }
242 protected:
244 
245 
248 
249 
251  bool m_coefSet;
255 
256 };
257 
258 ///
259 /**
260  */
262 {
263 public:
264  ///
265  /**
266  */
268  {
269  m_coefSet = false;
270  m_dataBased = false;
271  }
272 
274  {
275  }
276 
277 
278  ///
279  /**
280  */
281  void setCoef(EBLevelGrid & a_eblg,
282  Real & a_beta,
284  {
285  m_coefSet = true;
286  m_beta = a_beta;
287  m_eblg = a_eblg;
288  m_bcoe = a_bcoe;
289  }
290 
291 
292 protected:
293 
295  bool m_coefSet;
298 
299 };
300 ///
301 /**
302  */
304 {
305 public:
307  {
308  }
309 
311  {
312  }
313 
314  ///
315  /**
316  */
317  virtual BaseEBBC* create(const ProblemDomain& a_domain,
318  const EBISLayout& a_layout,
319  const RealVect& a_dx,
320  const IntVect* a_ghostCellsPhi=0,
321  const IntVect* a_ghostCellsRhs=0 ) = 0;
322 };
323 
324 #include "NamespaceFooter.H"
325 #endif
static RealVect getVofLocation(const VolIndex &a_vof, const RealVect &a_dx, const RealVect &a_probLo)
gets the location in real space of a cell center
Definition: BaseEBBC.H:261
Real m_beta
Definition: BaseEBBC.H:296
bool m_isFunction
Definition: BaseEBBC.H:243
A reference-counting handle class.
Definition: RefCountedPtr.H:66
bool m_dataBased
Definition: BaseEBBC.H:98
#define CH_SPACEDIM
Definition: SPACE.H:52
void getChangeInSolution(Real a_deltaLph[CH_SPACEDIM], const Real a_flux[CH_SPACEDIM][CH_SPACEDIM], const RealVect &a_dx, const VolIndex &a_vof, const DataIndex &a_dit, const EBISBox &a_ebisBox)
Definition: BaseEBBC.H:220
A class to facilitate interaction with physical boundary conditions.
Definition: ProblemDomain.H:130
virtual LayoutData< BaseIVFAB< VoFStencil > > * getFluxStencil(int ivar)=0
bool m_coefSet
Definition: BaseEBBC.H:251
BaseEBBCFactory()
Definition: BaseEBBC.H:306
Definition: EBISBox.H:46
Definition: EBLevelGrid.H:30
void getFluxFromGrad(Real a_flux[CH_SPACEDIM][CH_SPACEDIM], const Real a_grad[CH_SPACEDIM][CH_SPACEDIM], const VolIndex &a_vof, const DataIndex &a_dit)
Definition: BaseEBBC.H:191
RefCountedPtr< BaseBCFuncEval > m_func
Definition: BaseEBBC.H:247
Real bndryArea(const VolIndex &a_vof) const
void setCoef(EBLevelGrid &a_eblg, Real &a_beta, RefCountedPtr< LevelData< BaseIVFAB< Real > > > &a_bcoe)
Definition: BaseEBBC.H:281
const int SpaceDim
Definition: SPACE.H:39
EBLevelGrid m_eblg
Definition: BaseEBBC.H:250
virtual void setValue(Real a_value)
Definition: BaseEBBC.H:140
Real m_beta
Definition: BaseEBBC.H:252
Definition: EBCellFAB.H:29
double Real
Definition: REAL.H:33
virtual void getEBFlux(Real &a_flux, const VolIndex &a_vof, const LevelData< EBCellFAB > &a_phi, const LayoutData< IntVectSet > &a_cfivs, const DataIndex &a_dit, const RealVect &a_probLo, const RealVect &a_dx, const bool &a_useHomogeneous, const Real &a_time, const pair< int, Real > *a_cacheHint=0)
deprecated interface.
Definition: BaseEBBC.H:47
virtual ~BaseEBBCFactory()
Definition: BaseEBBC.H:310
ViscousBaseEBBC()
Definition: BaseEBBC.H:111
RealVect bndryCentroid(const VolIndex &a_vof) const
Definition: BaseEBBC.H:105
virtual void define(const LayoutData< IntVectSet > &a_cfivs, const Real &a_factor)=0
virtual void applyEBFlux(EBCellFAB &a_lphi, const EBCellFAB &a_phi, VoFIterator &a_vofit, const LayoutData< IntVectSet > &a_cfivs, const DataIndex &a_dit, const RealVect &a_probLo, const RealVect &a_dx, const Real &a_factor, const bool &a_useHomogeneous, const Real &a_time)=0
static void Error(const char *const a_msg=m_nullString, int m_exitCode=CH_DEFAULT_ERROR_CODE)
Print out message to cerr and exit with the specified exit code.
virtual BaseEBBC * create(const ProblemDomain &a_domain, const EBISLayout &a_layout, const RealVect &a_dx, const IntVect *a_ghostCellsPhi=0, const IntVect *a_ghostCellsRhs=0)=0
bool dataBased() const
Definition: BaseEBBC.H:91
void setCoef(EBLevelGrid &a_eblg, Real &a_beta, RefCountedPtr< LevelData< BaseIVFAB< Real > > > &a_eta, RefCountedPtr< LevelData< BaseIVFAB< Real > > > &a_lambda)
Definition: BaseEBBC.H:125
virtual void setData(RefCountedPtr< LevelData< BaseIVFAB< Real > > > &a_data)
Definition: BaseEBBC.H:85
A Real vector in SpaceDim-dimensional space.
Definition: RealVect.H:41
Definition: BaseEBBC.H:31
Definition: DataIndex.H:112
virtual Real derivative(const RealVect &a_point, const int &a_comp, const int &a_derivDir) const =0
Definition: BaseEBBC.H:303
Iterator for all vofs within an IntVectSet and an Ebgraph.
Definition: VoFIterator.H:27
RealVect normal(const VolIndex &a_vof) const
EBLevelGrid m_eblg
Definition: BaseEBBC.H:294
RefCountedPtr< LevelData< BaseIVFAB< Real > > > m_bcoe
Definition: BaseEBBC.H:297
void getBoundaryGrad(Real a_grad[CH_SPACEDIM][CH_SPACEDIM], const VolIndex &a_vof, const RealVect &a_dx, const RealVect &a_probLo, const EBISBox &a_ebisBox)
Definition: BaseEBBC.H:161
ConductivityBaseEBBC()
Definition: BaseEBBC.H:267
An integer Vector in SpaceDim-dimensional space.
Definition: CHArray.H:42
virtual void setFunction(RefCountedPtr< BaseBCFuncEval > a_func)
Definition: BaseEBBC.H:152
Real m_value
Definition: BaseEBBC.H:246
RefCountedPtr< LevelData< BaseIVFAB< Real > > > m_lambda
Definition: BaseEBBC.H:254
RefCountedPtr< LevelData< BaseIVFAB< Real > > > m_eta
Definition: BaseEBBC.H:253
Volume of Fluid Index.
Definition: VolIndex.H:31
virtual ~ConductivityBaseEBBC()
Definition: BaseEBBC.H:273
Definition: EBISLayout.H:39
BaseEBBC()
Definition: BaseEBBC.H:34
RefCountedPtr< LevelData< BaseIVFAB< Real > > > m_data
Definition: BaseEBBC.H:97
bool m_coefSet
Definition: BaseEBBC.H:295
virtual ~ViscousBaseEBBC()
Definition: BaseEBBC.H:118
virtual ~BaseEBBC()
Definition: BaseEBBC.H:39