Debian Codegraph @

bench/geometry/bounding_box_tree_compute_entity_collisions/cpp/main.cpp

raw
1 // Copyright (C) 2013 Anders Logg
2 //
3 // This file is part of DOLFIN.
4 //
5 // DOLFIN is free software: you can redistribute it and/or modify
6 // it under the terms of the GNU Lesser General Public License as published by
7 // the Free Software Foundation, either version 3 of the License, or
8 // (at your option) any later version.
9 //
10 // DOLFIN is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 // GNU Lesser General Public License for more details.
14 //
15 // You should have received a copy of the GNU Lesser General Public License
16 // along with DOLFIN. If not, see <http://www.gnu.org/licenses/>.
17 //
18 // This benchmark measures the performance of compute_entity_collisions.
19 //
20 // First added: 2013-05-23
21 // Last changed: 2013-09-04
22
23 #include <vector>
24 #include <dolfin.h>
25
26 using namespace dolfin;
27
28 #define NUM_REPS 5000000
29 #define SIZE 64
30
31 int main(int argc, char* argv[])
32 {
33 info("Compute entity collisions on UnitCubeMesh(%d, %d, %d)",
34 SIZE, SIZE, SIZE);
35
36 // Create mesh
37 UnitCubeMesh mesh(SIZE, SIZE, SIZE);
38
39 // First call
40 BoundingBoxTree tree;
41 tree.build(mesh);
42 Point point(0.0, 0.0, 0.0);
43 tree.compute_entity_collisions(point);
44
45 // Call repeatedly
46 tic();
47 for (int i = 0; i < NUM_REPS; i++)
48 {
49 point.coordinates()[0] += 1.0 / static_cast<double>(NUM_REPS);
50 point.coordinates()[1] += 1.0 / static_cast<double>(NUM_REPS);
51 point.coordinates()[2] += 1.0 / static_cast<double>(NUM_REPS);
52 std::vector<unsigned int> entities = tree.compute_entity_collisions(point);
53 }
54 const double t = toc();
55
56 // Report result
57 info("BENCH %g", t);
58
59 return 0;
60 }