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 : #ifndef __H__UG_smooth_projector
34 : #define __H__UG_smooth_projector
35 :
36 : #include "refinement_projector.h"
37 :
38 : namespace ug{
39 :
40 :
41 : /// Smoothes vertices during refinement
42 : class SmoothProjector : public RefinementProjector {
43 : public:
44 0 : SmoothProjector () :
45 0 : m_iterations (10),
46 0 : m_changeRate (0.25)
47 : {}
48 :
49 : SmoothProjector (int iterations,
50 0 : number changeRate) :
51 0 : m_iterations (iterations),
52 0 : m_changeRate (changeRate)
53 : {}
54 :
55 : /** \sa ug::RefinementProjector::RefinementProjector*/
56 0 : SmoothProjector (SPIGeometry3d geometry,
57 : int iterations,
58 0 : number changeRate) :
59 : RefinementProjector (geometry),
60 0 : m_iterations (iterations),
61 0 : m_changeRate (changeRate)
62 0 : {}
63 :
64 0 : int iterations () const {return m_iterations;}
65 0 : void set_iterations (int iterations) {m_iterations = iterations;}
66 :
67 0 : number change_rate () const {return m_changeRate;}
68 0 : void set_change_rate (number changeRate) {m_changeRate = changeRate;}
69 :
70 : /// called before refinement begins
71 0 : virtual void refinement_begins(const ISubGrid* sg)
72 : {
73 0 : RefinementProjector::refinement_begins(sg);
74 : m_newVrts.clear();
75 0 : }
76 :
77 : /// called when refinement is done.
78 : /** The actual smoothing is performed here*/
79 : virtual void refinement_ends();
80 :
81 : /// called when a new vertex was created from an old edge.
82 0 : virtual number new_vertex(Vertex* vrt, Edge* parent)
83 : {
84 0 : m_newVrts.push_back(vrt);
85 0 : return RefinementProjector::new_vertex(vrt, parent);
86 : }
87 :
88 : /// called when a new vertex was created from an old face.
89 0 : virtual number new_vertex(Vertex* vrt, Face* parent)
90 : {
91 0 : m_newVrts.push_back(vrt);
92 0 : return RefinementProjector::new_vertex(vrt, parent);
93 : }
94 :
95 : /// called when a new vertex was created from an old volume.
96 0 : virtual number new_vertex(Vertex* vrt, Volume* parent)
97 : {
98 0 : m_newVrts.push_back(vrt);
99 0 : return RefinementProjector::new_vertex(vrt, parent);
100 : }
101 :
102 : private:
103 : friend class boost::serialization::access;
104 :
105 : template <class Archive>
106 : void serialize( Archive& ar, const unsigned int version)
107 : {
108 0 : ar & make_nvp("iterations", m_iterations);
109 0 : ar & make_nvp("change rate", m_changeRate);
110 : UG_EMPTY_BASE_CLASS_SERIALIZATION(SmoothProjector, RefinementProjector);
111 : }
112 :
113 : std::vector<Vertex*> m_newVrts;
114 : int m_iterations;
115 : number m_changeRate;
116 : };
117 :
118 : }// end of namespace
119 :
120 : #endif //__H__UG_smooth_projector
|