Line data Source code
1 : /*
2 : * Copyright (c) 2016: 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 "smooth_projector.h"
34 :
35 : namespace ug{
36 :
37 0 : void SmoothProjector::
38 : refinement_ends ()
39 : {
40 : Grid::edge_traits::secure_container edges;
41 : Grid::face_traits::secure_container faces;
42 : Grid::volume_traits::secure_container volumes;
43 :
44 : Grid& grid = geom().grid();
45 :
46 : std::vector<Vertex*> localNbrs;
47 :
48 0 : for(int iteration = 0; iteration < m_iterations; ++iteration){
49 0 : for(size_t inewVrt = 0; inewVrt < m_newVrts.size(); ++inewVrt){
50 0 : Vertex* vrt = m_newVrts[inewVrt];
51 : localNbrs.clear();
52 : grid.associated_elements(edges, vrt);
53 : grid.associated_elements(faces, vrt);
54 : grid.associated_elements(volumes, vrt);
55 :
56 0 : grid.begin_marking();
57 : grid.mark(vrt);
58 0 : for(size_t iass = 0; iass < edges.size(); ++iass){
59 : Edge* e = edges[iass];
60 0 : for(size_t ivrt = 0; ivrt < e->num_vertices(); ++ivrt){
61 0 : Vertex* nbr = e->vertex(ivrt);
62 0 : if(!grid.is_marked(nbr)){
63 : grid.mark(nbr);
64 0 : localNbrs.push_back(nbr);
65 : }
66 : }
67 : }
68 0 : for(size_t iass = 0; iass < faces.size(); ++iass){
69 : Face* e = faces[iass];
70 0 : for(size_t ivrt = 0; ivrt < e->num_vertices(); ++ivrt){
71 0 : Vertex* nbr = e->vertex(ivrt);
72 0 : if(!grid.is_marked(nbr)){
73 : grid.mark(nbr);
74 0 : localNbrs.push_back(nbr);
75 : }
76 : }
77 : }
78 0 : for(size_t iass = 0; iass < volumes.size(); ++iass){
79 : Volume* e = volumes[iass];
80 0 : for(size_t ivrt = 0; ivrt < e->num_vertices(); ++ivrt){
81 0 : Vertex* nbr = e->vertex(ivrt);
82 0 : if(!grid.is_marked(nbr)){
83 : grid.mark(nbr);
84 0 : localNbrs.push_back(nbr);
85 : }
86 : }
87 : }
88 0 : grid.end_marking();
89 :
90 : const size_t numNbrs = localNbrs.size();
91 0 : if(numNbrs > 0){
92 0 : number wgt = m_changeRate / (number)numNbrs;
93 : vector3 weigtedCenter(0, 0, 0);
94 0 : for_each_in_vec(Vertex* nbr, localNbrs){
95 : vector3 nbrPos = pos(nbr);
96 : nbrPos *= wgt;
97 : weigtedCenter += nbrPos;
98 : }end_for;
99 :
100 : vector3 newPos = pos(vrt);
101 0 : newPos *= (1. - m_changeRate);
102 : newPos += weigtedCenter;
103 : set_pos(vrt, newPos);
104 : }
105 : }
106 : }
107 0 : }
108 :
109 : }// end of namespace
|