chombo-discharge
Loading...
Searching...
No Matches
CD_ScanShopImplem.H
1/*
2 * SPDX-FileCopyrightText: 2021-2026 SINTEF Energy Research
3 *
4 * SPDX-License-Identifier: GPL-3.0-or-later
5 @return True if regular, false otherwise
6 */
7
15#ifndef CD_SCANSHOPIMPLEM_H
16#define CD_SCANSHOPIMPLEM_H
17
18// Our includes
19#include <CD_ScanShop.H>
20#include <CD_NamespaceHeader.H>
21
22inline bool
24{
25 CH_TIME("ScanShop::isRegular(Box, RealVect, Real)");
26
27 // Short-circuit search over the box: a direct index loop with early return rather than a BoxLoops::loop,
28 // since BoxLoops::loop cannot break early and m_baseIF->value(...) is expensive.
29#if CH_SPACEDIM == 3
30 for (int k = a_box.smallEnd(2); k <= a_box.bigEnd(2); k++) {
31#endif
32 for (int j = a_box.smallEnd(1); j <= a_box.bigEnd(1); j++) {
33 for (int i = a_box.smallEnd(0); i <= a_box.bigEnd(0); i++) {
34 const RealVect point = a_probLo + a_dx * (0.5 * RealVect::Unit + RealVect(IntVect(D_DECL(i, j, k))));
35 if (m_baseIF->value(point) >= -0.5 * a_dx * sqrt(SpaceDim)) {
36 return false;
37 }
38 }
39 }
40#if CH_SPACEDIM == 3
41 }
42#endif
43
44 return true;
45}
46
47inline bool
49{
50 CH_TIME("ScanShop::isCovered(Box, RealVect, Real)");
51
52 // Short-circuit search over the box: a direct index loop with early return rather than a BoxLoops::loop,
53 // since BoxLoops::loop cannot break early and m_baseIF->value(...) is expensive.
54#if CH_SPACEDIM == 3
55 for (int k = a_box.smallEnd(2); k <= a_box.bigEnd(2); k++) {
56#endif
57 for (int j = a_box.smallEnd(1); j <= a_box.bigEnd(1); j++) {
58 for (int i = a_box.smallEnd(0); i <= a_box.bigEnd(0); i++) {
59 const RealVect point = a_probLo + a_dx * (0.5 * RealVect::Unit + RealVect(IntVect(D_DECL(i, j, k))));
60 if (m_baseIF->value(point) <= 0.5 * a_dx * sqrt(SpaceDim)) {
61 return false;
62 }
63 }
64 }
65#if CH_SPACEDIM == 3
66 }
67#endif
68
69 return true;
70}
71
74{
75
77
78 for (int i = 0; i < a_boxes.size(); i++) {
80 }
81
82 auto comparator = [](const std::pair<Box, int>& a, const std::pair<Box, int>& b) -> bool {
83 return a.first < b.first;
84 };
85
86 std::sort(sortedBoxesAndTypes.begin(), sortedBoxesAndTypes.end(), comparator);
87
89}
90
91#endif
92
93#include <CD_NamespaceFooter.H>
Declare a class geometry generation (ScanShop) that uses the signed distance function for optimizatio...
bool isRegular(Box a_box, const RealVect &a_probLo, Real a_dx) const
Check if every point in input box is regular.
Definition CD_ScanShopImplem.H:23
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:73
const BaseIF * m_baseIF
Implicit function used to generate geometries.
Definition CD_ScanShop.H:189
bool isCovered(Box a_box, const RealVect &a_probLo, Real a_dx) const
Check if every point in box is covered.
Definition CD_ScanShopImplem.H:48
Base class for a tracer particle solver. This solver can advance particles in a pre-defined velocity ...
Definition CD_TracerParticleSolver.H:38
TracerParticleSolver()
Default constructor.
Definition CD_TracerParticleSolverImplem.H:26