Chombo + EB  3.2
GeometryService.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 // ANAG, LBNL, DTG
12 
13 #ifndef _GEOMETRYSERVICE_H_
14 #define _GEOMETRYSERVICE_H_
15 
16 #include <cmath>
17 #include <cstdlib>
18 
19 #include "REAL.H"
20 #include "LoHiSide.H"
21 #include "RealVect.H"
22 #include "Box.H"
23 #include "IntVect.H"
24 
25 #include "EBISBox.H"
26 #include "VolIndex.H"
27 #include "FaceIndex.H"
28 #include "IrregNode.H"
29 #include "DisjointBoxLayout.H"
30 #include "NamespaceHeader.H"
31 
32 ///
33 /**
34  This is a pure base class that EBIndexSpace uses
35  to interface with geometry-generation classes.
36  */
38 {
39 public:
40 
41  enum InOut
42  {
46  };
47 
49 
50  virtual ~GeometryService();
51 
52  ///
53  /**
54  Return true if every cell in region is regular at the
55  refinement described by dx.
56  */
57  virtual bool isRegular(const Box& a_region,
58  const ProblemDomain& a_domain,
59  const RealVect& a_origin,
60  const Real& a_dx) const = 0;
61 
62  ///
63  /**
64  Return true if every cell in region is covered at the
65  refinement described by dx.
66  */
67  virtual bool isCovered(const Box& a_region,
68  const ProblemDomain& a_domain,
69  const RealVect& a_origin,
70  const Real& a_dx) const = 0;
71 
72  virtual bool isIrregular(const Box& a_region,
73  const ProblemDomain& a_domain,
74  const RealVect& a_origin,
75  const Real& a_dx) const ;
76  ///
77  /**
78  irregGraph contains a complete list of irregular vofs. \\
79  validRegion is the the region of the graph \\
80  domain is the domain of compuation \\
81  regIrregCovered = 1 for regular, 0 for irregular, -1 for covered.
82  regIrregCovered must contain the valid region grown by 1. \\
83  In chombospeak, \\
84  ghostregion = (grow(validRegion, 1) & domain);
85  */
86  /*
87  virtual void fillGraph(BaseFab<int>& a_regIrregCovered,
88  Vector<IrregNode>& a_nodes,
89  const Box& a_validRegion,
90  const Box& a_ghostRegion,
91  const ProblemDomain& a_domain,
92  const RealVect& a_origin,
93  const Real& a_dx) const = 0;
94  */
95 
96  ///
97  /**
98  This overloaded method will be called when the GeometryService
99  was asked to make the grids with makeGrids()
100  */
101  virtual void fillGraph(BaseFab<int>& a_regIrregCovered,
102  Vector<IrregNode>& a_nodes,
103  const Box& a_validRegion,
104  const Box& a_ghostRegion,
105  const ProblemDomain& a_domain,
106  const RealVect& a_origin,
107  const Real& a_dx,
108  const DataIndex& a_di ) const = 0;
109  // {
110  // return fillGraph( a_regIrregCovered, a_nodes, a_validRegion, a_ghostRegion,
111  // a_domain, a_origin, a_dx );
112  // }
113 
114 
115  virtual bool canGenerateMultiCells() const;
116 
117  virtual InOut InsideOutside(const Box& a_region,
118  const ProblemDomain& a_domain,
119  const RealVect& a_origin,
120  const Real& a_dx) const ;
121 
122 
123  ///return true if the geometry service generates higher order moments
124  /**
125  Most of the geometry generating objects we have do *not* generate higher order
126  moments (they only generate the standard stuff (volume fractions, area fractions and centroids)).
127  WrappedGShop, does generate the higher order stuff so that one can return true;
128  */
129  virtual bool generatesHigherOrderMoments() const
130  {
131  return false;
132  }
133 
134 
135  ///
136  /**
137  This overloaded method will be called when the GeometryService
138  was asked to make the grids with makeGrids()
139  */
140 
141  virtual InOut InsideOutside(const Box& a_region,
142  const ProblemDomain& a_domain,
143  const RealVect& a_origin,
144  const Real& a_dx,
145  const DataIndex& a_di ) const
146  {
147  return InsideOutside( a_region, a_domain, a_origin, a_dx );
148  }
149 
150  ///handy functions to do rectangle intersections in real space
151  static bool intersection(const RealVect& a_lo1, const RealVect& a_hi1,
152  const RealVect& a_lo2, const RealVect& a_hi2);
153 
154  static bool intersection(const Box& a_region,
155  const RealVect& a_origin,
156  const Real& a_dx,
157  const RealVect& a_lower,
158  const RealVect& a_upper);
159 
160 
161  /** Perform any adjustments needed after box layout is created during EBISLevel construction
162  This function is used because subclasses may have distributed data that they will
163  want to adjust based on the new layout. The default implementation is empty.
164  */
165  virtual void postMakeBoxLayout(const DisjointBoxLayout& a_dbl,
166  const RealVect& a_dx);
167 
168 
169  ///
170  /**
171  A GeometryService has three options for implementing this function
172  1) do nothing, allow the empty base implementation to remain in place as a null-op
173  2) take the makeGrids call as a directive: Here are the grids EBIndexSpace is wanting to use, configure
174  yourself accordingly to make this efficient for you.
175  3) discard the DisjointBoxLayout EBIndexSpace would like and insert your own implementation of layout
176  EBIndexSpace will faithfully use a_grids returned from this function, including it's load balance.
177  */
178  virtual void makeGrids( const ProblemDomain& a_domain,
179  DisjointBoxLayout& a_grids,
180  const int& a_maxGridSize,
181  const int& a_maxIrregGridSize )
182  { // default implementation of makeGrids is to ignore it. GeometryService is ignorant of BoxLayouts
183  // or load balances and just answers geometric queries
184  }
185 
186 protected:
187 
188 };
189 #include "NamespaceFooter.H"
190 #endif
A class to facilitate interaction with physical boundary conditions.
Definition: ProblemDomain.H:141
virtual bool canGenerateMultiCells() const
one dimensional dynamic array
Definition: Vector.H:53
Definition: GeometryService.H:43
virtual ~GeometryService()
virtual bool isIrregular(const Box &a_region, const ProblemDomain &a_domain, const RealVect &a_origin, const Real &a_dx) const
InOut
Definition: GeometryService.H:41
virtual void fillGraph(BaseFab< int > &a_regIrregCovered, Vector< IrregNode > &a_nodes, const Box &a_validRegion, const Box &a_ghostRegion, const ProblemDomain &a_domain, const RealVect &a_origin, const Real &a_dx, const DataIndex &a_di) const =0
Definition: GeometryService.H:44
virtual bool isRegular(const Box &a_region, const ProblemDomain &a_domain, const RealVect &a_origin, const Real &a_dx) const =0
virtual bool isCovered(const Box &a_region, const ProblemDomain &a_domain, const RealVect &a_origin, const Real &a_dx) const =0
double Real
Definition: REAL.H:33
Definition: GeometryService.H:37
static bool intersection(const RealVect &a_lo1, const RealVect &a_hi1, const RealVect &a_lo2, const RealVect &a_hi2)
handy functions to do rectangle intersections in real space
A BoxLayout that has a concept of disjointedness.
Definition: DisjointBoxLayout.H:30
A Rectangular Domain on an Integer Lattice.
Definition: Box.H:465
A Real vector in SpaceDim-dimensional space.
Definition: RealVect.H:41
Definition: GeometryService.H:45
Definition: DataIndex.H:112
virtual InOut InsideOutside(const Box &a_region, const ProblemDomain &a_domain, const RealVect &a_origin, const Real &a_dx) const
virtual InOut InsideOutside(const Box &a_region, const ProblemDomain &a_domain, const RealVect &a_origin, const Real &a_dx, const DataIndex &a_di) const
Definition: GeometryService.H:141
virtual void makeGrids(const ProblemDomain &a_domain, DisjointBoxLayout &a_grids, const int &a_maxGridSize, const int &a_maxIrregGridSize)
Definition: GeometryService.H:178
virtual bool generatesHigherOrderMoments() const
return true if the geometry service generates higher order moments
Definition: GeometryService.H:129
virtual void postMakeBoxLayout(const DisjointBoxLayout &a_dbl, const RealVect &a_dx)