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_subdivision_projector
34 : #define __H__UG_subdivision_projector
35 :
36 : #include <algorithm>
37 : #include <vector>
38 : #include "refinement_projector.h"
39 : #include "lib_grid/callbacks/basic_callbacks.h"
40 : #include "lib_grid/callbacks/topology_callbacks.h"
41 :
42 : namespace ug{
43 :
44 : /// Applies piecewise smooth loop subdivision rules
45 : /**
46 : * \warning The implementation assumes that vertices which are passed to
47 : * 'refinement_begins' still exist in the underlying grid when
48 : * 'refinement_ends' is called.
49 : */
50 : class SubdivisionProjector : public RefinementProjector {
51 : public:
52 0 : SubdivisionProjector () :
53 : m_cbIsCrease (Grid::edge_traits::callback(ConsiderNone())),
54 0 : m_customConcernedElementsCallbackUsed (false)
55 : {}
56 :
57 : SubdivisionProjector (Grid::edge_traits::callback cbIsCrease) :
58 : m_cbIsCrease (cbIsCrease),
59 : m_customConcernedElementsCallbackUsed (false)
60 : {}
61 :
62 : /** \sa ug::RefinementProjector::RefinementProjector*/
63 0 : SubdivisionProjector (SPIGeometry3d geometry) :
64 0 : RefinementProjector (geometry, make_sp(new IsBoundaryOrManifodFace(geometry->grid()))),
65 : m_cbIsCrease (Grid::edge_traits::callback(ConsiderNone())),
66 0 : m_customConcernedElementsCallbackUsed (false)
67 0 : {}
68 :
69 : /** \sa ug::RefinementProjector::RefinementProjector*/
70 : SubdivisionProjector (SPIGeometry3d geometry,
71 : Grid::edge_traits::callback cbIsCrease) :
72 : RefinementProjector (geometry, make_sp(new IsBoundaryOrManifodFace(geometry->grid()))),
73 : m_cbIsCrease (cbIsCrease),
74 : m_customConcernedElementsCallbackUsed (false)
75 : {}
76 :
77 0 : virtual void set_geometry (SPIGeometry3d geometry)
78 : {
79 0 : RefinementProjector::set_geometry (geometry);
80 0 : if(!m_customConcernedElementsCallbackUsed){
81 0 : RefinementProjector::set_concerned_elements(
82 0 : make_sp(new IsBoundaryOrManifodFace(geometry->grid())));
83 : }
84 0 : }
85 :
86 0 : virtual void set_concerned_elements (SPElementCallback cb)
87 : {
88 0 : RefinementProjector::set_concerned_elements (cb);
89 0 : m_customConcernedElementsCallbackUsed = true;
90 0 : }
91 :
92 0 : virtual bool refinement_begins_requires_subgrid () const {return true;}
93 :
94 : virtual void refinement_begins(const ISubGrid* sg);
95 : virtual void refinement_ends();
96 :
97 : virtual number new_vertex(Vertex* vrt, Edge* parent);
98 : // virtual number new_vertex(Vertex* vrt, Face* parent);
99 : // virtual number new_vertex(Vertex* vrt, Volume* parent);
100 :
101 0 : virtual void set_crease_callback (Grid::edge_traits::callback cbIsCrease)
102 : {
103 0 : m_cbIsCrease = cbIsCrease;
104 0 : }
105 :
106 : protected:
107 : size_t nbr_crease_edges (Vertex* vrt,
108 : Grid::edge_traits::secure_container* assEdges = NULL,
109 : Edge* creaseEdgesOut[2] = NULL);
110 :
111 : size_t concerned_nbr_faces (Edge* edge,
112 : Grid::face_traits::secure_container* assFaces = NULL,
113 : Face* facesOut[2] = NULL);
114 :
115 : private:
116 : friend class boost::serialization::access;
117 :
118 : template <class Archive>
119 : void serialize( Archive& ar, const unsigned int version)
120 : {
121 : UG_EMPTY_BASE_CLASS_SERIALIZATION(SubdivisionProjector, RefinementProjector);
122 : }
123 :
124 :
125 : typedef std::vector<std::pair<Vertex*, vector3> > new_pos_vec_t;
126 :
127 : Grid::edge_traits::callback m_cbIsCrease;
128 : new_pos_vec_t m_newPositions;
129 : bool m_customConcernedElementsCallbackUsed;
130 : };
131 :
132 : }// end of namespace
133 :
134 : #endif //__H__UG_subdivision_projector
|