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__LOCAL_FINITE_ELEMENT__LOCAL_FINITE_ELEMENT_PROVIDER__
34 : #define __H__UG__LIB_DISC__LOCAL_FINITE_ELEMENT__LOCAL_FINITE_ELEMENT_PROVIDER__
35 :
36 : // extern libraries
37 : #include <cassert>
38 : #include <map>
39 :
40 : // other ug4 modules
41 : #include "common/math/ugmath.h"
42 :
43 : // library intern headers
44 : #include "local_finite_element_id.h"
45 : #include "lib_disc/local_finite_element/local_shape_function_set.h"
46 : #include "lib_disc/local_finite_element/local_dof_set.h"
47 :
48 : namespace ug {
49 :
50 : ////////////////////////////////////////////////////////////////////////////////
51 : // Provider for local finite element infos
52 : ////////////////////////////////////////////////////////////////////////////////
53 :
54 : // LocalFiniteElementProvider
55 : /** class to provide infos on local finite elements
56 : *
57 : * This class provides references to Local Shape functions and Local DoF Sets.
58 : * It is implemented as a Singleton.
59 : */
60 : class LocalFiniteElementProvider {
61 : private:
62 : // disallow private constructor
63 : LocalFiniteElementProvider();
64 :
65 : // disallow copy and assignment (intentionally left unimplemented)
66 : LocalFiniteElementProvider(const LocalFiniteElementProvider&);
67 : LocalFiniteElementProvider& operator=(const LocalFiniteElementProvider&);
68 :
69 : // private destructor
70 : ~LocalFiniteElementProvider();
71 :
72 : // Singleton provider
73 0 : inline static LocalFiniteElementProvider& inst()
74 : {
75 0 : static LocalFiniteElementProvider myInst;
76 0 : return myInst;
77 : };
78 :
79 : private:
80 : /// create the standard lagrange space
81 : /// \{
82 : template <typename TRefElem>
83 : static void create_lagrange_set(const LFEID& id);
84 : static void create_lagrange_set(ReferenceObjectID roid, const LFEID& id);
85 : /// \}
86 :
87 : /// create the mini bubble space
88 : /// \{
89 : template <typename TRefElem>
90 : static void create_mini_bubble_set(const LFEID& id);
91 : static void create_mini_bubble_set(ReferenceObjectID roid, const LFEID& id);
92 : /// \}
93 :
94 : /// creates nedelec space
95 : /// \{
96 : template <typename TRefElem>
97 : static void create_nedelec_set(const LFEID& id);
98 : static void create_nedelec_set(ReferenceObjectID roid, const LFEID& id);
99 : /// \}
100 :
101 : /// creates piecewise constant space
102 : /// \{
103 : template <typename TRefElem>
104 : static void create_piecewise_constant_set(const LFEID& id);
105 : static void create_piecewise_constant_set(ReferenceObjectID roid, const LFEID& id);
106 : /// \}
107 :
108 : /// creates crouxeiz-raviart space
109 : /// \{
110 : template <typename TRefElem>
111 : static void create_crouxeiz_raviart_set(const LFEID& id);
112 : static void create_crouxeiz_raviart_set(ReferenceObjectID roid, const LFEID& id);
113 : /// \}
114 :
115 : /// creates new set at runtime if available
116 : static void create_set(ReferenceObjectID roid, const LFEID& id);
117 :
118 : /// creates new set at runtime if available
119 : static void create_set(const LFEID& id);
120 :
121 : /// creates dof set on sub elements
122 : template <int rdim, int dim>
123 : static void create_sub_dof_set(ReferenceObjectID roid, const LFEID& id);
124 : static void create_dof_set(ReferenceObjectID roid, const LFEID& id);
125 :
126 : private:
127 : template <int dim, typename TShape, typename TGrad>
128 0 : struct LocalShapeFunctionSets{
129 0 : ConstSmartPtr<LocalShapeFunctionSet<dim, TShape, TGrad> >& operator[](size_t i) {return ptr[i];}
130 : const ConstSmartPtr<LocalShapeFunctionSet<dim, TShape, TGrad> >& operator[](size_t i) const {return ptr[i];}
131 : ConstSmartPtr<LocalShapeFunctionSet<dim, TShape, TGrad> > ptr[NUM_REFERENCE_OBJECTS];
132 : };
133 :
134 : // return a map of element_trial_spaces
135 : template <int dim, typename TShape, typename TGrad>
136 : static std::map<LFEID, LocalShapeFunctionSets<dim, TShape, TGrad> >&
137 : lsfs_map();
138 :
139 : // returns the continuous information
140 : static std::map<LFEID, bool> m_mContSpace;
141 :
142 : private:
143 0 : struct LocalDoFSets{
144 0 : ConstSmartPtr<LocalDoFSet>& operator[](size_t i) {return ptr[i];}
145 : const ConstSmartPtr<LocalDoFSet>& operator[](size_t i) const {return ptr[i];}
146 : ConstSmartPtr<LocalDoFSet> ptr[NUM_REFERENCE_OBJECTS];
147 : };
148 :
149 : template <int dim>
150 0 : struct DimLocalDoFSets{
151 0 : ConstSmartPtr<DimLocalDoFSet<dim> >& operator[](size_t i) {return ptr[i];}
152 : const ConstSmartPtr<DimLocalDoFSet<dim> >& operator[](size_t i) const {return ptr[i];}
153 : ConstSmartPtr<DimLocalDoFSet<dim> > ptr[NUM_REFERENCE_OBJECTS];
154 : };
155 :
156 :
157 : // map holding common dof set for roid of same dimension
158 : static std::map<LFEID, CommonLocalDoFSet> m_mCommonDoFSet;
159 :
160 : // map holding dof sets for a reference object id
161 : static std::map<LFEID, LocalDoFSets> m_mLocalDoFSets;
162 :
163 : // returns map for dof set with local pos
164 : template <int dim>
165 : static std::map<LFEID, DimLocalDoFSets<dim> >& lds_map();
166 :
167 : public:
168 : /// register a local shape function set for a given reference element type
169 : /**
170 : * This function is used to register a Local Shape Function set for an element
171 : * type and the corresponding local shape function set id.
172 : *
173 : * \param[in] id Identifier for local shape function set
174 : * \param[in] roid Reference Object id
175 : * \param[in] set Local Shape Function Set to register
176 : */
177 : template <int dim, typename TShape, typename TGrad>
178 : static void register_set(const LFEID& id,
179 : ConstSmartPtr<LocalShapeFunctionSet<dim, TShape, TGrad> > set);
180 :
181 : /** register a local DoF set for a given reference element type
182 : * This function is used to register a Local Shape Function set for an element
183 : * type and the corresponding local DoF set id.
184 : *
185 : * \param[in] id Identifier for local DoF set
186 : * \param[in] set Local Shape Function Set to register
187 : */
188 : template <int dim>
189 : static void register_set(const LFEID& id, ConstSmartPtr<DimLocalDoFSet<dim> > set);
190 :
191 : /** register a local DoF set for a given reference element type
192 : * This function is used to register a Local Shape Function set for an element
193 : * type and the corresponding local DoF set id.
194 : *
195 : * \param[in] id Identifier for local DoF set
196 : * \param[in] set Local Shape Function Set to register
197 : */
198 : static void register_set(const LFEID& id, ConstSmartPtr<LocalDoFSet> set);
199 :
200 : /// returns the Local Shape Function Set
201 : /**
202 : * This function returns the Local Shape Function Set for a reference element
203 : * type and an Identifier if a set has been registered for the identifier.
204 : * Else an exception is thrown.
205 : *
206 : * \param[in] roid Reference object id
207 : * \param[in] id Identifier for local shape function set
208 : * \return set A const reference to the shape function set
209 : */
210 : ///\{
211 : template <int dim, typename TShape, typename TGrad>
212 : static const LocalShapeFunctionSet<dim, TShape, TGrad>&
213 : get(ReferenceObjectID roid, const LFEID& id, bool bCreate = true);
214 :
215 : template <int dim>
216 : static const LocalShapeFunctionSet<dim>&
217 : get(ReferenceObjectID roid, const LFEID& id, bool bCreate = true)
218 0 : {return get<dim,number,MathVector<dim> >(roid, id, bCreate);}
219 :
220 : template <int dim, typename TShape, typename TGrad>
221 : static ConstSmartPtr<LocalShapeFunctionSet<dim, TShape, TGrad> >
222 : getptr(ReferenceObjectID roid, const LFEID& id, bool bCreate = true);
223 :
224 : template <int dim>
225 : static ConstSmartPtr<LocalShapeFunctionSet<dim> >
226 : getptr(ReferenceObjectID roid, const LFEID& id, bool bCreate = true)
227 0 : {return getptr<dim,number,MathVector<dim> >(roid, id, bCreate);}
228 : ///\}
229 :
230 :
231 : /// returns the common dof set for all reference objects of a dimension
232 : static const CommonLocalDoFSet& get_dofs(const LFEID& id, bool bCreate = true);
233 :
234 : /// returns the local DoF set base for an id
235 : static const LocalDoFSet& get_dofs(ReferenceObjectID roid, const LFEID& id, bool bCreate = true);
236 :
237 : /// returns the local DoF set base for an id
238 : /// \{
239 : template <int dim>
240 : static const DimLocalDoFSet<dim>&
241 : get_dofs(ReferenceObjectID roid, const LFEID& id, bool bCreate = true);
242 :
243 : template <int dim>
244 : static ConstSmartPtr<DimLocalDoFSet<dim> >
245 : get_dof_ptr(ReferenceObjectID roid, const LFEID& id, bool bCreate = true);
246 : /// \}
247 :
248 : ///returns if a Local Shape Function Set is continuous
249 : static bool continuous(const LFEID& id, bool bCreate = true);
250 : };
251 :
252 : } // namespace ug
253 :
254 : #include "local_finite_element_provider_impl.h"
255 :
256 : #endif /* __H__UG__LIB_DISC__LOCAL_FINITE_ELEMENT__LOCAL_SHAPE_FUCNTION_SET__ */
|