17 #ifndef dealii_matrix_free_evaluation_selector_h 18 #define dealii_matrix_free_evaluation_selector_h 20 #include <deal.II/matrix_free/evaluation_kernels.h> 22 DEAL_II_NAMESPACE_OPEN
45 template <
int dim,
int n_components,
typename Number>
49 Number *values_dofs_actual,
51 Number *gradients_quad,
52 Number *hessians_quad,
54 const bool evaluate_values,
55 const bool evaluate_gradients,
56 const bool evaluate_hessians)
60 ::evaluate(shape_info, values_dofs_actual, values_quad,
61 gradients_quad, hessians_quad, scratch_data,
62 evaluate_values, evaluate_gradients, evaluate_hessians);
66 Number *values_dofs_actual,
68 Number *gradients_quad,
70 const bool integrate_values,
71 const bool integrate_gradients)
75 ::integrate(shape_info, values_dofs_actual, values_quad,
76 gradients_quad, scratch_data,
77 integrate_values, integrate_gradients,
false);
86 int DEPTH=0,
int degree=0,
int n_q_points_1d=0,
class Enable =
void>
87 struct Factory : Default<dim, n_components, Number> {};
93 template<
int n_q_po
ints_1d,
int dim,
int n_components,
typename Number>
94 struct Factory<dim,
n_components, Number, 0, 10, n_q_points_1d> : Default<dim, n_components, Number> {};
100 template<
int degree,
int n_q_po
ints_1d,
int dim,
int n_components,
typename Number>
101 struct Factory<dim,
n_components, Number, 1, degree, n_q_points_1d,
102 typename
std::enable_if<n_q_points_1d==degree+3>::type> : Default<dim, n_components, Number> {};
107 template<
int degree,
int n_q_po
ints_1d,
int dim,
int n_components,
typename Number>
108 struct Factory<dim,
n_components, Number, 0, degree, n_q_points_1d>
110 static inline void evaluate (
112 Number *values_dofs_actual,
114 Number *gradients_quad,
115 Number *hessians_quad,
116 Number *scratch_data,
117 const bool evaluate_values,
118 const bool evaluate_gradients,
119 const bool evaluate_hessians)
121 const unsigned int runtime_degree = shape_info.
fe_degree;
122 constexpr
unsigned int start_n_q_points = degree+1;
123 if (runtime_degree == degree)
124 Factory<dim, n_components, Number, 1, degree, start_n_q_points>::evaluate
125 (shape_info, values_dofs_actual, values_quad, gradients_quad, hessians_quad,
126 scratch_data, evaluate_values, evaluate_gradients, evaluate_hessians);
128 Factory<dim, n_components, Number, 0, degree+1, n_q_points_1d>::evaluate
129 (shape_info, values_dofs_actual, values_quad, gradients_quad, hessians_quad,
130 scratch_data, evaluate_values, evaluate_gradients, evaluate_hessians);
133 static inline void integrate (
135 Number *values_dofs_actual,
137 Number *gradients_quad,
138 Number *scratch_data,
139 const bool integrate_values,
140 const bool integrate_gradients)
142 const int runtime_degree = shape_info.
fe_degree;
143 constexpr
unsigned int start_n_q_points = degree+1;
144 if (runtime_degree == degree)
145 Factory<dim, n_components, Number, 1, degree, start_n_q_points>::integrate
146 (shape_info, values_dofs_actual, values_quad, gradients_quad,
147 scratch_data, integrate_values, integrate_gradients);
149 Factory<dim, n_components, Number, 0, degree+1, n_q_points_1d>::integrate
150 (shape_info, values_dofs_actual, values_quad, gradients_quad,
151 scratch_data, integrate_values, integrate_gradients);
158 template<
int degree,
int n_q_po
ints_1d,
int dim,
int n_components,
typename Number>
159 struct Factory<dim,
n_components, Number, 1, degree, n_q_points_1d, typename
std::enable_if<(n_q_points_1d<degree+3)>::type>
162 Number *values_dofs_actual,
164 Number *gradients_quad,
165 Number *hessians_quad,
166 Number *scratch_data,
167 const bool evaluate_values,
168 const bool evaluate_gradients,
169 const bool evaluate_hessians)
172 if (runtime_n_q_points_1d == n_q_points_1d)
174 if (n_q_points_1d == degree+1 &&
175 shape_info.
element_type == internal::MatrixFreeFunctions::tensor_symmetric_collocation)
177 ::evaluate(shape_info, values_dofs_actual, values_quad,
178 gradients_quad, hessians_quad, scratch_data,
179 evaluate_values, evaluate_gradients, evaluate_hessians);
180 else if (degree < n_q_points_1d)
182 ::evaluate(shape_info, values_dofs_actual, values_quad,
183 gradients_quad, hessians_quad, scratch_data,
184 evaluate_values, evaluate_gradients, evaluate_hessians);
187 ::evaluate(shape_info, values_dofs_actual, values_quad,
188 gradients_quad, hessians_quad, scratch_data,
189 evaluate_values, evaluate_gradients, evaluate_hessians);
192 Factory<dim, n_components, Number, 1, degree, n_q_points_1d+1>::evaluate (shape_info, values_dofs_actual, values_quad,
193 gradients_quad, hessians_quad, scratch_data,
194 evaluate_values, evaluate_gradients, evaluate_hessians);
198 Number *values_dofs_actual,
200 Number *gradients_quad,
201 Number *scratch_data,
202 const bool integrate_values,
203 const bool integrate_gradients)
206 if (runtime_n_q_points_1d == n_q_points_1d)
208 if (n_q_points_1d == degree+1 &&
209 shape_info.
element_type == internal::MatrixFreeFunctions::tensor_symmetric_collocation)
211 ::integrate(shape_info, values_dofs_actual, values_quad,
212 gradients_quad, scratch_data,
213 integrate_values, integrate_gradients,
false);
214 else if (degree < n_q_points_1d)
216 ::integrate(shape_info, values_dofs_actual, values_quad,
217 gradients_quad, scratch_data,
218 integrate_values, integrate_gradients,
false);
221 ::integrate(shape_info, values_dofs_actual, values_quad, gradients_quad,
222 scratch_data, integrate_values, integrate_gradients,
false);
225 Factory<dim, n_components, Number, 1, degree, n_q_points_1d+1>
226 ::integrate (shape_info, values_dofs_actual, values_quad, gradients_quad,
227 scratch_data, integrate_values, integrate_gradients);
237 template<
int dim,
int n_components,
typename Number>
239 Number *values_dofs_actual,
241 Number *gradients_quad,
242 Number *hessians_quad,
243 Number *scratch_data,
244 const bool evaluate_values,
245 const bool evaluate_gradients,
246 const bool evaluate_hessians)
250 Factory<dim, n_components, Number>::evaluate
251 (shape_info, values_dofs_actual, values_quad, gradients_quad, hessians_quad,
252 scratch_data, evaluate_values, evaluate_gradients, evaluate_hessians);
261 template<
int dim,
int n_components,
typename Number>
263 Number *values_dofs_actual,
265 Number *gradients_quad,
266 Number *scratch_data,
267 const bool integrate_values,
268 const bool integrate_gradients)
272 Factory<dim, n_components, Number>::integrate
273 (shape_info, values_dofs_actual, values_quad, gradients_quad,
274 scratch_data, integrate_values, integrate_gradients);
290 template <
int dim,
int fe_degree,
int n_q_po
ints_1d,
int n_components,
typename Number>
301 Number *values_dofs_actual,
303 Number *gradients_quad,
304 Number *hessians_quad,
305 Number *scratch_data,
306 const bool evaluate_values,
307 const bool evaluate_gradients,
308 const bool evaluate_hessians);
318 Number *values_dofs_actual,
320 Number *gradients_quad,
321 Number *scratch_data,
322 const bool integrate_values,
323 const bool integrate_gradients);
336 template <
int dim,
int n_q_po
ints_1d,
int n_components,
typename Number>
348 Number *values_dofs_actual,
350 Number *gradients_quad,
351 Number *hessians_quad,
352 Number *scratch_data,
353 const bool evaluate_values,
354 const bool evaluate_gradients,
355 const bool evaluate_hessians);
366 Number *values_dofs_actual,
368 Number *gradients_quad,
369 Number *scratch_data,
370 const bool integrate_values,
371 const bool integrate_gradients);
377 template <
int dim,
int fe_degree,
int n_q_po
ints_1d,
int n_components,
typename Number>
382 Number *values_dofs_actual,
384 Number *gradients_quad,
385 Number *hessians_quad,
386 Number *scratch_data,
387 const bool evaluate_values,
388 const bool evaluate_gradients,
389 const bool evaluate_hessians)
393 if (fe_degree+1 == n_q_points_1d &&
394 shape_info.
element_type == internal::MatrixFreeFunctions::tensor_symmetric_collocation)
397 ::evaluate(shape_info, values_dofs_actual, values_quad,
398 gradients_quad, hessians_quad, scratch_data,
399 evaluate_values, evaluate_gradients, evaluate_hessians);
401 else if (fe_degree < n_q_points_1d &&
402 shape_info.
element_type <= internal::MatrixFreeFunctions::tensor_symmetric)
405 ::evaluate(shape_info, values_dofs_actual, values_quad,
406 gradients_quad, hessians_quad, scratch_data,
407 evaluate_values, evaluate_gradients, evaluate_hessians);
409 else if (shape_info.
element_type == internal::MatrixFreeFunctions::tensor_symmetric)
413 ::evaluate(shape_info, values_dofs_actual, values_quad,
414 gradients_quad, hessians_quad, scratch_data,
415 evaluate_values, evaluate_gradients, evaluate_hessians);
417 else if (shape_info.
element_type == internal::MatrixFreeFunctions::tensor_symmetric_plus_dg0)
421 ::evaluate(shape_info, values_dofs_actual, values_quad,
422 gradients_quad, hessians_quad, scratch_data,
423 evaluate_values, evaluate_gradients, evaluate_hessians);
425 else if (shape_info.
element_type == internal::MatrixFreeFunctions::truncated_tensor)
429 ::evaluate(shape_info, values_dofs_actual, values_quad,
430 gradients_quad, hessians_quad, scratch_data,
431 evaluate_values, evaluate_gradients, evaluate_hessians);
433 else if (shape_info.
element_type == internal::MatrixFreeFunctions::tensor_general)
437 ::evaluate(shape_info, values_dofs_actual, values_quad,
438 gradients_quad, hessians_quad, scratch_data,
439 evaluate_values, evaluate_gradients, evaluate_hessians);
447 template <
int dim,
int fe_degree,
int n_q_po
ints_1d,
int n_components,
typename Number>
452 Number *values_dofs_actual,
454 Number *gradients_quad,
455 Number *scratch_data,
456 const bool integrate_values,
457 const bool integrate_gradients)
461 if (fe_degree+1 == n_q_points_1d &&
462 shape_info.
element_type == internal::MatrixFreeFunctions::tensor_symmetric_collocation)
465 ::integrate(shape_info, values_dofs_actual, values_quad,
466 gradients_quad, scratch_data,
467 integrate_values, integrate_gradients,
false);
469 else if (fe_degree < n_q_points_1d &&
470 shape_info.
element_type <= internal::MatrixFreeFunctions::tensor_symmetric)
473 ::integrate(shape_info, values_dofs_actual, values_quad,
474 gradients_quad, scratch_data,
475 integrate_values, integrate_gradients,
false);
477 else if (shape_info.
element_type == internal::MatrixFreeFunctions::tensor_symmetric)
481 ::integrate(shape_info, values_dofs_actual, values_quad,
482 gradients_quad, scratch_data,
483 integrate_values, integrate_gradients,
false);
485 else if (shape_info.
element_type == internal::MatrixFreeFunctions::tensor_symmetric_plus_dg0)
489 ::integrate(shape_info, values_dofs_actual, values_quad,
490 gradients_quad, scratch_data,
491 integrate_values, integrate_gradients,
false);
493 else if (shape_info.
element_type == internal::MatrixFreeFunctions::truncated_tensor)
497 ::integrate(shape_info, values_dofs_actual, values_quad,
498 gradients_quad, scratch_data,
499 integrate_values, integrate_gradients,
false);
501 else if (shape_info.
element_type == internal::MatrixFreeFunctions::tensor_general)
505 ::integrate(shape_info, values_dofs_actual, values_quad,
506 gradients_quad, scratch_data,
507 integrate_values, integrate_gradients,
false);
515 template <
int dim,
int dummy,
int n_components,
typename Number>
520 Number *values_dofs_actual,
522 Number *gradients_quad,
523 Number *hessians_quad,
524 Number *scratch_data,
525 const bool evaluate_values,
526 const bool evaluate_gradients,
527 const bool evaluate_hessians)
529 if (shape_info.
element_type == internal::MatrixFreeFunctions::tensor_symmetric_plus_dg0)
533 ::evaluate(shape_info, values_dofs_actual, values_quad,
534 gradients_quad, hessians_quad, scratch_data,
535 evaluate_values, evaluate_gradients, evaluate_hessians);
537 else if (shape_info.
element_type == internal::MatrixFreeFunctions::truncated_tensor)
541 ::evaluate(shape_info, values_dofs_actual, values_quad,
542 gradients_quad, hessians_quad, scratch_data,
543 evaluate_values, evaluate_gradients, evaluate_hessians);
545 else if (shape_info.
element_type == internal::MatrixFreeFunctions::tensor_general)
548 ::evaluate(shape_info, values_dofs_actual, values_quad,
549 gradients_quad, hessians_quad, scratch_data,
550 evaluate_values, evaluate_gradients, evaluate_hessians);
552 symmetric_selector_evaluate<dim, n_components, Number>
553 (shape_info, values_dofs_actual, values_quad,
554 gradients_quad, hessians_quad, scratch_data,
555 evaluate_values, evaluate_gradients, evaluate_hessians);
560 template <
int dim,
int dummy,
int n_components,
typename Number>
565 Number *values_dofs_actual,
567 Number *gradients_quad,
568 Number *scratch_data,
569 const bool integrate_values,
570 const bool integrate_gradients)
572 if (shape_info.
element_type == internal::MatrixFreeFunctions::tensor_symmetric_plus_dg0)
576 ::integrate(shape_info, values_dofs_actual, values_quad,
577 gradients_quad, scratch_data,
578 integrate_values, integrate_gradients,
false);
580 else if (shape_info.
element_type == internal::MatrixFreeFunctions::truncated_tensor)
584 ::integrate(shape_info, values_dofs_actual, values_quad,
585 gradients_quad, scratch_data,
586 integrate_values, integrate_gradients,
false);
588 else if (shape_info.
element_type == internal::MatrixFreeFunctions::tensor_general)
591 ::integrate(shape_info, values_dofs_actual, values_quad,
592 gradients_quad, scratch_data,
593 integrate_values, integrate_gradients,
false);
595 symmetric_selector_integrate<dim, n_components, Number>
596 (shape_info, values_dofs_actual, values_quad,
597 gradients_quad, scratch_data,
598 integrate_values, integrate_gradients);
602 DEAL_II_NAMESPACE_CLOSE
static void integrate(const internal::MatrixFreeFunctions::ShapeInfo< Number > &shape_info, Number *values_dofs_actual, Number *values_quad, Number *gradients_quad, Number *scratch_data, const bool integrate_values, const bool integrate_gradients)
#define AssertThrow(cond, exc)
static void evaluate(const internal::MatrixFreeFunctions::ShapeInfo< Number > &shape_info, Number *values_dofs_actual, Number *values_quad, Number *gradients_quad, Number *hessians_quad, Number *scratch_data, const bool evaluate_values, const bool evaluate_gradients, const bool evaluate_hessians)
#define Assert(cond, exc)
unsigned int n_q_points_1d
static ::ExceptionBase & ExcNotImplemented()
unsigned int n_components(const DoFHandler< dim, spacedim > &dh)
static ::ExceptionBase & ExcInternalError()