chombo-discharge
CD_ScanShop.H
Go to the documentation of this file.
1 /* chombo-discharge
2  * Copyright © 2021 SINTEF Energy Research.
3  * Please refer to Copyright.txt and LICENSE in the chombo-discharge root directory.
4  */
5 
12 #ifndef CD_ScanShop_H
13 #define CD_ScanShop_H
14 
15 // Chombo includes
16 #include <GeometryShop.H>
17 #include <GeometryService.H>
18 
19 // Our includes
20 #include <CD_Timer.H>
21 #include <CD_BoxSorting.H>
22 #include <CD_NamespaceHeader.H>
23 
29 class ScanShop : public GeometryShop
30 {
31 public:
35  ScanShop() = delete;
36 
48  ScanShop(const BaseIF& a_geometry,
49  const int a_verbosity,
50  const Real a_finestDx,
51  const RealVect a_probLo,
52  const ProblemDomain a_finestDomain,
53  const ProblemDomain a_scanLevel,
54  const int a_ebGhost = 4,
55  const Real a_thrshdVoF = 1.0e-16);
56 
60  ~ScanShop();
61 
65  void
66  setProfileFileName(const std::string a_fileName);
67 
76  void
77  makeGrids(const ProblemDomain& a_domain,
78  DisjointBoxLayout& a_grids,
79  const int& a_maxGridSize,
80  const int& a_maxIrregGridSize) override;
81 
92  GeometryService::InOut
93  InsideOutside(const Box& a_region,
94  const ProblemDomain& a_domain,
95  const RealVect& a_probLo,
96  const Real& a_dx,
97  const DataIndex& a_dit) const override;
98 
111  virtual void
112  fillGraph(BaseFab<int>& a_regIrregCovered,
113  Vector<IrregNode>& a_nodes,
114  const Box& a_validRegion,
115  const Box& a_ghostRegion,
116  const ProblemDomain& a_domain,
117  const RealVect& a_probLo,
118  const Real& a_dx,
119  const DataIndex& a_di) const override;
120 
121 protected:
125  std::string m_fileName;
126 
131 
135  mutable Timer m_timer;
136 
140  bool m_profile;
141 
146 
151 
155  RealVect m_probLo;
156 
160  const BaseIF* m_baseIF;
161 
166 
170  Vector<Real> m_dx;
171 
175  Vector<ProblemDomain> m_domains;
176 
180  Vector<DisjointBoxLayout> m_grids;
181 
186  Vector<RefCountedPtr<LayoutData<GeometryService::InOut>>> m_boxMap;
187 
191  std::vector<bool> m_hasThisLevel;
192 
200  void
201  makeDomains(const Real a_dx,
202  const RealVect a_probLo,
203  const ProblemDomain a_finestDomain,
204  const ProblemDomain a_scanLevel);
205 
211  void
212  buildFinerLevels(const int a_coarserLevel, const int a_maxGridSize);
213 
221  void
222  buildCoarseLevel(const int a_finerLevel, const int a_maxGridSize);
223 
230  inline bool
231  isRegular(const Box a_box, const RealVect a_probLo, const Real a_dx) const;
232 
239  inline bool
240  isCovered(const Box a_box, const RealVect a_probLo, const Real a_dx) const;
241 
246  inline std::vector<std::pair<Box, int>>
247  getSortedBoxesAndTypes(const Vector<Box>& a_boxes, const Vector<int>& a_types) const;
248 
252  void
253  defineLevel(Vector<Box>& coveredBoxes, Vector<Box>& regularBoxes, Vector<Box>& cutCellBoxes, const int a_level);
254 };
255 
256 #include <CD_NamespaceFooter.H>
257 
258 #include <CD_ScanShopImplem.H>
259 
260 #endif
Declaration of an enum for identifying various ways of sorting grid patches.
BoxSorting
Enum for sorting boxes.
Definition: CD_BoxSorting.H:21
Implementation of CD_Timer.H.
Derived version of GeometryShop that load balances based on the cut cells themselves.
Definition: CD_ScanShop.H:30
void makeDomains(const Real a_dx, const RealVect a_probLo, const ProblemDomain a_finestDomain, const ProblemDomain a_scanLevel)
Create the problem domain and resolutions.
Definition: CD_ScanShop.cpp:90
bool isCovered(const Box a_box, const RealVect a_probLo, const Real a_dx) const
Check if every point in box is covered.
Definition: CD_ScanShopImplem.H:39
Vector< RefCountedPtr< LayoutData< GeometryService::InOut > > > m_boxMap
Box maps.
Definition: CD_ScanShop.H:186
Vector< Real > m_dx
Level resolutions. Note that index 0 is the finest level.
Definition: CD_ScanShop.H:170
void buildCoarseLevel(const int a_finerLevel, const int a_maxGridSize)
Build the "coarse level" where we initiate the recursion process.
Definition: CD_ScanShop.cpp:194
void buildFinerLevels(const int a_coarserLevel, const int a_maxGridSize)
Refine levels recursively down to the finest level.
Definition: CD_ScanShop.cpp:269
std::string m_fileName
Set output file name (if doing profiling)
Definition: CD_ScanShop.H:125
int m_scanLevel
Scan level where we first begin to break up boxes. This is relative the EBIS level.
Definition: CD_ScanShop.H:145
int m_ebGhost
Maximum number of ghost cells near the EB.
Definition: CD_ScanShop.H:150
BoxSorting m_boxSorting
For arranging boxes in space when we load balance.
Definition: CD_ScanShop.H:130
~ScanShop()
Destructor (does nothing)
Definition: CD_ScanShop.cpp:71
void makeGrids(const ProblemDomain &a_domain, DisjointBoxLayout &a_grids, const int &a_maxGridSize, const int &a_maxIrregGridSize) override
This grid generation method is called by EBISLevel when using distributed data.
Definition: CD_ScanShop.cpp:133
Vector< DisjointBoxLayout > m_grids
Grids on each level, used for generating the EBIS information.
Definition: CD_ScanShop.H:180
void setProfileFileName(const std::string a_fileName)
If doing profiling, set the output name.
Definition: CD_ScanShop.cpp:82
bool m_profile
Bool for run-time profiling of ScanShop.
Definition: CD_ScanShop.H:140
std::vector< std::pair< Box, int > > getSortedBoxesAndTypes(const Vector< Box > &a_boxes, const Vector< int > &a_types) const
Sort boxes lexicographically.
Definition: CD_ScanShopImplem.H:58
RealVect m_probLo
Lower-left corner of simulation domain.
Definition: CD_ScanShop.H:155
const BaseIF * m_baseIF
Implicit function used to generate geometrys.
Definition: CD_ScanShop.H:160
Timer m_timer
Timer for when we use run-time profiling.
Definition: CD_ScanShop.H:135
void defineLevel(Vector< Box > &coveredBoxes, Vector< Box > &regularBoxes, Vector< Box > &cutCellBoxes, const int a_level)
Define the "box map" on a specified level.
Definition: CD_ScanShop.cpp:358
GeometryService::InOut InsideOutside(const Box &a_region, const ProblemDomain &a_domain, const RealVect &a_probLo, const Real &a_dx, const DataIndex &a_dit) const override
This method is called by EBSILevel when using distributed data.
Definition: CD_ScanShop.cpp:488
ScanShop()=delete
Disallowed default constructor.
std::vector< bool > m_hasThisLevel
Check if level has been scanned. 0 = false, != 0 implies true.
Definition: CD_ScanShop.H:191
bool isRegular(const Box a_box, const RealVect a_probLo, const Real a_dx) const
Check if every point in input box is regular.
Definition: CD_ScanShopImplem.H:20
bool m_hasScanLevel
Check if scan level has been built.
Definition: CD_ScanShop.H:165
Vector< ProblemDomain > m_domains
Level domains. Note that index 0 is the finest level.
Definition: CD_ScanShop.H:175
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_probLo, const Real &a_dx, const DataIndex &a_di) const override
Override of GeometryShop's fillGraph.
Definition: CD_ScanShop.cpp:531
Class which is used for run-time monitoring of events.
Definition: CD_Timer.H:31