Line data Source code
1 : /*
2 : * Copyright (c) 2011-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 : #ifndef __H__UG__HANGING_NODE_REFINER_GRID__
34 : #define __H__UG__HANGING_NODE_REFINER_GRID__
35 :
36 : #include "hanging_node_refiner_base.h"
37 :
38 : namespace ug
39 : {
40 :
41 : /// \addtogroup lib_grid_algorithms_refinement
42 : /// @{
43 :
44 : /// Specialization of ug::HangingNodeRefiner for ug::Grid
45 : /** This class should be used, if hanging node refinement shall be
46 : * applied on a flat grid (ug::Grid).
47 : *
48 : * Marked elements will be replaced by their newly created children.
49 : *
50 : * Take a look at ug::HangingNodeRefinerBase for a more in-depth documentation.
51 : *
52 : * \sa ug::HangingNodeRefinerBase, ug::HangingNodeRefiner_Grid
53 : */
54 : class HangingNodeRefiner_Grid : public HangingNodeRefinerBase<Selector>
55 : {
56 : public:
57 : typedef HangingNodeRefinerBase<Selector> BaseClass;
58 : using HangingNodeRefinerBase<Selector>::mark;
59 :
60 : public:
61 : HangingNodeRefiner_Grid(SPRefinementProjector projector = SPNULL);
62 : HangingNodeRefiner_Grid(Grid& grid,
63 : SPRefinementProjector projector = SPNULL);
64 :
65 : virtual ~HangingNodeRefiner_Grid();
66 :
67 : virtual void grid_to_be_destroyed(Grid* grid);
68 :
69 : virtual void assign_grid(Grid& grid);
70 0 : virtual Grid* get_associated_grid() {return m_pGrid;}
71 0 : virtual Grid* grid() {return m_pGrid;}
72 :
73 0 : virtual bool adaptivity_supported() const {return true;}
74 0 : virtual bool coarsening_supported() const {return false;}
75 :
76 : /// Marks a vertex for refinement (ignores RM_COARSEN).
77 : virtual bool mark(Vertex* v, RefinementMark refMark = RM_REFINE);
78 :
79 : /// Marks an edge for refinement (ignores RM_COARSEN).
80 : virtual bool mark(Edge* e, RefinementMark refMark = RM_REFINE);
81 :
82 : /// Marks a face for refinement (ignores RM_COARSEN).
83 : virtual bool mark(Face* f, RefinementMark refMark = RM_REFINE);
84 :
85 : /// Marks a volume for refinement (ignores RM_COARSEN).
86 : virtual bool mark(Volume* v, RefinementMark refMark = RM_REFINE);
87 :
88 :
89 0 : virtual bool local_marks_supported() const {return true;}
90 :
91 : virtual void mark_local(Face* f, int localMark);
92 : virtual void mark_local(Volume* f, int localMark);
93 :
94 : virtual int get_local_mark(Face* f) const;
95 : virtual int get_local_mark(Volume* f) const;
96 :
97 : protected:
98 : void attach_local_marks();
99 :
100 : /// returns the number of (globally) marked edges on this level of the hierarchy
101 : virtual void num_marked_edges_local(std::vector<int>& numMarkedEdgesOut);
102 : /// returns the number of (globally) marked faces on this level of the hierarchy
103 : virtual void num_marked_faces_local(std::vector<int>& numMarkedFacesOut);
104 : /// returns the number of (globally) marked volumes on this level of the hierarchy
105 : virtual void num_marked_volumes_local(std::vector<int>& numMarkedVolsOut);
106 :
107 : template <class TElem>
108 : void num_marked_elems(std::vector<int>& numMarkedElemsOut);
109 :
110 : /// performs registration and deregistration at a grid.
111 : /** Initializes all grid related variables.
112 : * call set_grid(NULL) to unregister the observer from a grid.
113 : *
114 : * Please note that though the base grid features a set_grid method,
115 : * it is not declared virtual. This is because we want to call it
116 : * during construction and destruction.*/
117 : void set_grid(Grid* grid);
118 :
119 : virtual void collect_objects_for_refine();
120 :
121 : /// erases unused refined elements
122 : virtual void post_refine();
123 :
124 : virtual void process_constraining_edge(ConstrainingEdge* cge);
125 : virtual void refine_edge_with_normal_vertex(Edge* e,
126 : Vertex** newCornerVrts = NULL);
127 :
128 : virtual void refine_face_with_normal_vertex(Face* f,
129 : Vertex** newCornerVrts = NULL);
130 : virtual void process_constraining_face(ConstrainingFace* cgf);
131 :
132 : virtual void refine_volume_with_normal_vertex(Volume* v,
133 : Vertex** newVolumeVrts = NULL);
134 :
135 : /// Returns the vertex associated with the edge
136 : virtual Vertex* get_center_vertex(Edge* e);
137 :
138 : /// Associates a vertex with the edge.
139 : virtual void set_center_vertex(Edge* e, Vertex* v);
140 :
141 : /// Returns the vertex associated with the face
142 : virtual Vertex* get_center_vertex(Face* f);
143 :
144 : /// Associates a vertex with the face.
145 : virtual void set_center_vertex(Face* f, Vertex* v);
146 :
147 : private:
148 : Grid* m_pGrid;
149 : AVertex m_aVertex;
150 : AInt m_aLocalMark;
151 : Grid::EdgeAttachmentAccessor<AVertex> m_aaVertexEDGE;
152 : Grid::FaceAttachmentAccessor<AVertex> m_aaVertexFACE;
153 : MultiElementAttachmentAccessor<AInt> m_aaLocalMark;
154 : };
155 :
156 : /// @} // end of add_to_group command
157 :
158 : }// end of namespace
159 :
160 : #endif
|