Line data Source code
1 : /*
2 : * Copyright (c) 2015: G-CSC, Goethe University Frankfurt
3 : * Author: Sebastian Reiter
4 : *
5 : * This file is part of UG4.
6 : *
7 : * UG4 is free software: you can redistribute it and/or modify it under the
8 : * terms of the GNU Lesser General Public License version 3 (as published by the
9 : * Free Software Foundation) with the following additional attribution
10 : * requirements (according to LGPL/GPL v3 §7):
11 : *
12 : * (1) The following notice must be displayed in the Appropriate Legal Notices
13 : * of covered and combined works: "Based on UG4 (www.ug4.org/license)".
14 : *
15 : * (2) The following notice must be displayed at a prominent place in the
16 : * terminal output of covered works: "Based on UG4 (www.ug4.org/license)".
17 : *
18 : * (3) The following bibliography is recommended for citation and must be
19 : * preserved in all covered files:
20 : * "Reiter, S., Vogel, A., Heppner, I., Rupp, M., and Wittum, G. A massively
21 : * parallel geometric multigrid solver on hierarchically distributed grids.
22 : * Computing and visualization in science 16, 4 (2013), 151-164"
23 : * "Vogel, A., Reiter, S., Rupp, M., Nägel, A., and Wittum, G. UG4 -- a novel
24 : * flexible software system for simulating pde based models on high performance
25 : * computers. Computing and visualization in science 16, 4 (2013), 165-179"
26 : *
27 : * This program is distributed in the hope that it will be useful,
28 : * but WITHOUT ANY WARRANTY; without even the implied warranty of
29 : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
30 : * GNU Lesser General Public License for more details.
31 : */
32 :
33 : #include "grid_bridges.h"
34 : #include "common/space_partitioning/ntree_traverser.h"
35 : #include "lib_grid/algorithms/debug_util.h"
36 : #include "lib_grid/refinement/hanging_node_refiner_grid.h"
37 : #include "lib_grid/algorithms/space_partitioning/lg_ntree.h"
38 : #include "lib_grid/file_io/file_io.h"
39 : #include "lib_grid/grid_debug.h"
40 :
41 : using namespace std;
42 :
43 : namespace ug{
44 : namespace bridge{
45 :
46 0 : bool TestNTree(const char* filename)
47 : {
48 : PROFILE_FUNC_GROUP("grid");
49 0 : Grid g;
50 0 : SubsetHandler sh(g);
51 : APosition aPos = aPosition;
52 :
53 : PROFILE_BEGIN(ntree_loading);
54 0 : if(!LoadGridFromFile(g, sh, filename, aPos)){
55 0 : UG_LOG(" could not load " << filename << endl);
56 : return false;
57 : }
58 : PROFILE_END();
59 :
60 :
61 : typedef lg_ntree<3, 3, Volume> tree_t;
62 0 : tree_t tree(g, aPos);
63 :
64 : PROFILE_BEGIN(ntree_creating_tree);
65 0 : tree.create_tree(g.volumes_begin(), g.volumes_end());
66 : PROFILE_END();
67 :
68 : size_t lvl = FindLowestLeafNodeLevel(tree);
69 :
70 : UG_LOG("Lowest leaf-node-level: " << lvl << endl);
71 :
72 0 : pair<size_t, size_t> minMax = GetMinMaxNumElements(tree, lvl);
73 0 : UG_LOG("Min num elements: " << minMax.first << endl);
74 0 : UG_LOG("Max num elements: " << minMax.second << endl);
75 :
76 :
77 : const size_t numPicks = 1000000;
78 :
79 : UG_LOG("Picking elements for " << numPicks << " random points:\n");
80 0 : Volume* e = NULL;
81 : size_t numSuccesses = 0;
82 :
83 : PROFILE_BEGIN(ntree_picking_elements);
84 0 : for(size_t i = 0; i < numPicks; ++i){
85 : //vector2 p(urand<number>(-1, 1), urand<number>(-1, 1));
86 : vector3 p(urand<number>(-1, 1), urand<number>(-1, 1), urand<number>(-1, 1));
87 0 : if(FindContainingElement(e, tree, p)){
88 0 : ++numSuccesses;
89 : }
90 : }
91 : PROFILE_END();
92 :
93 : UG_LOG(" successes: " << numSuccesses << "\n");
94 0 : UG_LOG(" failures: " << numPicks - numSuccesses << "\n");
95 : return true;
96 0 : }
97 :
98 1 : void RegisterGridBridge_Misc(Registry& reg, string parentGroup)
99 : {
100 : string grp = parentGroup;
101 3 : reg.add_function("PrintGridElementNumbers", static_cast<void (*)(MultiGrid&)>(&PrintGridElementNumbers), grp)
102 3 : .add_function("PrintGridElementNumbers", static_cast<void (*)(Grid&)>(&PrintGridElementNumbers), grp)
103 3 : .add_function("PrintAttachmentInfo", &PrintAttachmentInfo, grp);
104 :
105 3 : reg.add_function("TestNTree", &TestNTree, grp);
106 :
107 3 : reg.add_function("CreateGridGlobalDebugInfoProvider", static_cast<void (*) (Grid&,ISubsetHandler&)>(&grid_global_debug_info_provider::create), grp);
108 1 : }
109 :
110 : }// end of namespace
111 : }// end of namespace
|