Chombo + EB + MF  3.2
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 
96  virtual void setType( RefCountedPtr<LevelData<BaseIVFAB<int> > >& a_type)
97  {
98  }
99 
100 protected:
101 
104 };
105 
106 ///
107 /**
108  */
110 {
111 public:
112  ///
113  /**
114  */
116  {
117  m_coefSet = false;
118  m_value = 12345.6789;
120  m_isFunction = false;
121  }
123  {
124  }
125 
126  ///
127  /**
128  */
129  void setCoef(EBLevelGrid & a_eblg,
130  Real & a_beta,
134  RefCountedPtr<LevelData< EBFluxFAB > >& a_lambdaOpen
135  )
136  {
137  m_coefSet = true;
138  m_beta = a_beta;
139  m_eblg = a_eblg;
140  m_eta = a_eta;
141  m_lambda = a_lambda;
142  m_etaOpen = a_etaOpen;
143  m_lambdaOpen = a_lambdaOpen;
144  }
145 
146  ///
147  /**
148  */
149  virtual void setValue(Real a_value)
150  {
151  m_value = a_value;
153 
154  m_isFunction = false;
155  }
156 
157 
158  ///
159  /**
160  */
162  {
163  m_value = 12345.6789;
164  m_func = a_func;
165 
166  m_isFunction = true;
167  }
168 
169  void
171  const VolIndex& a_vof,
172  const RealVect& a_dx,
173  const RealVect& a_probLo,
174  const EBISBox& a_ebisBox)
175  {
176  for (int comp = 0; comp < SpaceDim; comp++)
177  {
178  for (int derivDir = 0; derivDir < SpaceDim; derivDir++)
179  {
180  Real value;
181  if (m_isFunction)
182  {
183  // Compute the bndryCentroid location in physical coordinates
184  RealVect startPt = a_ebisBox.bndryCentroid(a_vof);
185  startPt *= a_dx[0];
186  startPt += a_probLo;
187  RealVect point = EBArith::getVofLocation(a_vof, a_dx, startPt);
188  value = m_func->derivative(point, comp, derivDir);
189  }
190  else
191  {
192  value = m_value;
193  }
194  a_grad[comp][derivDir] = value;
195  }
196  }
197  }
198 
199  void
201  const Real a_grad[CH_SPACEDIM][CH_SPACEDIM],
202  const VolIndex& a_vof,
203  const DataIndex& a_dit)
204  {
205  //compute divergence at boundary face
206  Real divergence = 0;
207  for (int divDir = 0; divDir < SpaceDim; divDir++)
208  {
209  divergence += a_grad[divDir][divDir];
210  }
211 
212  Real lambda = (*m_lambda)[a_dit](a_vof, 0);
213  Real eta = (*m_eta)[a_dit](a_vof, 0);
214 
215  for (int comp = 0; comp < SpaceDim; comp++)
216  {
217  for (int derivDir = 0; derivDir < SpaceDim; derivDir++)
218  {
219  a_flux[comp][derivDir] = eta*(a_grad[comp][derivDir] + a_grad[derivDir][comp]);
220  if (comp == derivDir)
221  {
222  a_flux[comp][derivDir] += lambda*divergence;
223  }
224  }
225  }
226  }
227 
228  void
230  const Real a_flux[CH_SPACEDIM][CH_SPACEDIM],
231  const RealVect& a_dx,
232  const VolIndex& a_vof,
233  const DataIndex& a_dit,
234  const EBISBox& a_ebisBox)
235  {
236  Real beta = m_beta;
237  RealVect normal = a_ebisBox.normal(a_vof);
238  Real areaFrac = a_ebisBox.bndryArea(a_vof);
239  //change in solution from one flux is
240  // dphi = beta * div F = beta * bndryArea*(f dot normal)/dx
241  // = beta *sum_dir(F[comp][derivDir]*n_derivDir/dx
242  for (int comp = 0; comp < SpaceDim; comp++)
243  {
244  a_deltaLph[comp] = 0;
245  for (int derivDir = 0; derivDir < SpaceDim; derivDir++)
246  {
247  a_deltaLph[comp] -= a_flux[comp][derivDir]*beta*areaFrac*normal[derivDir]/a_dx[0];
248  }
249  }
250  }
251 protected:
253 
254 
257 
258 
260  bool m_coefSet;
264 
267 
268 };
269 
270 ///
271 /**
272  */
274 {
275 public:
276  ///
277  /**
278  */
280  {
281  m_coefSet = false;
282  m_dataBased = false;
283  }
284 
286  {
287  }
288 
289 
290  ///
291  /**
292  */
293  void setCoef(EBLevelGrid & a_eblg,
294  Real & a_beta,
296  {
297  m_coefSet = true;
298  m_beta = a_beta;
299  m_eblg = a_eblg;
300  m_bcoe = a_bcoe;
301  }
302 
303 
304 protected:
305 
307  bool m_coefSet;
310 
311 };
312 ///
313 /**
314  */
316 {
317 public:
319  {
320  }
321 
323  {
324  }
325 
326  ///
327  /**
328  */
329  virtual BaseEBBC* create(const ProblemDomain& a_domain,
330  const EBISLayout& a_layout,
331  const RealVect& a_dx,
332  const IntVect* a_ghostCellsPhi=0,
333  const IntVect* a_ghostCellsRhs=0 ) = 0;
334 };
335 
336 #include "NamespaceFooter.H"
337 #endif
virtual void setType(RefCountedPtr< LevelData< BaseIVFAB< int > > > &a_type)
Definition: BaseEBBC.H:96
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:273
Real m_beta
Definition: BaseEBBC.H:308
bool m_isFunction
Definition: BaseEBBC.H:252
A reference-counting handle class.
Definition: RefCountedPtr.H:173
bool m_dataBased
Definition: BaseEBBC.H:103
#define CH_SPACEDIM
Definition: SPACE.H:51
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:229
A class to facilitate interaction with physical boundary conditions.
Definition: ProblemDomain.H:141
Real bndryArea(const VolIndex &a_vof) const
virtual LayoutData< BaseIVFAB< VoFStencil > > * getFluxStencil(int ivar)=0
bool m_coefSet
Definition: BaseEBBC.H:260
BaseEBBCFactory()
Definition: BaseEBBC.H:318
void setCoef(EBLevelGrid &a_eblg, Real &a_beta, RefCountedPtr< LevelData< BaseIVFAB< Real > > > &a_eta, RefCountedPtr< LevelData< BaseIVFAB< Real > > > &a_lambda, RefCountedPtr< LevelData< EBFluxFAB > > &a_etaOpen, RefCountedPtr< LevelData< EBFluxFAB > > &a_lambdaOpen)
Definition: BaseEBBC.H:129
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:200
RefCountedPtr< LevelData< EBFluxFAB > > m_etaOpen
Definition: BaseEBBC.H:265
RefCountedPtr< BaseBCFuncEval > m_func
Definition: BaseEBBC.H:256
bool dataBased() const
Definition: BaseEBBC.H:91
void setCoef(EBLevelGrid &a_eblg, Real &a_beta, RefCountedPtr< LevelData< BaseIVFAB< Real > > > &a_bcoe)
Definition: BaseEBBC.H:293
const int SpaceDim
Definition: SPACE.H:38
EBLevelGrid m_eblg
Definition: BaseEBBC.H:259
virtual void setValue(Real a_value)
Definition: BaseEBBC.H:149
Real m_beta
Definition: BaseEBBC.H:261
Definition: EBCellFAB.H:29
RefCountedPtr< LevelData< EBFluxFAB > > m_lambdaOpen
Definition: BaseEBBC.H:266
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
RealVect bndryCentroid(const VolIndex &a_vof) const
virtual ~BaseEBBCFactory()
Definition: BaseEBBC.H:322
ViscousBaseEBBC()
Definition: BaseEBBC.H:115
Definition: BaseEBBC.H:109
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.
RealVect normal(const VolIndex &a_vof) const
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:114
Definition: BaseEBBC.H:315
Iterator for all vofs within an IntVectSet and an Ebgraph.
Definition: VoFIterator.H:27
EBLevelGrid m_eblg
Definition: BaseEBBC.H:306
RefCountedPtr< LevelData< BaseIVFAB< Real > > > m_bcoe
Definition: BaseEBBC.H:309
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:170
ConductivityBaseEBBC()
Definition: BaseEBBC.H:279
An integer Vector in SpaceDim-dimensional space.
Definition: CHArray.H:42
virtual void setFunction(RefCountedPtr< BaseBCFuncEval > a_func)
Definition: BaseEBBC.H:161
Real m_value
Definition: BaseEBBC.H:255
RefCountedPtr< LevelData< BaseIVFAB< Real > > > m_lambda
Definition: BaseEBBC.H:263
RefCountedPtr< LevelData< BaseIVFAB< Real > > > m_eta
Definition: BaseEBBC.H:262
Volume of Fluid Index.
Definition: VolIndex.H:31
virtual ~ConductivityBaseEBBC()
Definition: BaseEBBC.H:285
Definition: EBISLayout.H:39
BaseEBBC()
Definition: BaseEBBC.H:34
RefCountedPtr< LevelData< BaseIVFAB< Real > > > m_data
Definition: BaseEBBC.H:102
bool m_coefSet
Definition: BaseEBBC.H:307
virtual ~ViscousBaseEBBC()
Definition: BaseEBBC.H:122
virtual ~BaseEBBC()
Definition: BaseEBBC.H:39