Mechanics of Defect Evolution Library
Loading...
Searching...
No Matches
QuadratureDynamic.h
Go to the documentation of this file.
1/* This file is part of MoDELib, the Mechanics Of Defects Evolution Library.
2 *
3 *
4 * MoDELib is distributed without any warranty under the
5 * GNU General Public License (GPL) v2 <http://www.gnu.org/licenses/>.
6 */
7
8#ifndef model_QUADRATUREDYNAMIC_H_
9#define model_QUADRATUREDYNAMIC_H_
10
11#include <math.h> /* round, floor, ceil, trunc */
12#include <assert.h>
13#include <set>
14#include <Eigen/Dense>
15#include <Quadrature.h>
16
17namespace model
18{
19 /**************************************************************************/
20 /**************************************************************************/
21 template<
22 short unsigned int dim,
23 template <short unsigned int, size_t> class QuadratureRule,
24 int...Orders>
26
27 /**************************************************************************/
28 /**************************************************************************/
29 template<
30 short unsigned int dim,
31 template <short unsigned int, size_t> class QuadratureRule,
32 int order,
33 int... otherOrders>
34 struct QuadratureDynamic<dim,QuadratureRule,order,otherOrders...>
35 {
37
38 /**********************************************************************/
39 static const double& weight(const short unsigned int & N,
40 const short unsigned int & k)
41 {
42// assert(k < N && "k must be less than N");
43 if(k>=N)
44 {
45 throw std::runtime_error("k must be less than N");
46 }
48 }
49
50 /**********************************************************************/
51 static const VectorDim abscissa(const short unsigned int & N,
52 const short unsigned int & k)
53 {
54// std::cout<<"order="<<order<<std::endl;
55// assert(k < N && "k must be less than N");
56 if(k>=N)
57 {
58 throw std::runtime_error("k must be less than N");
59 }
61 }
62
63 /**********************************************************************/
64 template<typename IntegrandType>
65 static void integrate(const short unsigned int & N,
66 IntegrandType (*fp)(const double&),
67 IntegrandType &intgrl)
68 {
69 if (N==order)
70 {
72 }
73 else
74 {
76 }
77 }
78
79 /**********************************************************************/
80 template <typename AnyClass, typename IntegrandType, typename ...Args>
81 static void integrate(const short unsigned int & N,
82 const AnyClass* const C, IntegrandType &intgrl,
83 IntegrandType (AnyClass::*mfp)(const VectorDim&, const Args&...) const,
84 const Args&...args)
85 {
86 if (N==order)
87 {
89 }
90 else
91 {
93 }
94 }
95
96 /**********************************************************************/
97 template <typename AnyClass, typename IntegrandType, typename ...Args>
98 static void integrate(const short unsigned int & N,
99 const AnyClass* const C, IntegrandType &intgrl,
100 IntegrandType (AnyClass::*mfp)(const int&, const Args&... ) const,
101 const Args&...args)
102 {
103 if (N==order)
104 {
106 }
107 else
108 {
110 }
111 }
112
113 template <typename AnyClass, typename ...Args>
114 static void execute(const short unsigned int & N,AnyClass* const C,
115 void (AnyClass::*mfp)(const VectorDim&, const Args&...),
116 const Args&...args)
117 {
118 if (N==order)
119 {
121 }
122 else
123 {
125 }
126 }
127
128 template <typename AnyClass, typename ...Args>
129 static void execute(const short unsigned int & N,AnyClass* const C,
130 void (AnyClass::*mfp)(const int&, const Args&...),
131 const Args&...args)
132 {
133 if (N==order)
134 {
136 }
137 else
138 {
140 }
141 }
142
143 static const std::set<int> orderSet;
144
145 static std::set<int> fillSet()
146 {
147 std::set<int> temp;
149 temp.emplace(order);
150 return temp;
151 }
152
153 static std::set<int> fillSet(std::set<int>& temp)
154 {
156 temp.emplace(order);
157 return temp;
158 }
159
160 static int lowerOrder(const int& k)
161 {
162 std::set<int>::const_iterator temp=orderSet.lower_bound(k);
163 return temp==orderSet.end()? *orderSet.rbegin() : *temp;
164 }
165
166 static int lowerOrder(const double& d)
167 {
168 return lowerOrder(int(round(d)));
169 }
170
171
172 };
173
174 template<
175 short unsigned int dim,
176 template <short unsigned int, size_t> class QuadratureRule,
177 int order,
178 int... otherOrders>
180
181
182 /**************************************************************************/
183 /**************************************************************************/
184 template<
185 short unsigned int dim,
186 template <short unsigned int, size_t> class QuadratureRule,
187 int order>
188 struct QuadratureDynamic<dim,QuadratureRule,order>
189 {
191
192 /* weight ********************************************/
193 static const double& weight(const short unsigned int & N,
194 const short unsigned int & k)
195 {
196 // assert(k < N && "k must be less than N");
197 // assert(N==order && "quadrature order N not found in QuadratureDynamic");
198 if(k>=N)
199 {
200 throw std::runtime_error("k must be less than N");
201 }
202 if(N!=order)
203 {
204 throw std::runtime_error("quadrature order N not found in QuadratureDynamic");
205 }
207 }
208
209 /* abscissa ******************************************/
210 static const VectorDim abscissa(const short unsigned int & N,
211 const short unsigned int & k)
212 {
213// assert(k < N && "k must be less than N");
214// assert(N==order && "quadrature order N not found in QuadratureDynamic");
215 if(k>=N)
216 {
217 throw std::runtime_error("k must be less than N");
218 }
219 if(N!=order)
220 {
221 throw std::runtime_error("quadrature order N not found in QuadratureDynamic");
222 }
224 }
225
226 template<typename IntegrandType>
227 static void integrate(const short unsigned int & N,
228 IntegrandType (*fp)(const double&),
229 IntegrandType &intgrl)
230 {
231// assert(N==order && "quadrature order N not found in QuadratureDynamic");
232 if(N!=order)
233 {
234 throw std::runtime_error("quadrature order N not found in QuadratureDynamic");
235 }
237 }
238
239 template <typename AnyClass, typename IntegrandType, typename ...Args>
240 static void integrate(const short unsigned int & N,
241 const AnyClass* const C, IntegrandType &intgrl,
242 IntegrandType (AnyClass::*mfp)(const VectorDim&, const Args&...) const,
243 const Args&...args)
244 {
245// assert(N==order && "quadrature order N not found in QuadratureDynamic");
246 if(N!=order)
247 {
248 throw std::runtime_error("quadrature order N not found in QuadratureDynamic");
249 }
251 }
252
253 template <typename AnyClass, typename IntegrandType, typename ...Args>
254 static void integrate(const short unsigned int & N,
255 const AnyClass* const C, IntegrandType &intgrl,
256 IntegrandType (AnyClass::*mfp)(const int&, const Args&... ) const,
257 const Args&...args)
258 {
259// assert(N==order && "quadrature order N not found in QuadratureDynamic");
260 if(N!=order)
261 {
262 throw std::runtime_error("quadrature order N not found in QuadratureDynamic");
263 }
265 }
266
267 template <typename AnyClass, typename ...Args>
268 static void execute(const short unsigned int & N,AnyClass* const C,
269 void (AnyClass::*mfp)(const VectorDim&, const Args&...),
270 const Args&...args)
271 {
272// assert(N==order && "quadrature order N not found in QuadratureDynamic");
273 if(N!=order)
274 {
275 throw std::runtime_error("quadrature order N not found in QuadratureDynamic");
276 }
278 }
279
280 template <typename AnyClass, typename ...Args>
281 static void execute(const short unsigned int & N,AnyClass* const C,
282 void (AnyClass::*mfp)(const int&, const Args&...),
283 const Args&...args)
284 {
285// assert(N==order && "quadrature order N not found in QuadratureDynamic");
286 if(N!=order)
287 {
288 throw std::runtime_error("quadrature order N not found in QuadratureDynamic");
289 }
291 }
292
293 static const std::set<int> orderSet;
294
295 static std::set<int> fillSet(std::set<int>& temp)
296 {
297 temp.emplace(order);
298 return temp;
299 }
300
301 static std::set<int> fillSet()
302 {
303 std::set<int> temp;
304 temp.emplace(order);
305 return temp;
306 }
307
308 };
309
310 template<
311 short unsigned int dim,
312 template <short unsigned int, size_t> class QuadratureRule,
313 int order>
315
316
317} // namespace model
318#endif
319
const std::set< int > QuadratureDynamic< dim, QuadratureRule, order, otherOrders... >::orderSet
static void integrate(const short unsigned int &N, const AnyClass *const C, IntegrandType &intgrl, IntegrandType(AnyClass::*mfp)(const int &, const Args &...) const, const Args &...args)
static void execute(const short unsigned int &N, AnyClass *const C, void(AnyClass::*mfp)(const VectorDim &, const Args &...), const Args &...args)
static void integrate(const short unsigned int &N, const AnyClass *const C, IntegrandType &intgrl, IntegrandType(AnyClass::*mfp)(const VectorDim &, const Args &...) const, const Args &...args)
static void execute(const short unsigned int &N, AnyClass *const C, void(AnyClass::*mfp)(const int &, const Args &...), const Args &...args)
static const double & weight(const short unsigned int &N, const short unsigned int &k)
static void integrate(const short unsigned int &N, IntegrandType(*fp)(const double &), IntegrandType &intgrl)
static const VectorDim abscissa(const short unsigned int &N, const short unsigned int &k)
static void execute(const short unsigned int &N, AnyClass *const C, void(AnyClass::*mfp)(const int &, const Args &...), const Args &...args)
static void integrate(const short unsigned int &N, const AnyClass *const C, IntegrandType &intgrl, IntegrandType(AnyClass::*mfp)(const VectorDim &, const Args &...) const, const Args &...args)
static void execute(const short unsigned int &N, AnyClass *const C, void(AnyClass::*mfp)(const VectorDim &, const Args &...), const Args &...args)
static std::set< int > fillSet(std::set< int > &temp)
static const VectorDim abscissa(const short unsigned int &N, const short unsigned int &k)
static void integrate(const short unsigned int &N, IntegrandType(*fp)(const double &), IntegrandType &intgrl)
static const double & weight(const short unsigned int &N, const short unsigned int &k)
VectorDimTypeSelector< dim, order >::VectorDim VectorDim
static void integrate(const short unsigned int &N, const AnyClass *const C, IntegrandType &intgrl, IntegrandType(AnyClass::*mfp)(const int &, const Args &...) const, const Args &...args)
static const VectorDim abscissa(const short unsigned int &k)
Definition Quadrature.h:73
static const double & weight(const short unsigned int &k)
Definition Quadrature.h:66
static void integrate(IntegrandType(*fp)(const double &), IntegrandType &intgrl)
Definition Quadrature.h:81
static void execute(AnyClass *const C, void(AnyClass::*mfp)(const VectorDim &, const Args &...), const Args &...args)
Definition Quadrature.h:205
Eigen::Matrix< double, dim, 1 > VectorDim
Definition Quadrature.h:23
b order
int k
vertex temp