Chombo + EB + MF  3.2
EBArith.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 _EBARITH_H_
12 #define _EBARITH_H_
13 
14 #include <fstream>
15 
16 #include "EBCellFAB.H"
17 #include "EBISBox.H"
18 #include "EBISLayout.H"
19 #include "EBFaceFAB.H"
20 #include "BoxLayout.H"
21 #include "BoxLayoutData.H"
22 #include "Stencils.H"
23 #include "LayoutData.H"
24 #include "Tuple.H"
25 #include "EBFluxFAB.H"
26 #include "EBCellFAB.H"
27 #include "NamespaceHeader.H"
28 ///
29 /**
30  enumeration class to ennumerate the different
31  extents of norm covereage. sometimes one
32  wants to only take a norm over the irregular
33  cells. sometimes one only wants to take a norm
34  over the regular cells, and sometimes one wants
35  both.
36  */
38 {
39 public:
40 
41  ///
42  /**
43  OverOnlyRegular means take the norm only over
44  regular cells. \\
45  OverOnlyirregular means take the norm only over
46  irregular cells. \\
47  OverBoth means use all uncovered cells. \\
48  All norms exclude covered cells.
49  */
50  enum NormMode
51  {
55  };
56 };
57 
58 ///
59 /**
60  class to encapsulate the common arithmatic operations
61  for ebfabs
62  */
63 class EBArith
64 {
65 public:
66 
67  ///
68  static void
69  getAllVoFsWithinRadiusExcludingStartVoF(Vector<VolIndex>& a_vofList,
70  Vector<IntVect> & a_dist,
71  const VolIndex& a_vof,
72  const EBISBox& a_ebisBox,
73  const int& a_redistRad);
74  ///
75  static void convertToITM(IndexTM<Real, SpaceDim>& a_diffrv, const RealVect& a_rv);
76 
77 
78  ///
79  static void convertToITM(IndexTM<int, SpaceDim>& a_diffrv, const IntVect& a_rv);
80 
81  ///
82  static void convertToITM(IndexTM<Real, SpaceDim-1>& a_diffrv, const RealVect& a_rv, const int& a_ignoreIndex);
83 
84  ///
85  static void convertToITM(IndexTM<int, SpaceDim-1>& a_diffrv, const IntVect& a_rv, const int& a_ignoreIndex);
86 
87  ///
88  /**
89  Gets the stencil to take the first derivative of cell centered data.
90  no high order one sided stuff (to keep stencil close)
91  */
92  static int
93  getFirstDerivStencilWidthOne(VoFStencil& a_sten,
94  const VolIndex& a_vof,
95  const EBISBox& a_ebisBox,
96  const int& a_idir,
97  const Real& a_dx,
98  IntVectSet* a_cfivsPtr,
99  int ivar);
100 
101  ///
102  /**
103  Least square sten using all cells in a monotone path of radius a_rad
104  */
105  static void
106  getLeastSquaresGradStenAllVoFsRad(VoFStencil& a_stencil,
107  Real& a_weight,
108  const RealVect& a_normal,
109  const RealVect& a_centroid,
110  const VolIndex& a_vof,
111  const EBISBox& a_ebisBox,
112  const RealVect& a_dx,
113  const ProblemDomain& a_domain,
114  int a_ivar,
115  int a_rad);
116 
117  static int
118  getFirstOrderExtrapolationStencil(VoFStencil& a_stencil,
119  const RealVect& a_dist,
120  const RealVect& a_dx,
121  const VolIndex& a_startVoF,
122  const EBISBox& a_ebisBox,
123  int a_noExtrapThisDir,
124  IntVectSet* a_cfivsPtr,
125  int ivar);
126  ///
127  /**
128  */
129  static int orderScript(int icomp, int inorm, int ncomp);
130 
131  ///
132  static void
133  compareError(Vector<Real>& a_orders,
134  const LevelData<EBCellFAB>& a_errorFine,
135  const LevelData<EBCellFAB>& a_errorCoar,
136  const DisjointBoxLayout& a_gridsFine,
137  const DisjointBoxLayout& a_gridsCoar,
138  const EBISLayout& a_ebislFine,
139  const EBISLayout& a_ebislCoar,
140  const Box& a_coarseDom,
141  int a_testverbosity,
142  fstream* a_fout = NULL,
143  Vector<string> a_names = Vector<string>(),
144  string a_prefix = string()) ;
145  ///
146  /**o
147  */
148  static void
149  compareError(Vector<Real>& a_orders,
150  const Vector< LevelData<EBCellFAB>* >& a_errorFine,
151  const Vector< LevelData<EBCellFAB>* >& a_errorCoar,
152  const Vector< DisjointBoxLayout >& a_gridsFine,
153  const Vector< DisjointBoxLayout >& a_gridsCoar,
154  const Vector< EBISLayout >& a_ebislFine,
155  const Vector< EBISLayout >& a_ebislCoar,
156  const Vector<int>& a_refRat,
157  const Box& a_coarseDom,
158  int a_testverbosity,
159  fstream* a_fout = NULL,
160  Vector<string> names = Vector<string>(),
161  string prefix = string());
162 
163  static Real
164  irregNorm(const LevelData<BaseIVFAB<Real> > & a_dataOne,
165  const DisjointBoxLayout & a_layout,
166  const EBISLayout & a_ebisl,
167  const int & a_comp,
168  const int & a_p);
169  static void
170  irregNorm(Real& a_ebIrregNorm,
171  const BaseIVFAB<Real>& a_ebiError,
172  const IntVectSet& a_ivsIrreg,
173  const EBISBox& a_ebisBox,
174  const int& a_comp,
175  const int& a_normtype);
176  static void
177  compareIrregError(Vector<Real>& a_orders,
178  const LevelData<BaseIVFAB<Real> >& a_errorFine,
179  const LevelData<BaseIVFAB<Real> >& a_errorCoar,
180  const DisjointBoxLayout& a_gridsFine,
181  const DisjointBoxLayout& a_gridsCoar,
182  const EBISLayout& a_ebislFine,
183  const EBISLayout& a_ebislCoar,
184  const Box& a_coarseDom,
185  const string & a_prefix,
186  Vector<string> a_names) ;
187  ///
188  static void shrinkIVS(IntVectSet& a_ivs, const int& a_numShrink);
189 
190  static void
191  timeInterpolate(LevelData<EBCellFAB>& a_U,
192  const LevelData<EBCellFAB>& a_UOld,
193  const LevelData<EBCellFAB>& a_UNew,
194  const DisjointBoxLayout& a_grids,
195  const Real& a_time,
196  const Real& a_told,
197  const Real& a_tnew);
198  ///
199  static Real
200  getDiagWeight( VoFStencil& a_vofStencil,
201  const VolIndex& a_vof,
202  int a_var = 0);
203 
204  ///
205  static void getMultiColors(Vector<IntVect>& a_colors);
206 
207  ///
208  static void
209  interpolateCFH(EBCellFAB& a_phi,
210  const int & a_idir,
211  const Side::LoHiSide& a_hiorlo,
212  const EBISBox& a_ebisBox,
213  const Real& a_dxfine,
214  const Real& a_dxcoar,
215  const IntVectSet& a_interpIVS);
216 
217  ///
218  /**
219  returns the order of the extrapolation.
220  the reason for the last argument is that you might not want the stencil
221  to leak over in the noExtrap direction even though you have set a_dist to zero.
222  This happens in CF interpolation where you have to really worry about stencil width.
223  **/
224  static int
225  getExtrapolationStencil(VoFStencil& a_stencil,
226  const RealVect& a_dist,
227  const RealVect& a_dx,
228  const VolIndex& a_startVoF,
229  const EBISBox& a_ebisBox,
230  int a_noExtrapThisDirection = -1,
231  IntVectSet* a_cfivsPtr = NULL,
232  int ivar = 0);
233 
234  ///
235  /**
236  returns the order of the extrapolation.
237  the reason for the last argument is that you might not want the stencil
238  to leak over in the noExtrap direction even though you have set a_dist to zero.
239  This happens in CF interpolation where you have to really worry about stencil width.
240  **/
241  static int
242  get1stOrderExtrapolationStencil(VoFStencil& a_stencil,
243  const RealVect& a_dist,
244  const RealVect& a_dx,
245  const VolIndex& a_startVoF,
246  const EBISBox& a_ebisBox,
247  int a_noExtrapThisDirection = -1,
248  IntVectSet* a_cfivsPtr = NULL,
249  int ivar = 0);
250 
251  ///
252  /**
253  **/
254  static void
255  getDir1Dir2(int& a_dir1, int& a_dir2, const int& a_dir);
256 
257  ///
258  /**
259  send null ivs if you do not want lohicenter to care about cfivs
260  **/
261  static void
262  loHiCenter(Box& a_loBox,
263  int& a_hasLo,
264  Box& a_hiBox,
265  int& a_hasHi,
266  Box& a_centerBox,
267  const ProblemDomain & a_eblg,
268  const Box& a_inBox,
269  const int& a_dir,
270  IntVectSet* a_cfivsPtr = NULL);
271 
272  ///
273  /**
274  **/
275  static void
276  loHi(Box& a_loBox,
277  int& a_hasLo,
278  Box& a_hiBox,
279  int& a_hasHi,
280  const ProblemDomain& a_eblg,
281  const Box& a_inBox,
282  const int& a_dir);
283 
284  ///
285  /**
286  testRef is the size of the coarsest domain allowed in multigrid. If testRef=2,
287  then the coarsest domain in multigrid will be 2x2(x2)
288  **/
289  static bool getCoarserLayouts(DisjointBoxLayout& a_dblCoar,
290  ProblemDomain& a_domainCoar,
291  const DisjointBoxLayout& a_dblFine,
292  const ProblemDomain& a_domainFine,
293  int a_refToCoar,
294  int a_maxBoxSize,
295  bool& a_layoutChanged,
296  int a_testRef = 2);
297 
298  ///
299  /**
300  Gets the stencil to take the first derivative in the given direction
301  of cell centered data.
302  Returns the expected order of the derivative.
303  When we need them, we prefer
304  first derivataves to be second order if at all possible, so we take some pains
305  to achieve that
306  */
307  static int
308  getFirstDerivStencil(VoFStencil& a_sten,
309  const VolIndex& a_vof,
310  const EBISBox& a_ebisBox,
311  const int& a_idir,
312  const Real& a_dx,
313  IntVectSet* a_cfivsPtr = NULL,
314  int ivar = 0);
315 
316 
317  ///
318  /**
319  Gets the stencil to take the mixed (in the given directions)
320  derivative of cell centered data.
321  Returns the expected order of the derivative.
322  When we need them, we usually only need second derivatives to O(h), so
323  this just shifts stencil when it has to.
324  */
325  static int
326  getMixedDerivStencil(VoFStencil& a_sten,
327  const VolIndex& a_vof,
328  const EBISBox& a_ebisBox,
329  const int& a_dir1,
330  const int& a_dir2,
331  const Real& a_dx1,
332  const Real& a_dx2,
333  IntVectSet* a_cfivsPtr = NULL,
334  int ivar = 0);
335 
336  ///
337  /**
338  Gets the stencil to take the second derivative in the given direction)
339  of cell centered data.
340  Returns the expected order of the derivative.
341  When we need them, we usually only need second derivatives to O(h), so
342  this just shifts stencil when it has to.
343  */
344  static int
345  getSecondDerivStencil(VoFStencil& a_sten,
346  const VolIndex& a_vof,
347  const EBISBox& a_ebisBox,
348  const int& a_idir,
349  const Real& a_dx,
350  IntVectSet* a_cfivsPtr = NULL,
351  int ivar = 0);
352 
353  ///
354  /**
355  a function that could possibly take over the world.
356  */
357  static void
358  getVoFsDir(bool& a_hasClose, VolIndex& a_closeVoF,
359  bool& a_hasFar, VolIndex& a_farVoF,
360  const EBISBox& a_ebisBox,
361  const VolIndex& a_vof,
362  int a_idir, Side::LoHiSide a_sd,
363  IntVectSet* a_cfivsPtr);
364 
365  ///
366  /**
367  define an intvectset of ghost cells which live on
368  the coarse fine interface. includes corner cells.
369  */
370  static void
371  defineCFIVS(LayoutData<IntVectSet>& a_cfivs,
372  const DisjointBoxLayout& a_grids,
373  const ProblemDomain& a_probDom);
374 
375  ///
376  static Real
377  extrapFaceGradToOutflow(const FaceIndex& a_bndryFace,
378  const Side::LoHiSide& a_side,
379  const int& a_idir,
380  const EBGraph& a_ebGraph,
381  const EBFaceFAB& a_faceData,
382  const int& a_comp);
383 
384  ///
385  static Real
386  extrapFaceValueToDomain(const FaceIndex& a_bndryFace,
387  const Side::LoHiSide& a_side,
388  const int& a_idir,
389  const EBGraph& a_ebGraph,
390  const EBFaceFAB& a_faceData,
391  const int& a_comp,
392  const Real& a_dropOrderValue = 0.);
393 
394  ///
395  static Real
396  extrapFaceVelToOutflow(const FaceIndex& a_bndryFace,
397  const Side::LoHiSide& a_side,
398  const int& a_idir,
399  const EBGraph& a_ebGraph,
400  const EBFaceFAB& a_faceData,
401  const int& a_comp);
402 
403  ///
404  static Real
405  interpolateVel(const EBFaceFAB& a_vel,
406  const EBISBox& a_ebisBox,
407  const FaceIndex& a_face);
408 
409  ///
410  static Real
411  deInterpolateVel(const Real& a_centroidVel,
412  const EBFaceFAB& a_vel,
413  const EBISBox& a_ebisBox,
414  const FaceIndex& a_face);
415 
416  ///
417  static Real
418  getFaceVelForDivFreeCell(const FaceIndex& a_face,
419  const VolIndex& a_vof,
420  const int& a_idir,
421  const Side::LoHiSide& a_side,
422  const EBFluxFAB& a_vel,
423  const RealVect& a_dx,
424  const EBISBox& a_ebisBox);
425  ///
426  /**
427  evaluates integral(a_divu dV)/integral(dV) over a hierarchy.
428  pval = -1--->assumes volfrac already multiplied in
429  pval = -2--->multiply by volume fraction
430  */
431  static void
432  meanOverHierarchy(Real& a_mean,
433  const Vector<LevelData<EBCellFAB> *>& a_divu,
434  const Vector<DisjointBoxLayout>& a_grids,
435  const Vector<EBISLayout>& a_ebisl,
436  const Vector<int>& a_refRat,
437  const ProblemDomain& a_domainCoarsest,
438  const RealVect& a_dxCoarsest,
439  const int& a_comp,
440  int pval= -1);
441 
442  ///
443  /**
444  //gets the weight of a vof to interpolate (linear in 2d, bilinear in 3d) to an interpolation point in the plane
445  //this is used to get one of the points along the johansen ray
446  */
447  static Real
448  getJohanVoFWeight(const VolIndex& a_whichVoF, //vof for which we are trying to find weight
449  const RealVect& a_intersectLoc, //location of intersection in real space
450  const IntVect& a_intersectIV, //intvect through which ray passes
451  const int& a_nMaxDir, //direction of largest normal
452  const RealVect& a_dx); //grid spacing but you knew that.
453 
454  ///version which uses incoming normal, boundary centroid
455  /**
456  splitting up stuff this way to facillitate multifluid
457  which can have multiple normals and boundary centroids per cell.
458  */
459  static void
460  johanStencil(bool& a_dropOrder,
461  Vector<VoFStencil>& a_pointStencils,
462  Vector<Real>& a_distanceAlongLine,
463  const RealVect& a_normal,
464  const RealVect& a_bndryCentroid,
465  const VolIndex& a_vof,
466  const EBISBox& a_ebisBox,
467  const RealVect& a_dx,
468  const IntVectSet& a_cfivs,
469  int a_ivar = 0);
470 
471  ///
472  /**
473  Gets the stencils to get the data points along the Johansen ray. If a_dropOrder
474  returns true then the stencil does not exist. Also returns the distances along the ray
475  to each point.
476  */
477  static void
478  johanStencil(bool& a_dropOrder,
479  Vector<VoFStencil>& a_pointStencils,
480  Vector<Real>& a_distanceAlongLine,
481  const VolIndex& a_vof,
482  const EBISBox& a_ebisBox,
483  const RealVect& a_dx,
484  const IntVectSet& a_cfivs,
485  int a_ivar = 0);
486 
487  ///standard interface
488  /**
489  gets the normal and calls the other version
490  */
491  static void
492  getLeastSquaresGradSten(VoFStencil& a_stencil,
493  Real& a_weight,
494  const VolIndex& a_vof,
495  const EBISBox& a_ebisBox,
496  const RealVect& a_dx,
497  const ProblemDomain& a_domain,
498  int a_ivar = 0);
499 
500  ///version which uses incoming normal, boundary centroid
501  /**
502  splitting up stuff this way to facillitate multifluid
503  which can have multiple normals and boundary centroids per cell.
504  */
505  static void
506  getLeastSquaresGradSten(VoFStencil& a_stencil,
507  Real& a_weight,
508  const RealVect& a_normal ,
509  const RealVect& a_centroid,
510  const VolIndex& a_vof,
511  const EBISBox& a_ebisBox,
512  const RealVect& a_dx,
513  const ProblemDomain& a_domain,
514  int a_ivar = 0);
515 
516 
517  ///version which uses incoming normal, boundary centroid
518  /**
519  splitting up stuff this way to facillitate multifluid
520  which can have multiple normals and boundary centroids per cell.
521  */
522  static void
523  getLeastSquaresGradSten(VoFStencil& a_stencil,
524  Real& a_weight,
525  const RealVect& a_normal ,
526  const RealVect& a_centroid,
527  const IntVect& a_quadrant,
528  const VolIndex& a_vof,
529  const EBISBox& a_ebisBox,
530  const RealVect& a_dx,
531  const ProblemDomain& a_domain,
532  int a_ivar = 0);
533 
534  ///version which uses incoming normal, boundary centroid, and
535  /// all available VoFs.
536  /**
537  splitting up stuff this way to facillitate multifluid
538  which can have multiple normals and boundary centroids per cell.
539  */
540  static void
541  getLeastSquaresGradStenAllVoFs(VoFStencil& a_stencil,
542  Real& a_weight,
543  const RealVect& a_normal,
544  const RealVect& a_centroid,
545  const VolIndex& a_vof,
546  const EBISBox& a_ebisBox,
547  const RealVect& a_dx,
548  const ProblemDomain& a_domain,
549  int a_ivar);
550 
551  ///version which uses incoming normal, boundary centroid, and
552  /// all quadrants.
553  /**
554  splitting up stuff this way to facillitate multifluid
555  which can have multiple normals and boundary centroids per cell.
556  */
557  static void
558  getLeastSquaresGradStenAllQuad(VoFStencil& a_stencil,
559  Real& a_weight,
560  const RealVect& a_normal,
561  const RealVect& a_centroid,
562  const VolIndex& a_vof,
563  const EBISBox& a_ebisBox,
564  const RealVect& a_dx,
565  const ProblemDomain& a_domain,
566  int a_ivar,
567  bool a_doSymmetric = false);
568 
569  /**
570  split matrix computations for least squares into separate
571  routine that is independent of stencil size, so that the
572  code can be reused
573  */
574  static void
575  calculateWeightingMatrix(RealVect x0,
576  Vector<RealVect>& xp,
577  Vector<RealVect>& weightMatrix,
578  bool& detZero);
579 
580  static void
581  calculateWeightingMatrixRed(RealVect x0,
582  Vector<RealVect>& xp,
583  IntVect dimm,
584  Vector<RealVect>& weightMatrix,
585  bool& deadRed);
586 
587  ///gets the normal of a domain face
588  static RealVect getDomainNormal(int a_idir, Side::LoHiSide a_side);
589 
590  ///gets the location in real space of a face center
591  static RealVect getFaceLocation(const FaceIndex& a_face,
592  const RealVect& a_dx,
593  const RealVect& a_probLo);
594 
595 
596  ///gets the location in real space of a face center
597  static RealVect getFaceLocation(const FaceIndex& a_face,
598  const Real& a_dx,
599  const RealVect& a_probLo)
600  {
601  return getFaceLocation(a_face, a_dx*RealVect::Unit, a_probLo);
602  }
603 
604  ///get stencils for points along a line (generalized johansen stencil)
605  static void dataRayCast(bool& a_dropOrder,
606  Vector<VoFStencil>& a_pointStencils,
607  Vector<Real>& a_distanceAlongLine,
608  const RealVect& a_normal,
609  const RealVect& a_bndryCentroid,
610  const VolIndex& a_vof,
611  const EBISBox& a_ebisBox,
612  const RealVect& a_dx,
613  const IntVectSet& a_cfivs,
614  int a_ivar,
615  int a_numPoints);
616 
617  ///gets the location in real space of a cell center
618  static RealVect getVofLocation(const VolIndex& a_vof,
619  const RealVect& a_dx,
620  const RealVect& a_probLo);
621 
622  ///I have misspelled this one time too many
623  static RealVect getVoFLocation(const VolIndex& a_vof,
624  const RealVect& a_dx,
625  const RealVect& a_probLo)
626  {
627  return getVofLocation(a_vof, a_dx, a_probLo);
628  }
629 
630  ///I have misspelled this one time too many
631  static RealVect getVoFLocation(const VolIndex& a_vof,
632  const Real& a_dx,
633  const RealVect& a_probLo)
634  {
635  RealVect rvdx = a_dx*RealVect::Unit;
636  return getVofLocation(a_vof, rvdx, a_probLo);
637  }
638 
639 
640  ///I have misspelled this one time too many
641  static RealVect getVofLocation(const VolIndex& a_vof,
642  const Real& a_dx,
643  const RealVect& a_probLo)
644  {
645  RealVect rvdx = a_dx*RealVect::Unit;
646  return getVofLocation(a_vof, rvdx, a_probLo);
647  }
648 
649 
650  ///gets the location in real space of a cell center
651  static RealVect getIVLocation(const IntVect& a_iv,
652  const RealVect& a_dx,
653  const RealVect& a_probLo);
654 
655  ///
656  /**
657  A very easy to screw up piece of code that was in four places.
658  */
659  static void
660  defineFluxInterpolant(LevelData<BaseIFFAB<Real> >& a_fluxInterpolant,
661  LayoutData<IntVectSet> & a_irregSetsGrown,
662  const DisjointBoxLayout & a_dbl,
663  const EBISLayout & a_ebisl,
664  const ProblemDomain & a_domain,
665  const int & a_ncomp,
666  const int & a_faceDir);
667 
668  ///
669  static void
670  interpolateFluxToCentroids(LevelData<EBFluxFAB>& a_centroidFlux,
671  const LevelData<EBFluxFAB>& a_faceCentFlux,
672  const DisjointBoxLayout& a_grids,
673  const EBISLayout& a_ebisl,
674  const ProblemDomain& a_domain);
675 
676  ///
677  static void
678  interpolateFluxToCentroids(EBFaceFAB& a_centroidFlux,
679  const EBFaceFAB& a_faceCentFlux,
680  const Box& a_box,
681  const EBISBox& a_ebisBox,
682  const ProblemDomain& a_domain,
683  const int& a_idir);
684 
685 
686  ///
687  static FaceStencil getInterpStencil(const FaceIndex& a_face,
688  const IntVectSet& a_coarseFineIVS,
689  const EBISBox& a_ebisBox,
690  const ProblemDomain& a_domainBox);
691 
692  ///
693  static void getInterpStencil2D(FaceStencil& a_sten,
694  const FaceIndex& a_face,
695  const IntVectSet& a_coarseFineIVS,
696  const EBISBox& a_ebisBox,
697  const ProblemDomain& a_domainBox) ;
698 
699  ///
700  static void getInterpStencil3D(FaceStencil& a_sten,
701  const FaceIndex& a_face,
702  const IntVectSet& a_coarseFineIVS,
703  const EBISBox& a_ebisBox,
704  const ProblemDomain& a_domainBox);
705 
706  ///
707  /**
708  Return true if there is unique vof associated with a_cell
709  that lies in the a_vofsStencil. If so, a_vof = vof. Else return false.
710  */
711  static bool
712  isVoFHere(VolIndex& a_vof,
713  const Vector<VolIndex>& a_vofsStencil,
714  const IntVect& a_cell );
715 
716  ///
717  static bool
718  isVoFHere(VolIndex& a_vof, int& a_whichVoF,
719  const Vector<VolIndex>& a_vofsStencil,
720  const IntVect& a_cell );
721 
722  ///
723  /** Returns all vofs that can be reached from a_vof via a
724  monotone path of length <= than radius
725  */
726  static void
727  getAllVoFsInMonotonePath(Vector<VolIndex>& a_vofList,
728  const VolIndex& a_vof,
729  const EBISBox& a_ebisBox,
730  const int& a_redistRad);
731 
732  /*******/
733  static void
734  getAllVoFsWithinRadius(Vector<VolIndex>& a_vofList,
735  Vector<IntVect> & a_dist,
736  const VolIndex& a_vof,
737  const EBISBox& a_ebisBox,
738  const int& a_redistRad);
739 
740  ///get volume of a vof in rz coords
741  static void
742  getKVolRZ(Real& a_kvol,
743  Real& a_cellVol,
744  const EBISBox& a_ebisBox,
745  const Real& a_dx,
746  const VolIndex& a_vof);
747 
748  ///get volume of a vof in rz coords
749  static void
750  getKVolRZNoDx(Real& a_kvol,
751  Real& a_cellVolDx3,
752  const EBISBox& a_ebisBox,
753  const VolIndex& a_vof);
754 
755  ///
756  /**
757  Return true if there is a unique adjacent face in the
758  given direction. False if either covered or multivalued.
759  */
760  static
761  bool
762  getAdjacentFace(FaceIndex& a_adjacentFace,
763  const FaceIndex& a_face,
764  const EBISBox& a_ebisBox,
765  const ProblemDomain& a_domain,
766  const int& a_idir,
767  const Side::LoHiSide& a_side);
768 
769  ///
770  /**
771  compute a stencil for one of our fancy interpolated
772  gradients.
773  */
774  static
775  void computeGradFluxStencil(VoFStencil& a_thisStencil,
776  const FaceIndex& a_thisFace,
777  const EBISBox& a_ebisBox,
778  const ProblemDomain& a_domain,
779  const int& a_dir);
780 
781  ///
782  /**
783  compute a stencil for one of our fancy interpolated
784  fluxes.
785  */
786  static
787  void computeInterpStencil(FaceStencil& a_thisStencil,
788  const FaceIndex& a_thisFace,
789  const EBISBox& a_ebisBox,
790  const ProblemDomain& a_domain,
791  const int& a_dir);
792 
793  ///
794  /**
795  return lp-norm of component comp of a_src,
796  weighted by local volume fraction.
797  not normalized by number of points or anything like that.
798  if p==0, volume returned is one
799  and norm returned is Max(abs(a_src)) over
800  uncovered regions. otherwise,
801  returns sum(volfrac*a_src(iv,comp)**p) of component comp of a_src
802  weighted by local volume fraction and
803  also returns volume of uncovered regions.
804  Only uncovered regions count here.
805  */
806  static
807  void
808  volWeightedSum(Real& a_norm,
809  Real& a_volume,
810  const EBCellFAB& a_src,
811  const Box& a_region,
812  const EBISBox& a_ebisBox,
813  const RealVect& a_dx,
814  const IntVectSet& a_ivsExclude,
815  const int& a_comp,
816  const int& a_p,
818 
819 
820  static void
821  getCompVolRZ(Real& a_compVol,
822  const EBISBox& a_ebisBox,
823  const Real& a_dx,
824  const VolIndex& a_vof,
825  bool a_verbose = false);
826  ///
827  /**
828  return volume-weighted sum of component comp of a_src,
829  weighted by local volume fraction.
830  and norm returned is Max(abs(a_src)) over
831  uncovered regions. otherwise,
832  returns sum(volfrac*a_src(iv,comp)**p) of component comp of a_src
833  weighted by local volume fraction and
834  also returns volume of uncovered regions.
835  Only uncovered regions count here.
836  */
837  static
838  void
839  computeSum(Real& a_norm,
840  Real& a_volume,
841  const EBCellFAB& a_src,
842  const Box& a_region,
843  const EBISBox& a_ebisBox,
844  const RealVect& a_dx,
845  const IntVectSet& a_ivsExclude,
846  const int& a_comp,
848 
849 
850  ///
851  /**
852  return volume-weighted sum of component comp of a_src,
853  weighted by local volume fraction.
854  and norm returned is Max(abs(a_src)) over
855  uncovered regions. otherwise,
856  returns sum(volfrac*a_src(iv,comp)**p) of component comp of a_src
857  weighted by local volume fraction and
858  also returns volume of uncovered regions.
859  Only uncovered regions count here.
860  */
861  static
862  void
863  computeUnweightedSum(Real& a_norm,
864  Real& a_volume,
865  const EBCellFAB& a_src,
866  const Box& a_region,
867  const EBISBox& a_ebisBox,
868  const RealVect& a_dx,
869  const IntVectSet& a_ivsExclude,
870  const int& a_comp,
872 
873  ///
874  /** return l-p norm of a_src.
875  if p==0, v
876  norm returned is Max(abs(a_src)) over
877  uncovered regions. otherwise,
878  returns 1/vol(sum(volfrac*a_src(iv,comp)**p)^(1/p))
879  of component comp of a_src
880  weighted by local volume fraction and
881  also returns volume of uncovered regions.
882  Only uncovered regions count here.
883  The data must have the same layout as a_layout with
884  the possible exception of ghost cells.
885 
886  int pmode = -2; //norm = (1/v)(sum(phi dv)) ---no absolute values and multiply kappa as you go
887  int pmode = -1; //norm = (1/v)(sum(phi dv)) ---no absolute values and assume kappa already multiplied in
888 
889  */
890  static
891  Real
892  norm(const BoxLayoutData<EBCellFAB >& a_dataOne,
893  const BoxLayout& a_layout,
894  const EBISLayout& a_ebisl,
895  const int& comp,
896  const int& p,
898 
899  static
900  Real
901  norm(const Vector<LevelData<EBCellFAB>* >& a_data,
902  const Vector< DisjointBoxLayout > & a_layout,
903  const Vector< EBISLayout >& a_ebisl,
904  const Vector< int >& a_refRatio,
905  const int& comp,
906  const int& p,
908 
909  ///
910  static
911  void
912  computeCoveredFaces(Vector<VolIndex>& a_coveredFace,
913  IntVectSet& a_coveredSets,
914  IntVectSet& a_irregIVS,
915  const int& a_idir,
916  const Side::LoHiSide& a_sd,
917  const EBISBox& a_ebisBox,
918  const Box& a_region);
919 
920  //testing interface
921  static
922  Real
923  norm(Real& volume, const BoxLayoutData<EBCellFAB >& a_dataOne,
924  const BoxLayout& a_layout,
925  const EBISLayout& a_ebisl,
926  const int& comp,
927  const int& p,
929 
930  ///
931  /** return l-p norm of a_src.
932  if p==0, v
933  norm returned is Max(abs(a_src)) over
934  uncovered regions. otherwise,
935  returns 1/vol(sum(volfrac*a_src(iv,comp)**p)^(1/p))
936  of component comp of a_src
937  weighted by local volume fraction and
938  also returns volume of uncovered regions.
939  Only uncovered regions count here.
940  The data must have the same layout as a_layout with
941  the possible exception of ghost cells.
942  */
943  static
944  Real
945  norm(const EBCellFAB& a_dataOne,
946  const Box& a_grid,
947  const EBISBox& a_ebisl,
948  const int& a_comp,
949  const int& a_p,
951 
952  static
953  Real
954  norm(Real& volume, const EBCellFAB& a_dataOne,
955  const Box& a_grid,
956  const EBISBox& a_ebisl,
957  const int& a_comp,
958  const int& a_p,
960 
961  ///
962  /** return l-p norm of a_src.
963  if p==0, v
964  norm returned is Max(abs(a_src)) over
965  uncovered regions. otherwise,
966  returns sum(volfrac*a_src(iv,comp)**p) of component comp of a_src
967  weighted by local volume fraction and
968  also returns volume of uncovered regions.
969  Only uncovered regions count here.
970  The data must have the same layout as a_layout with
971  the possible exception of ghost cells.
972  */
973  static
974  void
975  volWeightedSum(Real& a_sum,
976  Real& a_volume,
977  const BoxLayoutData<EBCellFAB >& a_dataOne,
978  const BoxLayout& a_layout,
979  const EBISLayout& a_ebisl,
980  const RealVect& a_dx,
981  const IntVectSet& a_ivsExclude,
982  const int& a_comp,
983  const int& a_p,
985 
986  ///
987  /** return the sum of all irregular boundary areas
988  */
989  static
990  void
991  sumBndryArea(Real& a_area,
992  const BoxLayout& a_region,
993  const EBISLayout& a_ebisl);
994 
995  ///
996  /** return the dotproduct of two leveldatas of ebfabs,
997  Only uncovered regions count here.
998  */
999  static
1000  Real
1001  dotProduct(const BoxLayoutData<EBCellFAB >& a_dataOne,
1002  const BoxLayoutData<EBCellFAB >& a_dataTwo,
1003  const BoxLayout& a_layout,
1004  const EBISLayout& a_ebisl,
1005  const int& a_comp);
1006 
1007  ///
1008  /** return the dotproduct of two ebfabs,
1009  Only uncovered regions count here.
1010  */
1011  static
1012  Real
1013  dotProduct(const EBCellFAB& a_dataOne,
1014  const EBCellFAB& a_dataTwo,
1015  const Box& a_layout,
1016  const EBISBox& a_ebisBox,
1017  const int& a_comp);
1018 
1019  ///
1020  /** Given a VoF, a_vof1, and a cell, a_cell2, determine if there is a vector of
1021  VoFs in a_cell2 that connects to a_vof1 via a monotone path.
1022  A vector of VolIndices is returned, even if empty.
1023  */
1024  static
1025  void
1026  monotonePathVoFToCellMultiVoFs(Vector<VolIndex>& a_vofsInCell,
1027  const Vector<VolIndex>& a_vofsInPath,
1028  const IntVect& a_cell2,
1029  const EBISBox& a_ebisBox);
1030  ///
1031  /** Given a VoF, a_vof1, and a cell, a_cell2, determine if there is a single
1032  VoF in a_cell2 that connects to a_vof1 via a monotone path. If there is
1033  one such VoF then TRUE is returned (and the VolIndex is returned,
1034  a_vof2). If there is no such VoF or if there are more than one such
1035  VoF then FALSE is returned (and a_vof2 is unchanged).
1036  */
1037  static
1038  bool
1039  monotonePathVoFToCellVoF(VolIndex& a_vof2,
1040  const VolIndex& a_vof1,
1041  const IntVect& a_cell2,
1042  const EBISBox& a_ebisBox);
1043  /*******/
1044  static void
1045  getAllVoFsWithinRadius(Vector<VolIndex>& a_vofList,
1046  const VolIndex& a_vof,
1047  const EBISBox& a_ebisBox,
1048  const int& a_redistRad);
1049 
1050  /*******/
1051  static void
1052  getAllVoFsWithinRadius(Vector<VolIndex>& a_vofList,
1053  const IntVect& a_timesMoved,
1054  const VolIndex& a_vof,
1055  const EBISBox& a_ebisBox,
1056  const int& a_redistRad);
1057 
1058  ///
1059  /** Returns all vofs that can be reached from a_vof via a
1060  monotone path of length <= than radius
1061  */
1062  static
1063  void
1064  getAllVoFsInMonotonePath(Vector<VolIndex>& a_vofs,
1065  const IntVect& a_timesMoved,
1066  const IntVect& a_pathSign,
1067  const VolIndex& a_vof,
1068  const EBISBox& a_ebisBox,
1069  const int& a_radius);
1070 
1072  {
1073  return s_vofMax;
1074  }
1075  static Real& getValMax()
1076  {
1077  return s_valMax;
1078  }
1079 
1080  static void setMinVolumeFraction(Real a_minVolFrac)
1081  {
1082  s_minVolFrac = a_minVolFrac;
1083  }
1084 
1085 private:
1087  static Real s_valMax;
1089 
1090 };
1091 
1092 extern IntVect ebcoarsen (const IntVect& b,
1093  int refinement_ratio);
1094 
1095 extern
1096 Box ebrefine (const Box& b,
1097  int refinement_ratio);
1098 extern
1100  int refinement_ratio);
1101 
1102 extern Box ebcoarsen (const Box& b,
1103  int refinement_ratio);
1104 extern ProblemDomain ebcoarsen (const ProblemDomain& b,
1105  int refinement_ratio);
1106 
1107 extern void ebrefine(DisjointBoxLayout& output,
1108  const DisjointBoxLayout& input,
1109  int refinement);
1110 
1111 extern void ebcoarsen(DisjointBoxLayout& output,
1112  const DisjointBoxLayout& input,
1113  int refinement);
1114 
1115 #include "NamespaceFooter.H"
1116 #endif
IntVect ebcoarsen(const IntVect &b, int refinement_ratio)
Definition: Stencils.H:194
static VolIndex s_vofMax
Definition: EBArith.H:1086
An irregular domain on an integer lattice.
Definition: IntVectSet.H:44
A class to facilitate interaction with physical boundary conditions.
Definition: ProblemDomain.H:141
A not-necessarily-disjoint collective of boxes.
Definition: BoxLayout.H:145
Definition: FaceIndex.H:28
Real norm(const BoxLayoutData< FArrayBox > &A, const Interval &interval, const int &p=2)
Definition: EBISBox.H:46
Definition: EBArith.H:37
void compareError(Vector< Real > &a_orders, const Vector< LevelData< FArrayBox > * > &a_errorFine, const Vector< LevelData< FArrayBox > * > &a_errorCoar, const Vector< DisjointBoxLayout > &a_gridsFine, const Vector< DisjointBoxLayout > &a_gridsCoar, const Vector< int > &a_refRat, const ProblemDomain &a_coarseDom, int a_testverbosity)
Definition: EBFaceFAB.H:28
Geometric description within a box.
Definition: EBGraph.H:427
static RealVect getVofLocation(const VolIndex &a_vof, const Real &a_dx, const RealVect &a_probLo)
I have misspelled this one time too many.
Definition: EBArith.H:641
Definition: IndexTM.H:36
static const RealVect Unit
Definition: RealVect.H:427
VoF-centered stencil.
Definition: Stencils.H:60
static void setMinVolumeFraction(Real a_minVolFrac)
Definition: EBArith.H:1080
A EBFaceFAB-like container for edge-centered fluxes.
Definition: EBFluxFAB.H:25
Definition: EBCellFAB.H:29
static VolIndex & getVoFMax()
Definition: EBArith.H:1071
double Real
Definition: REAL.H:33
static Real & getValMax()
Definition: EBArith.H:1075
A BoxLayout that has a concept of disjointedness.
Definition: DisjointBoxLayout.H:30
LoHiSide
Definition: LoHiSide.H:27
Definition: EBArith.H:52
void loHiCenter(Box &a_loBox, int &a_hasLo, Box &a_hiBox, int &a_hasHi, Box &a_centerBox, Box &a_entireBox, const Box &a_inBox, const ProblemDomain &a_domain, const int &a_dir)
Definition: EBArith.H:53
A Rectangular Domain on an Integer Lattice.
Definition: Box.H:469
A Real vector in SpaceDim-dimensional space.
Definition: RealVect.H:41
static Real s_minVolFrac
Definition: EBArith.H:1088
Definition: BaseIFFAB.H:34
Real computeSum(const Vector< LevelData< FArrayBox > * > &a_phi, const Vector< int > &a_nRefFine, const Real &a_dxCrse, const Interval &a_comps=Interval(0, 0), const int &a_lBase=0)
Returns the volume-weighted sum (integral) of phi over all valid regions.
An integer Vector in SpaceDim-dimensional space.
Definition: CHArray.H:42
Definition: EBArith.H:63
Volume of Fluid Index.
Definition: VolIndex.H:31
static RealVect getVoFLocation(const VolIndex &a_vof, const Real &a_dx, const RealVect &a_probLo)
I have misspelled this one time too many.
Definition: EBArith.H:631
Definition: EBISLayout.H:39
Box ebrefine(const Box &b, int refinement_ratio)
Definition: EBArith.H:54
NormMode
Definition: EBArith.H:50
static RealVect getVoFLocation(const VolIndex &a_vof, const RealVect &a_dx, const RealVect &a_probLo)
I have misspelled this one time too many.
Definition: EBArith.H:623
static Real s_valMax
Definition: EBArith.H:1087
static RealVect getFaceLocation(const FaceIndex &a_face, const Real &a_dx, const RealVect &a_probLo)
gets the location in real space of a face center
Definition: EBArith.H:597