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__QUADRATURE_PROVIDER__
34 : #define __H__UG__LIB_DISC__QUADRATURE_PROVIDER__
35 :
36 : #include "lib_grid/grid/grid_base_objects.h"
37 : #include "quadrature.h"
38 :
39 :
40 : /// types of quadratures
41 : enum QuadType {
42 : BEST = 0,
43 : GAUSS,
44 : GAUSS_LEGENDRE,
45 : NEWTON_COTES,
46 : NUM_QUADRATURE_TYPES // always last
47 : };
48 :
49 : namespace ug{
50 :
51 : /// provides quadrature rules for a reference dimension
52 : /**
53 : * This class serves as a provider for quadrature rules. It is templated for a
54 : * reference element dimension.
55 : *
56 : * \tparam TDim Reference Element Dimension
57 : */
58 : template <int TDim>
59 : class QuadratureRuleProvider
60 : {
61 : public:
62 : /// dimension of reference element
63 : static const int dim = TDim;
64 :
65 : private:
66 : /// private constructor performing standard registering
67 : QuadratureRuleProvider();
68 :
69 : // disallow copy
70 : QuadratureRuleProvider(const QuadratureRuleProvider&);
71 : QuadratureRuleProvider& operator=(const QuadratureRuleProvider&);
72 :
73 : /// singleton provider
74 0 : static QuadratureRuleProvider<dim>& instance()
75 : {
76 0 : static QuadratureRuleProvider<dim> inst;
77 0 : return inst;
78 : }
79 :
80 : public:
81 : /// destructor
82 : ~QuadratureRuleProvider();
83 :
84 : protected:
85 : /// Vector, holding all registered rules
86 : static std::vector<const QuadratureRule<TDim>*> m_vRule[NUM_QUADRATURE_TYPES][NUM_REFERENCE_OBJECTS];
87 :
88 : /// provide rule, try to create it if not already present
89 : static const QuadratureRule<TDim>&
90 : get_quad_rule(ReferenceObjectID roid, size_t order, QuadType type);
91 :
92 : /// creates rule at this provider
93 : static void create_rule(ReferenceObjectID roid, size_t order, QuadType type);
94 :
95 : /// rule creation, returns NULL if unavailable
96 : /// \{
97 : static const QuadratureRule<TDim>* create_gauss_rule(ReferenceObjectID roid, size_t order);
98 : static const QuadratureRule<TDim>* create_newton_cotes_rule(ReferenceObjectID roid, size_t order);
99 : static const QuadratureRule<TDim>* create_gauss_legendre_rule(ReferenceObjectID roid, size_t order);
100 : /// \}
101 :
102 : public:
103 : /// gets quadrature rule of requested order
104 : /**
105 : * This function returns the next quadrature rule of order >= 'order'
106 : * that is registered to this Provider. If no rule is found an
107 : * Exception is thrown.
108 : *
109 : * \param[in] order Order of requested quadrature rule
110 : * \tparam TRefElem Reference element type
111 : */
112 : template <typename TRefElem>
113 : static const QuadratureRule<TDim>&
114 : get(size_t order, QuadType type = BEST);
115 :
116 : /// gets quadrature rule of requested order
117 : /**
118 : * This function returns the next quadrature rule of order >= 'order'
119 : * that is registered to this Provider. If no rule is found an
120 : * Exception is thrown.
121 : *
122 : * \param[in] roid Reference Object id
123 : * \param[in] order Order of requested quadrature rule
124 : */
125 : static const QuadratureRule<TDim>&
126 : get(ReferenceObjectID roid, size_t order, QuadType type = BEST);
127 : };
128 :
129 : // Init static member
130 : template <int dim>
131 : std::vector<const QuadratureRule<dim>*> QuadratureRuleProvider<dim>::m_vRule[NUM_QUADRATURE_TYPES][NUM_REFERENCE_OBJECTS];
132 :
133 : /// writes the Identifier to the output stream
134 : std::ostream& operator<<(std::ostream& out, const QuadType& v);
135 :
136 : /// returns Identifier from string
137 : QuadType GetQuadratureType(const std::string& name);
138 :
139 : /// @}
140 :
141 : } // namespace ug
142 :
143 : #include "quadrature_provider_impl.h"
144 :
145 : #endif /* __H__UG__LIB_DISC__QUADRATURE_PROVIDER__ */
|