Debian Codegraph @

bench/geometry/bounding_box_tree_compute_closest_entity/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 1000000
29 #define SIZE 64
30
31 int main(int argc, char* argv[])
32 {
33 info("Compute closest entity 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(-1.0, -1.0, 0.0);
43 tree.compute_closest_entity(point);
44 cout << "Built tree, searching for closest point" << endl;
45
46 // Call repeatedly
47 tic();
48 for (int i = 0; i < NUM_REPS; i++)
49 {
50 tree.compute_closest_entity(point);
51 point.coordinates()[1] += 2.0 / static_cast<double>(NUM_REPS);
52 }
53 const double t = toc();
54
55 // Report result
56 info("BENCH %g", t);
57
58 return 0;
59 }