chombo-discharge
CD_ScanShopImplem.H
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_ScanShopImplem_H
13 #define CD_ScanShopImplem_H
14 
15 // Our includes
16 #include <CD_ScanShop.H>
17 #include <CD_NamespaceHeader.H>
18 
19 inline bool
20 ScanShop::isRegular(const Box a_box, const RealVect a_probLo, const Real a_dx) const
21 {
22  CH_TIME("ScanShop::isRegular(Box, RealVect, Real)");
23 
24  bool ret = true;
25 
26  for (BoxIterator bit(a_box); bit.ok(); ++bit) {
27  const RealVect a_point = a_probLo + a_dx * (0.5 * RealVect::Unit + RealVect(bit()));
28  if (m_baseIF->value(a_point) >= -0.5 * a_dx * sqrt(SpaceDim)) {
29  ret = false;
30 
31  break;
32  }
33  }
34 
35  return ret;
36 }
37 
38 inline bool
39 ScanShop::isCovered(const Box a_box, const RealVect a_probLo, const Real a_dx) const
40 {
41  CH_TIME("ScanShop::isCovered(Box, RealVect, Real)");
42 
43  bool ret = true;
44 
45  for (BoxIterator bit(a_box); bit.ok(); ++bit) {
46  const RealVect a_point = a_probLo + a_dx * (0.5 * RealVect::Unit + RealVect(bit()));
47  if (m_baseIF->value(a_point) <= 0.5 * a_dx * sqrt(SpaceDim)) {
48  ret = false;
49 
50  break;
51  }
52  }
53 
54  return ret;
55 }
56 
57 inline std::vector<std::pair<Box, int>>
58 ScanShop::getSortedBoxesAndTypes(const Vector<Box>& a_boxes, const Vector<int>& a_types) const
59 {
60 
61  std::vector<std::pair<Box, int>> sortedBoxesAndTypes;
62 
63  for (int i = 0; i < a_boxes.size(); i++) {
64  sortedBoxesAndTypes.emplace_back(std::make_pair(a_boxes[i], a_types[i]));
65  }
66 
67  auto comparator = [](const std::pair<Box, int>& a, const std::pair<Box, int>& b) -> bool {
68  return a.first < b.first;
69  };
70 
71  std::sort(sortedBoxesAndTypes.begin(), sortedBoxesAndTypes.end(), comparator);
72 
73  return sortedBoxesAndTypes;
74 }
75 
76 #endif
77 
78 #include <CD_NamespaceFooter.H>
Declare a class geometry generation (ScanShop) that uses the signed distance function for optimizatio...
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
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
const BaseIF * m_baseIF
Implicit function used to generate geometrys.
Definition: CD_ScanShop.H:160
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