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