Line data Source code
1 : /*
2 : * Copyright (c) 2013-2015: G-CSC, Goethe University Frankfurt
3 : * Author: Andreas Vogel
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__LIB_DISC__FUNCTION_SPACE__ADAPTION_SURFACE_GRID_FUNCTION__
34 : #define __H__UG__LIB_DISC__FUNCTION_SPACE__ADAPTION_SURFACE_GRID_FUNCTION__
35 :
36 : #include "grid_function.h"
37 : #include "local_transfer_interface.h"
38 :
39 : namespace ug{
40 :
41 : template <typename TDomain>
42 : class AdaptionSurfaceGridFunction : public GridObserver
43 : {
44 : public:
45 : typedef std::vector<std::vector<number> > Values;
46 : typedef Attachment<Values> AValues;
47 :
48 : public:
49 : AdaptionSurfaceGridFunction(SmartPtr<TDomain> spDomain,
50 : bool bObserveStorage = true);
51 :
52 : public:
53 : template <typename TAlgebra>
54 : void copy_from_surface(const GridFunction<TDomain,TAlgebra>& rSurfaceFct);
55 :
56 : template <typename TAlgebra>
57 : void copy_to_surface(GridFunction<TDomain,TAlgebra>& rSurfaceFct);
58 :
59 0 : AValues value_attachment() {return m_aValue;}
60 :
61 : protected:
62 : template <typename TElem, typename TAlgebra>
63 : void copy_from_surface(const GridFunction<TDomain,TAlgebra>& rSurfaceFct, TElem* elem);
64 : template <typename TElem, typename TAlgebra>
65 : void copy_from_surface(const GridFunction<TDomain,TAlgebra>& rSurfaceFct);
66 :
67 : template <typename TElem, typename TAlgebra>
68 : void copy_to_surface(GridFunction<TDomain,TAlgebra>& rSurfaceFct, TElem* elem);
69 : template <typename TElem, typename TAlgebra>
70 : void copy_to_surface(GridFunction<TDomain,TAlgebra>& rSurfaceFct);
71 :
72 : public:
73 : void prolongate(const GridMessage_Adaption& msg);
74 : void do_restrict(const GridMessage_Adaption& msg);
75 :
76 : protected:
77 : template <typename TBaseElem>
78 : void prolongate(const GridMessage_Adaption& msg, const size_t lvl);
79 :
80 : template <typename TBaseElem>
81 : void do_restrict(const MGSelector& sel, const GridMessage_Adaption& msg);
82 :
83 : template <typename TBaseElem>
84 : void select_parents(MGSelector& sel, const GridMessage_Adaption& msg);
85 :
86 : protected:
87 : class ValueAccessor : public TransferValueAccessor
88 : {
89 : public:
90 : ValueAccessor(AdaptionSurfaceGridFunction<TDomain>& rASGF,
91 : size_t fct);
92 :
93 : void access_inner(GridObject* elem);
94 :
95 : void access_closure(GridObject* elem);
96 :
97 : protected:
98 : template <typename TBaseElem, typename TSubBaseElem>
99 : void access_closure(TBaseElem* elem);
100 :
101 : template <typename TBaseElem>
102 : void access_closure(TBaseElem* elem);
103 :
104 : protected:
105 : AdaptionSurfaceGridFunction<TDomain>& m_rASGF;
106 : const size_t m_fct;
107 : bool m_HasDoFs[NUM_GEOMETRIC_BASE_OBJECTS];
108 : };
109 : friend class ValueAccessor;
110 :
111 : public:
112 : /// creates storage when object created
113 : template <typename TBaseElem>
114 : inline void obj_created(TBaseElem* elem);
115 :
116 : /// grid observer callbacks
117 : /// \{
118 0 : virtual void vertex_created(Grid* grid, Vertex* vrt, GridObject* pParent = NULL, bool replacesParent = false){obj_created(vrt);}
119 0 : virtual void edge_created(Grid* grid, Edge* e, GridObject* pParent = NULL, bool replacesParent = false){obj_created(e);}
120 0 : virtual void face_created(Grid* grid, Face* f, GridObject* pParent = NULL, bool replacesParent = false){obj_created(f);}
121 0 : virtual void volume_created(Grid* grid, Volume* vol, GridObject* pParent = NULL, bool replacesParent = false){obj_created(vol);}
122 : /// \}
123 :
124 : protected:
125 : SmartPtr<TDomain> m_spDomain;
126 : SmartPtr<MultiGrid> m_spGrid;
127 : ConstSmartPtr<DoFDistributionInfo> m_spDDInfo;
128 : int m_ParallelStorageType;
129 : bool m_bObserveStorage;
130 :
131 : void attach_entries(ConstSmartPtr<DoFDistributionInfo> spDDInfo);
132 :
133 : template <typename TElem> void detach_entries();
134 : void detach_entries();
135 :
136 : AValues m_aValue;
137 : MultiElementAttachmentAccessor<AValues> m_aaValue;
138 :
139 : std::vector<SmartPtr<IElemProlongation<TDomain> > > m_vpProlong;
140 : std::vector<SmartPtr<IElemRestriction<TDomain> > > m_vpRestrict;
141 :
142 : };
143 :
144 : } // end namespace ug
145 :
146 : #include "adaption_surface_grid_function_impl.h"
147 :
148 : #endif /* __H__UG__LIB_DISC__FUNCTION_SPACE__ADAPTION_SURFACE_GRID_FUNCTION__ */
|