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__DOF_MANAGER__DOF_DISTRIBUTION_INFO__
34 : #define __H__UG__LIB_DISC__DOF_MANAGER__DOF_DISTRIBUTION_INFO__
35 :
36 : #include "common/common.h"
37 : #include "lib_grid/lg_base.h"
38 : #include "lib_disc/dof_manager/function_pattern.h"
39 : #include "lib_disc/local_finite_element/local_finite_element_id.h"
40 : #include "lib_disc/local_finite_element/local_dof_set.h"
41 :
42 : #include <vector>
43 :
44 : namespace ug{
45 :
46 : class DoFDistributionInfo : public FunctionPattern
47 : {
48 : public:
49 : /// indication that function is not defined on a subset
50 : enum{NOT_DEF_ON_SUBSET = (size_t) - 1};
51 : /// indication that function is not defined on a subset
52 : enum{NOT_YET_ASSIGNED = (size_t) - 2};
53 : /// indicate not set value
54 : enum{NOT_SPECIFIED = CommonLocalDoFSet::NOT_SPECIFIED};
55 :
56 : public:
57 : /// constructor
58 : DoFDistributionInfo(ConstSmartPtr<ISubsetHandler> spSH);
59 :
60 : /// initializes the DoFs
61 : void init();
62 :
63 :
64 : /// returns the maximum number of dofs on grid objects in a dimension
65 0 : size_t max_dofs(const int dim) const {return m_vMaxDoFsInDim[dim];}
66 :
67 : /// returns the maximum number of dofs on a grid base object type
68 0 : size_t max_dofs(const GridBaseObjectId gbo) const {return m_vMaxDoFsInDim[gbo];}
69 :
70 : /// returns the maximum number of dofs on reference object type
71 : size_t max_dofs(const ReferenceObjectID roid) const {return m_vMaxDoFsOnROID[roid];}
72 :
73 : /// returns the maximum number of dofs in a dimension on a subset
74 0 : size_t max_dofs(const int dim, const int si) const {return m_vvMaxDoFsInDimPerSubset[dim][si];}
75 :
76 : /// returns the maximum number of dofs on a grid base object on a subset
77 0 : size_t max_dofs(const GridBaseObjectId gbo, const int si) const {return m_vvMaxDoFsInDimPerSubset[gbo][si];}
78 :
79 : /// returns the number of dofs on a Reference Object on a subset
80 0 : size_t num_dofs(const ReferenceObjectID roid, const int si) const {return m_vvNumDoFsOnROIDPerSubset[roid][si];}
81 :
82 :
83 : /// returns the maximal number of dofs on a dimension for a function component
84 0 : size_t max_fct_dofs(const size_t fct, int dim) const {return m_vFctInfo[fct].vMaxDoFsInDim[dim];}
85 :
86 : /// returns the maximal number of dofs on a base object type for a function component
87 0 : size_t max_fct_dofs(const size_t fct, const GridBaseObjectId gbo) const {return m_vFctInfo[fct].vMaxDoFsInDim[gbo];}
88 :
89 : /// returns the number of dofs on a reference object for a function component
90 : size_t max_fct_dofs(const size_t fct, const ReferenceObjectID roid) const {return m_vFctInfo[fct].vMaxDoFsOnROID[roid];}
91 :
92 : /// returns the maximum number of dofs in a dimension on a subset for a function component
93 0 : size_t max_fct_dofs(const size_t fct, const int dim, const int si) const {return m_vFctInfo[fct].vvMaxDoFsInDimPerSubset[dim][si];}
94 :
95 : /// returns the maximum number of dofs on a grid base object on a subset for a function component
96 0 : size_t max_fct_dofs(const size_t fct, const GridBaseObjectId gbo, const int si) const {return m_vFctInfo[fct].vvMaxDoFsInDimPerSubset[gbo][si];}
97 :
98 : /// returns the number of dofs on a Reference Object on a subset for a function component
99 0 : size_t num_fct_dofs(const size_t fct, const ReferenceObjectID roid, const int si) const {return m_vFctInfo[fct].vvNumDoFsOnROIDPerSubset[roid][si];}
100 :
101 :
102 : /// returns the offset for reference element, subset and function
103 0 : size_t offset(const ReferenceObjectID roid, const int si, const size_t fct) const {return m_vFctInfo[fct].vvOffsets[roid][si];}
104 :
105 :
106 : /// prints informations
107 : void print_local_dof_statistic(int verboseLev) const;
108 :
109 : /// prints statistic on local dof distribution
110 : void print_local_dof_statistic() const {print_local_dof_statistic(1);}
111 :
112 : protected:
113 : /// creates offset arrays
114 : void create_offsets();
115 :
116 : protected:
117 : /// maximum number of DoFs on geometric objects in a dimension
118 : size_t m_vMaxDoFsInDim[NUM_GEOMETRIC_BASE_OBJECTS];
119 :
120 : /// maximum number of DoFs on a reference type
121 : size_t m_vMaxDoFsOnROID[NUM_REFERENCE_OBJECTS];
122 :
123 : /// maximum number of DoFs on geometric objects in a dimension per subset
124 : std::vector<size_t> m_vvMaxDoFsInDimPerSubset[NUM_GEOMETRIC_BASE_OBJECTS];
125 :
126 : /// number of DoFs on a reference element type on a subset
127 : std::vector<size_t> m_vvNumDoFsOnROIDPerSubset[NUM_REFERENCE_OBJECTS];
128 :
129 :
130 : struct FctInfo{
131 : /// number Dofs for local DoF set and subelement of element
132 : size_t vMaxDoFsInDim[NUM_GEOMETRIC_BASE_OBJECTS];
133 :
134 : /// number Dofs for local DoF set and subelement of element
135 : size_t vMaxDoFsOnROID[NUM_REFERENCE_OBJECTS];
136 :
137 : /// maximum number of DoFs on geometric objects in a dimension per subset
138 : std::vector<size_t> vvMaxDoFsInDimPerSubset[NUM_GEOMETRIC_BASE_OBJECTS];
139 :
140 : /// number of DoFs on a reference element type on a subset
141 : std::vector<size_t> vvNumDoFsOnROIDPerSubset[NUM_REFERENCE_OBJECTS];
142 :
143 : /// offset map
144 : std::vector<size_t> vvOffsets[NUM_REFERENCE_OBJECTS];
145 : };
146 :
147 : /// infos for a function component
148 : std::vector<FctInfo> m_vFctInfo;
149 : };
150 :
151 :
152 0 : class DoFDistributionInfoProvider{
153 : public:
154 : /// constructor
155 : DoFDistributionInfoProvider(ConstSmartPtr<DoFDistributionInfo> spDDI)
156 : : m_spDDI(spDDI)
157 : {}
158 :
159 : /// constructor
160 : DoFDistributionInfoProvider() : m_spDDI(0) {}
161 :
162 : /// sets the dd info
163 0 : void set_dof_distribution_info(ConstSmartPtr<DoFDistributionInfo> spDDI) {m_spDDI = spDDI;}
164 :
165 : /// returns underlying info
166 : ConstSmartPtr<DoFDistributionInfo> dof_distribution_info() const {return m_spDDI;}
167 :
168 : /// returns the subset handler
169 : ConstSmartPtr<ISubsetHandler> subset_handler() const {return m_spDDI->subset_handler();}
170 :
171 : /// returns the function pattern
172 : ConstSmartPtr<FunctionPattern> function_pattern() const {return m_spDDI;}
173 :
174 :
175 : /// number of discrete functions on subset si
176 0 : size_t num_fct() const {return m_spDDI->num_fct();}
177 :
178 : /// number of discrete functions on subset si
179 : size_t num_fct(int si) const {return m_spDDI->num_fct(si);}
180 :
181 : /// returns the name of the discrete function nr_fct
182 0 : std::string name(size_t fct) const {return m_spDDI->name(fct);}
183 :
184 : /// returns the names of the discrete functions
185 0 : std::vector<std::string> names() const {return m_spDDI->names();}
186 :
187 : /// returns fct id by name
188 0 : size_t fct_id_by_name(const char* name) const{return m_spDDI->fct_id_by_name(name);}
189 :
190 :
191 : /// returns number of subsets
192 : int num_subsets() const {return m_spDDI->num_subsets();}
193 :
194 : /// returns the dimension in which solution lives
195 0 : int dim(size_t fct) const {return m_spDDI->dim(fct);}
196 :
197 : /// returns dimension of subset
198 : int dim_subset(int si) const {return m_spDDI->dim_subset(si);}
199 :
200 : /// returns subset name
201 0 : std::string subset_name(int si) const {return m_spDDI->subset_name(si);}
202 :
203 : /// returns the subset id
204 0 : int subset_id_by_name(const char* name) const {return m_spDDI->subset_id_by_name(name);}
205 :
206 : /// returns subset group by name
207 : SubsetGroup subset_grp_by_name(const char* names) const;
208 :
209 : /// returns subset group of all the subsets except for (by name)
210 : SubsetGroup all_subsets_grp_except_for(const char* names) const;
211 :
212 : /// returns a function group to a string of functions
213 : FunctionGroup fct_grp_by_name(const char* names) const;
214 :
215 :
216 : /// returns if a function is defined on a subset
217 0 : bool is_def_in_subset(size_t fct, int si) const {return m_spDDI->is_def_in_subset(fct,si);}
218 :
219 : /// returns true if the discrete function nr_fct is defined everywhere
220 : bool is_def_everywhere(size_t fct) const {return m_spDDI->is_def_everywhere(fct);}
221 :
222 :
223 : /// returns the local finite element id of a function
224 : /// \{
225 : const LFEID& local_finite_element_id(size_t fct) const {return m_spDDI->local_finite_element_id(fct);}
226 0 : const LFEID& lfeid(size_t fct) const {return m_spDDI->lfeid(fct);}
227 : /// \}
228 :
229 :
230 : /// returns the maximum number of dofs on grid objects in a dimension
231 : size_t max_dofs(const int dim) const {return m_spDDI->max_dofs(dim);}
232 :
233 : /// returns the maximum number of dofs on a grid base object type
234 : size_t max_dofs(const GridBaseObjectId gbo) const {return m_spDDI->max_dofs(gbo);}
235 :
236 : /// returns the maximum number of dofs on reference object type
237 : size_t max_dofs(const ReferenceObjectID roid) const {return m_spDDI->max_dofs(roid);}
238 :
239 : /// returns the maximum number of dofs in a dimension on a subset
240 : size_t max_dofs(const int dim, const int si) const {return m_spDDI->max_dofs(dim, si);}
241 :
242 : /// returns the maximum number of dofs on a grid base object on a subset
243 : size_t max_dofs(const GridBaseObjectId gbo, const int si) const {return m_spDDI->max_dofs(gbo, si);}
244 :
245 : /// returns the number of dofs on a Reference Object on a subset
246 : size_t num_dofs(const ReferenceObjectID roid, const int si) const {return m_spDDI->num_dofs(roid, si);}
247 :
248 :
249 : /// returns the maximal number of dofs on a dimension for a function component
250 : size_t max_fct_dofs(const size_t fct, int dim) const {return m_spDDI->max_fct_dofs(fct, dim);}
251 :
252 : /// returns the maximal number of dofs on a base object type for a function component
253 : size_t max_fct_dofs(const size_t fct, const GridBaseObjectId gbo) const {return m_spDDI->max_fct_dofs(fct, gbo);}
254 :
255 : /// returns the number of dofs on a reference object for a function component
256 : size_t max_fct_dofs(const size_t fct, const ReferenceObjectID roid) const {return m_spDDI->max_fct_dofs(fct, roid);}
257 :
258 : /// returns the maximum number of dofs in a dimension on a subset for a function component
259 : size_t max_fct_dofs(const size_t fct, const int dim, const int si) const {return m_spDDI->max_fct_dofs(fct, dim, si);}
260 :
261 : /// returns the maximum number of dofs on a grid base object on a subset for a function component
262 : size_t max_fct_dofs(const size_t fct, const GridBaseObjectId gbo, const int si) const {return m_spDDI->max_fct_dofs(fct, gbo, si);}
263 :
264 : /// returns the number of dofs on a Reference Object on a subset for a function component
265 : size_t num_fct_dofs(const size_t fct, const ReferenceObjectID roid, const int si) const {return m_spDDI->num_fct_dofs(fct, roid, si);}
266 :
267 :
268 : /// returns the offset for reference element, subset and function
269 : size_t offset(const ReferenceObjectID roid, const int si, const size_t fct) const {return m_spDDI->offset(roid,si,fct);}
270 :
271 :
272 : /// prints statistic on local dof distribution
273 0 : void print_local_dof_statistic() const {print_local_dof_statistic(1);}
274 :
275 : /// prints informations
276 0 : void print_local_dof_statistic(int verboseLev) const {m_spDDI->print_local_dof_statistic(verboseLev);}
277 :
278 : protected:
279 : /// Function Pattern
280 : ConstSmartPtr<DoFDistributionInfo> m_spDDI;
281 : };
282 :
283 :
284 : } // end namespace ug
285 :
286 : #endif /* __H__UG__LIB_DISC__DOF_MANAGER__DOF_DISTRIBUTION_INFO__ */
|