7 #ifndef PORTAGE_SEARCH_SEARCH_SIMPLE_H_ 8 #define PORTAGE_SEARCH_SEARCH_SIMPLE_H_ 15 #include "wonton/support/Point.h" 34 double* xlow,
double* xhigh,
35 double* ylow,
double* yhigh)
37 const double big = 1.e99;
38 double xl = big;
double xh = -big;
39 double yl = big;
double yh = -big;
41 for (
const auto& p : cell_coord) {
42 const double x = p[0];
43 const double y = p[1];
44 xl = std::min(xl, x); xh = std::max(xh, x);
45 yl = std::min(yl, y); yh = std::max(yh, y);
48 *xlow = xl; *xhigh = xh;
49 *ylow = yl; *yhigh = yh;
67 template <
typename SourceMeshType,
typename TargetMeshType>
86 const TargetMeshType & target_mesh)
87 : sourceMesh_(source_mesh), targetMesh_(target_mesh) {
89 const int numCells = sourceMesh_.num_owned_cells() +
90 sourceMesh_.num_ghost_cells();
91 xlow_.reserve(numCells);
92 xhigh_.reserve(numCells);
93 ylow_.reserve(numCells);
94 yhigh_.reserve(numCells);
97 for (
int c = 0; c < numCells; ++c) {
98 std::vector<Point<2>> cell_coord;
99 sourceMesh_.cell_get_coordinates(c, &cell_coord);
101 &xlow_[c], &xhigh_[c],
102 &ylow_[c], &yhigh_[c]);
124 void operator() (
const int cellId, std::vector<int> *candidates)
const;
129 const SourceMeshType & sourceMesh_;
130 const TargetMeshType & targetMesh_;
131 std::vector<double> xlow_;
132 std::vector<double> xhigh_;
133 std::vector<double> ylow_;
134 std::vector<double> yhigh_;
140 template<
typename SourceMeshType,
typename TargetMeshType>
145 std::vector<Point<2>> cell_coord;
146 targetMesh_.cell_get_coordinates(cellId, &cell_coord);
147 double txlow, txhigh, tylow, tyhigh;
153 const int numCells = sourceMesh_.num_owned_cells() +
154 sourceMesh_.num_ghost_cells();
155 for (
int c = 0; c < numCells; ++c) {
156 if (std::max(txlow, xlow_[c]) < std::min(txhigh, xhigh_[c]) &&
157 std::max(tylow, ylow_[c]) < std::min(tyhigh, yhigh_[c])) {
158 candidates->push_back(c);
169 #endif // PORTAGE_SEARCH_SEARCH_SIMPLE_H_ file-local namespace
Definition: search_simple.h:19
SearchSimple(const SourceMeshType &source_mesh, const TargetMeshType &target_mesh)
Builds the search structure for finding intersection.
Definition: search_simple.h:85
std::vector< T > vector
Definition: portage.h:238
void getBoundingBox(const std::vector< Point< 2 >> &cell_coord, double *xlow, double *xhigh, double *ylow, double *yhigh)
Given a list of 2d coordinates, find the coordinates of the bounding box.
Definition: search_simple.h:32
Definition: coredriver.h:42
A simple, crude search algorithm that utilizes bounding boxes in 2d.
Definition: search_simple.h:68