Line data Source code
1 : /*
2 : * Copyright (c) 2009-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 "common/util/vec_for_each.h"
34 : #include "misc_util.h"
35 :
36 : namespace ug
37 : {
38 :
39 : ////////////////////////////////////////////////////////////////////////
40 : // EraseConnectingElements
41 : /// erases all elements that connect v1 and v2
42 0 : void EraseConnectingElements(Grid& grid, Vertex* v1, Vertex* v2)
43 : {
44 : // check volumes for direct connection
45 0 : if(grid.num_volumes() > 0)
46 : {
47 : // iterate through associated volumes
48 : std::vector<Volume*> vols;
49 0 : CollectVolumes(vols, grid, v1);
50 0 : for_each_in_vec(Volume* v, vols){
51 0 : uint numVrts = v->num_vertices();
52 : bool gotOne = false;
53 0 : for(uint i = 0; i < numVrts; ++i)
54 : {
55 0 : if(v->vertex(i) == v2)
56 : {
57 : gotOne = true;
58 : break;
59 : }
60 : }
61 :
62 0 : if(gotOne == true)
63 0 : grid.erase(v);
64 : }end_for;
65 0 : }
66 :
67 : // check faces for direct connection.
68 0 : if(grid.num_faces() > 0)
69 : {
70 : // iterate through associated faces
71 : std::vector<Face*> faces;
72 0 : CollectFaces(faces, grid, v1);
73 0 : for_each_in_vec(Face* f, faces){
74 0 : uint numVrts = f->num_vertices();
75 : bool gotOne = false;
76 0 : for(uint i = 0; i < numVrts; ++i)
77 : {
78 0 : if(f->vertex(i) == v2)
79 : {
80 : gotOne = true;
81 : break;
82 : }
83 : }
84 :
85 0 : if(gotOne == true)
86 0 : grid.erase(f);
87 : }end_for;
88 0 : }
89 :
90 : // check edges
91 0 : if(grid.num_edges() > 0)
92 : {
93 : // iterate through associated edges
94 : std::vector<Edge*> edges;
95 0 : CollectEdges(edges, grid, v1);
96 0 : for_each_in_vec(Edge* e, edges){
97 : // if e contains v2 we have to remove it.
98 0 : if((e->vertex(0) == v2) || (e->vertex(1) == v2))
99 : {
100 0 : grid.erase(e);
101 : }
102 : }end_for;
103 0 : }
104 0 : }
105 :
106 : }// end of namespace
|