Line data Source code
1 : /*
2 : * Copyright (c) 2011-2015: G-CSC, Goethe University Frankfurt
3 : * Author: Andreas Vogel
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 "mg_solver.h"
34 :
35 : namespace ug{
36 :
37 :
38 : ////////////////////////////////////////////////////////////////////////////////
39 : // SelectNonShadowsAdjacentToShadowsOnLevel
40 : ////////////////////////////////////////////////////////////////////////////////
41 :
42 0 : void SelectNonShadowsAdjacentToShadowsOnLevel(BoolMarker& sel,
43 : const SurfaceView& surfView,
44 : int level)
45 : {
46 : PROFILE_FUNC_GROUP("gmg");
47 : // vectors for associated elements
48 : std::vector<Vertex*> vAssVertex;
49 : std::vector<Edge*> vAssEdge;
50 : std::vector<Face*> vAssFace;
51 : std::vector<Volume*> vAssVolume;
52 :
53 : // get grid
54 : Grid& grid = *sel.grid();
55 :
56 : // get multigrid
57 0 : MultiGrid* mg = dynamic_cast<MultiGrid*>(&grid);
58 :
59 : // check multigrid
60 0 : if(mg == NULL)
61 0 : UG_THROW("SelectNonShadowsAdjacentToShadowsOnLevel: No "
62 : "Multigrid given, selection on level not possible.");
63 :
64 : // check level
65 0 : if(level >= (int) mg->num_levels() || level < 0)
66 0 : UG_THROW("SelectNonShadowsAdjacentToShadowsOnLevel: Requested "
67 : "level "<<level<<" does not exist in Multigrid.");
68 :
69 : const GridLevel gl(GridLevel::TOP, GridLevel::SURFACE);
70 :
71 : // iterator type
72 : geometry_traits<Vertex>::const_iterator iter, iterEnd;
73 :
74 0 : iterEnd = mg->end<Vertex>(level);
75 :
76 : // loop all base elems
77 0 : for(iter = mg->begin<Vertex>(level); iter != iterEnd; ++iter)
78 : {
79 : // get element
80 : Vertex* shadow = *iter;
81 :
82 : // check if element is a shadow
83 0 : if(!surfView.is_shadowed(shadow)) continue;
84 :
85 : // get adjacent elements
86 : CollectAssociated(vAssEdge, grid, shadow);
87 :
88 : vAssVertex.clear();
89 0 : for(size_t i = 0; i < vAssEdge.size(); ++i)
90 0 : CollectAssociated(vAssVertex, grid, vAssEdge[i], false);
91 :
92 : vAssEdge.clear();
93 : vAssFace.clear();
94 : vAssVolume.clear();
95 0 : for(size_t i = 0; i < vAssVertex.size(); ++i)
96 : {
97 0 : CollectAssociated(vAssEdge, grid, vAssVertex[i], false);
98 0 : CollectAssociated(vAssFace, grid, vAssVertex[i], false);
99 0 : CollectAssociated(vAssVolume, grid, vAssVertex[i], false);
100 : }
101 :
102 : // select associated elements
103 0 : for(size_t i = 0; i < vAssVertex.size(); ++i)
104 0 : if(surfView.is_contained(vAssVertex[i], gl, SurfaceView::SURFACE))
105 0 : sel.mark(vAssVertex[i]);
106 0 : for(size_t i = 0; i < vAssEdge.size(); ++i)
107 0 : if(surfView.is_contained(vAssEdge[i], gl, SurfaceView::SURFACE))
108 0 : sel.mark(vAssEdge[i]);
109 0 : for(size_t i = 0; i < vAssFace.size(); ++i)
110 0 : if(surfView.is_contained(vAssFace[i], gl, SurfaceView::SURFACE))
111 0 : sel.mark(vAssFace[i]);
112 0 : for(size_t i = 0; i < vAssVolume.size(); ++i)
113 0 : if(surfView.is_contained(vAssVolume[i], gl, SurfaceView::SURFACE))
114 0 : sel.mark(vAssVolume[i]);
115 : }
116 0 : }
117 :
118 : } // end namespace ug
|