FEAT 3
Finite Element Analysis Toolbox
Loading...
Searching...
No Matches
factory_wrapper.hpp
1// FEAT3: Finite Element Analysis Toolbox, Version 3
2// Copyright (C) 2010 by Stefan Turek & the FEAT group
3// FEAT3 is released under the GNU General Public License version 3,
4// see the file 'copyright.txt' in the top level directory for details.
5
6#pragma once
7
8// includes, FEAT
9#include <kernel/cubature/driver_factory.hpp>
10#include <kernel/cubature/refine_factory.hpp>
11#include <kernel/cubature/barycentre_driver.hpp>
12#include <kernel/cubature/trapezoidal_driver.hpp>
13#include <kernel/cubature/hammer_stroud_driver.hpp>
14#include <kernel/cubature/lauffer_driver.hpp>
15#include <kernel/cubature/silvester_driver.hpp>
16#include <kernel/cubature/dunavant_driver.hpp>
17#include <kernel/cubature/shunn_ham_driver.hpp>
18#include <kernel/cubature/simplex_scalar_factory.hpp>
19#include <kernel/cubature/tensor_product_factory.hpp>
20#include <kernel/cubature/scalar/factory_wrapper.hpp>
21
22namespace FEAT
23{
24 namespace Cubature
25 {
27 namespace Intern
28 {
29 template<
30 typename Shape_,
31 typename Functor_>
32 class DriverFactoryFunctor
33 {
34 protected:
35 Functor_& _functor;
36
37 public:
38 explicit DriverFactoryFunctor(Functor_& functor) :
39 _functor(functor)
40 {
41 }
42
43 template<template<typename> class Driver_>
44 void driver()
45 {
46 _functor.template factory< DriverFactory<Driver_, Shape_> >();
47 }
48 };
49
50 template<
51 typename ScalarDriver_,
52 typename Shape_,
53 bool tensorize_ = ScalarDriver_::tensorize>
54 class TensorProductFunctorHelper;
55
56 template<
57 typename ScalarDriver_,
58 bool tensorize_ = ScalarDriver_::tensorize>
59 class SimplexScalarFunctorHelper;
60 } // namespace Intern
62
68 template<typename Shape_>
69 class FactoryExplicitWrapper DOXY({});
70
76 template<>
77 class FactoryExplicitWrapper<Shape::Simplex<1> >
78 {
79 protected:
81
82 template<typename Functor_>
83 static void _driver_list(Functor_& /*functor*/)
84 {
85 // >>> CUBATURE DRIVER LIST >>>
86 // TODO: add you new cubature driver at the end of the list below, e.g.
87 // functor.template driver<YourDriverName>();
88
89 // <<< END OF CUBATURE DRIVER LIST <<<
90 }
91
92 template<typename Functor_>
93 static void _factory_list(Functor_& /*functor*/)
94 {
95 // >>> CUBATURE FACTORY LIST >>>
96 // TODO: add you new cubature factory at the end of the list below, e.g.
97 // functor.template factory<YourFactoryName>();
98
99 // <<< END OF CUBATURE FACTORY LIST <<<
100 }
101
102 public:
103 template<typename Functor_>
104 static void driver(Functor_& functor)
105 {
106 // call driver list
107 _driver_list(functor);
108 }
109
110 template<typename Functor_>
111 static void factory(Functor_& functor)
112 {
113 // call factory list
114 _factory_list(functor);
115
116 // call simplex-scalar functor
117 SimplexScalarFunctor<Functor_> scalar_functor(functor);
118 Scalar::FactoryWrapper::driver(scalar_functor);
119
120 // last: call driver factory functor
121 Intern::DriverFactoryFunctor<ShapeType, Functor_> driver_functor(functor);
122 _driver_list(driver_functor);
123 }
124
126 private:
127 template<typename Functor_>
128 class SimplexScalarFunctor
129 {
130 protected:
131 Functor_& _functor;
132
133 public:
134 explicit SimplexScalarFunctor(Functor_& functor) :
135 _functor(functor)
136 {
137 }
138
139 template<typename ScalarDriver_>
140 void driver()
141 {
142 Intern::SimplexScalarFunctorHelper<ScalarDriver_>::scalar_driver(_functor);
143 }
144 };
146 }; // class FactoryExplicitWrapper<Simplex<1>,...>
147
153 template<>
154 class FactoryExplicitWrapper<Shape::Simplex<2> >
155 {
156 protected:
158
159 template<typename Functor_>
160 static void _driver_list(Functor_& functor)
161 {
162 // >>> CUBATURE DRIVER LIST >>>
163 // TODO: add you new cubature driver at the end of the list below, e.g.
164 // functor.template driver<YourDriverName>();
165 functor.template driver<HammerStroudD2Driver>();
166 functor.template driver<HammerStroudD3Driver>();
167 functor.template driver<LaufferD2Driver>();
168 functor.template driver<SilvesterOpenDriver>();
169 functor.template driver<DunavantDriver>();
170
171 // <<< END OF CUBATURE DRIVER LIST <<<
172 }
173
174 template<typename Functor_>
175 static void _factory_list(Functor_& /*functor*/)
176 {
177 // >>> CUBATURE FACTORY LIST >>>
178 // TODO: add you new cubature factory at the end of the list below, e.g.
179 // functor.template factory<YourFactoryName>();
180
181 // <<< END OF CUBATURE FACTORY LIST <<<
182 }
183
184 public:
185 template<typename Functor_>
186 static void driver(Functor_& functor)
187 {
188 // call driver list
189 _driver_list(functor);
190 }
191
192 template<typename Functor_>
193 static void factory(Functor_& functor)
194 {
195 // call factory list
196 _factory_list(functor);
197
198 // last: call driver factory functor
199 Intern::DriverFactoryFunctor<ShapeType, Functor_> driver_functor(functor);
200 _driver_list(driver_functor);
201 }
202 }; // class FactoryExplicitWrapper<Simplex<2>,...>
203
209 template<>
210 class FactoryExplicitWrapper<Shape::Simplex<3> >
211 {
212 protected:
214
215 template<typename Functor_>
216 static void _driver_list(Functor_& functor)
217 {
218 // >>> CUBATURE DRIVER LIST >>>
219 // TODO: add you new cubature driver at the end of the list below, e.g.
220 // functor.template driver<YourDriverName>();
221 functor.template driver<HammerStroudD2Driver>();
222 functor.template driver<HammerStroudD3Driver>();
223 functor.template driver<HammerStroudD5Driver>();
224 functor.template driver<LaufferD2Driver>();
225 functor.template driver<LaufferD4Driver>();
226 functor.template driver<ShunnHamDriver>();
227
228 // <<< END OF CUBATURE DRIVER LIST <<<
229 }
230
231 template<typename Functor_>
232 static void _factory_list(Functor_& /*functor*/)
233 {
234 // >>> CUBATURE FACTORY LIST >>>
235 // TODO: add you new cubature factory at the end of the list below, e.g.
236 // functor.template factory<YourFactoryName>();
237
238 // <<< END OF CUBATURE FACTORY LIST <<<
239 }
240
241 public:
242 template<typename Functor_>
243 static void driver(Functor_& functor)
244 {
245 // call driver list
246 _driver_list(functor);
247 }
248
249 template<typename Functor_>
250 static void factory(Functor_& functor)
251 {
252 // call factory list
253 _factory_list(functor);
254
255 // last: call driver factory functor
256 Intern::DriverFactoryFunctor<ShapeType, Functor_> driver_functor(functor);
257 _driver_list(driver_functor);
258 }
259 }; // class FactoryExplicitWrapper<Simplex<3>,...>
260
266 template<>
267 class FactoryExplicitWrapper<Shape::Hypercube<1> >
268 {
269 protected:
271
272 template<typename Functor_>
273 static void _driver_list(Functor_& /*functor*/)
274 {
275 // >>> CUBATURE DRIVER LIST >>>
276 // TODO: add you new cubature driver at the end of the list below, e.g.
277 // functor.template driver<YourDriverName>();
278
279 // <<< END OF CUBATURE DRIVER LIST <<<
280 }
281
282 template<typename Functor_>
283 static void _factory_list(Functor_& /*functor*/)
284 {
285 // >>> CUBATURE FACTORY LIST >>>
286 // TODO: add you new cubature factory at the end of the list below, e.g.
287 // functor.template factory<YourFactoryName>();
288
289 // <<< END OF CUBATURE FACTORY LIST <<<
290 }
291
292 public:
293 template<typename Functor_>
294 static void driver(Functor_& functor)
295 {
296 // call driver list
297 _driver_list(functor);
298 }
299
300 template<typename Functor_>
301 static void factory(Functor_& functor)
302 {
303 // call factory list
304 _factory_list(functor);
305
306 // last: call driver factory functor
307 Intern::DriverFactoryFunctor<ShapeType, Functor_> driver_functor(functor);
308 _driver_list(driver_functor);
309 }
310 }; // class FactoryExplicitWrapper<Hypercube<1>,...>
311
317 template<>
318 class FactoryExplicitWrapper<Shape::Hypercube<2> >
319 {
320 protected:
322
323 template<typename Functor_>
324 static void _driver_list(Functor_& /*functor*/)
325 {
326 // >>> CUBATURE DRIVER LIST >>>
327 // TODO: add you new cubature driver at the end of the list below, e.g.
328 // functor.template driver<YourDriverName>();
329
330 // <<< END OF CUBATURE DRIVER LIST <<<
331 }
332
333 template<typename Functor_>
334 static void _factory_list(Functor_& /*functor*/)
335 {
336 // >>> CUBATURE FACTORY LIST >>>
337 // TODO: add you new cubature factory at the end of the list below, e.g.
338 // functor.template factory<YourFactoryName>();
339
340 // <<< END OF CUBATURE FACTORY LIST <<<
341 }
342
343 public:
344 template<typename Functor_>
345 static void driver(Functor_& functor)
346 {
347 // call driver list
348 _driver_list(functor);
349 }
350
351 template<typename Functor_>
352 static void factory(Functor_& functor)
353 {
354 // call factory list
355 _factory_list(functor);
356
357 // last: call driver factory functor
358 Intern::DriverFactoryFunctor<ShapeType, Functor_> driver_functor(functor);
359 _driver_list(driver_functor);
360 }
361 }; // class FactoryExplicitWrapper<Hypercube<2>,...>
362
368 template<>
369 class FactoryExplicitWrapper<Shape::Hypercube<3> >
370 {
371 protected:
373
374 template<typename Functor_>
375 static void _driver_list(Functor_& /*functor*/)
376 {
377 // >>> CUBATURE DRIVER LIST >>>
378 // TODO: add you new cubature driver at the end of the list below, e.g.
379 // functor.template driver<YourDriverName>();
380
381 // <<< END OF CUBATURE DRIVER LIST <<<
382 }
383
384 template<typename Functor_>
385 static void _factory_list(Functor_& /*functor*/)
386 {
387 // >>> CUBATURE FACTORY LIST >>>
388 // TODO: add you new cubature factory at the end of the list below, e.g.
389 // functor.template factory<YourFactoryName>();
390
391 // <<< END OF CUBATURE FACTORY LIST <<<
392 }
393
394 public:
395 template<typename Functor_>
396 static void driver(Functor_& functor)
397 {
398 // call driver list
399 _driver_list(functor);
400 }
401
402 template<typename Functor_>
403 static void factory(Functor_& functor)
404 {
405 // call factory list
406 _factory_list(functor);
407
408 // last: call driver factory functor
409 Intern::DriverFactoryFunctor<ShapeType, Functor_> driver_functor(functor);
410 _driver_list(driver_functor);
411 }
412 }; // class FactoryExplicitWrapper<Hypercube<3>,...>
413
419 template<typename Shape_>
420 class FactoryPartialWrapper DOXY({});
421
427 template<int dim_>
428 class FactoryPartialWrapper<Shape::Simplex<dim_> > :
429 public FactoryExplicitWrapper<Shape::Simplex<dim_> >
430 {
431 protected:
433
434 template<typename Functor_>
435 static void _driver_list(Functor_& /*functor*/)
436 {
437 // >>> CUBATURE DRIVER LIST >>>
438 // TODO: add you new cubature driver at the end of the list below, e.g.
439 // functor.template driver<YourDriverName>();
440
441
442 // <<< END OF CUBATURE DRIVER LIST <<<
443 }
444
445 template<typename Functor_>
446 static void _factory_list(Functor_& /*functor*/)
447 {
448 // >>> CUBATURE FACTORY LIST >>>
449 // TODO: add you new cubature factory at the end of the list below, e.g.
450 // functor.template factory<YourFactoryName>();
451
452 // <<< END OF CUBATURE FACTORY LIST <<<
453 }
454
455 public:
456 template<typename Functor_>
457 static void driver(Functor_& functor)
458 {
459 // first: call the base class driver function template
461
462 // call driver list
463 _driver_list(functor);
464 }
465
466 template<typename Functor_>
467 static void factory(Functor_& functor)
468 {
469 // first: call the base class factory function template
471
472 // call factory list
473 _factory_list(functor);
474
475 // last: call driver factory functor
476 Intern::DriverFactoryFunctor<ShapeType, Functor_> driver_functor(functor);
477 _driver_list(driver_functor);
478 }
479 }; // class FactoryPartialWrapper<Simplex<...>,...>
480
486 template<int dim_>
487 class FactoryPartialWrapper<Shape::Hypercube<dim_> > :
488 public FactoryExplicitWrapper<Shape::Hypercube<dim_> >
489 {
490 protected:
492
493 template<typename Functor_>
494 static void _driver_list(Functor_& /*functor*/)
495 {
496 // >>> CUBATURE DRIVER LIST >>>
497 // TODO: add you new cubature driver at the end of the list below, e.g.
498 // functor.template driver<YourDriverName>();
499
500 // <<< END OF CUBATURE DRIVER LIST <<<
501 }
502
503 template<typename Functor_>
504 static void _factory_list(Functor_& /*functor*/)
505 {
506 // >>> CUBATURE FACTORY LIST >>>
507 // TODO: add you new cubature factory at the end of the list below, e.g.
508 // functor.template factory<YourFactoryName>();
509
510 // <<< END OF CUBATURE FACTORY LIST <<<
511 }
512
513 public:
514 template<typename Functor_>
515 static void driver(Functor_& functor)
516 {
517 // first: call the base class driver function template
519
520 // call driver list
521 _driver_list(functor);
522 }
523
524 template<typename Functor_>
525 static void factory(Functor_& functor)
526 {
527 // first: call the base class factory function template
529
530 // call factory list
531 _factory_list(functor);
532
533 // call tensor-product functor
534 TensorProductFunctor<Functor_> tensor_functor(functor);
535 Scalar::FactoryWrapper::driver(tensor_functor);
536
537 // last: call driver factory functor
538 Intern::DriverFactoryFunctor<ShapeType, Functor_> driver_functor(functor);
539 _driver_list(driver_functor);
540 }
541
543 private:
544 template<typename Functor_>
545 class TensorProductFunctor
546 {
547 protected:
548 Functor_& _functor;
549
550 public:
551 explicit TensorProductFunctor(Functor_& functor) :
552 _functor(functor)
553 {
554 }
555
556 template<typename ScalarDriver_>
557 void driver()
558 {
559 Intern::TensorProductFunctorHelper<ScalarDriver_, Shape::Hypercube<dim_> >::scalar_driver(_functor);
560 }
561 };
563 }; // class FactoryPartialWrapper<Hypercube<...>,...>
564
570 template<typename Shape_>
572 public FactoryPartialWrapper<Shape_>
573 {
574 protected:
575 template<typename Functor_>
576 static void _driver_list(Functor_& functor)
577 {
578 // >>> CUBATURE DRIVER LIST >>>
579 // TODO: add you new cubature driver at the end of the list below, e.g.
580 // functor.template driver<YourDriverName>();
581 functor.template driver<BarycentreDriver>();
582 functor.template driver<TrapezoidalDriver>();
583
584 // <<< END OF CUBATURE DRIVER LIST <<<
585 }
586
587 template<typename Functor_>
588 static void _factory_list(Functor_& /*functor*/)
589 {
590 // >>> CUBATURE FACTORY LIST >>>
591 // TODO: add you new cubature factory at the end of the list below, e.g.
592 // functor.template factory<YourFactoryName>();
593
594 // <<< END OF CUBATURE FACTORY LIST <<<
595 }
596
597 public:
598 template<typename Functor_>
599 static void factory_no_refine(Functor_& functor)
600 {
601 // first: call the base class factory function template
603
604 // call factory list
605 _factory_list(functor);
606
607 // call driver factory functor
608 Intern::DriverFactoryFunctor<Shape_, Functor_> driver_functor(functor);
609 _driver_list(driver_functor);
610 }
611
612 template<typename Functor_>
613 static void driver(Functor_& functor)
614 {
615 // first: call the base class driver function template
617
618 // call driver list
619 _driver_list(functor);
620 }
621
622 template<typename Functor_>
623 static void factory(Functor_& functor)
624 {
625 // call non-refine factory list
626 factory_no_refine(functor);
627
628 // call refinement factory functor
629 RefineFactoryFunctor<Functor_> refine_functor(functor);
630 factory_no_refine(refine_functor);
631 }
632
634 private:
635 template<typename Functor_>
636 class RefineFactoryFunctor
637 {
638 protected:
639 Functor_& _functor;
640
641 public:
642 explicit RefineFactoryFunctor(Functor_& functor) :
643 _functor(functor)
644 {
645 }
646
647 template<typename Factory_>
648 void factory()
649 {
650 _functor.template factory< RefineFactory<Factory_> >();
651 }
652 };
654 }; // class FactoryWrapper<...>
655
657 namespace Intern
658 {
659 template<
660 typename ScalarDriver_,
661 typename Shape_>
662 class TensorProductFunctorHelper<ScalarDriver_, Shape_, true>
663 {
664 public:
665 template<typename Functor_>
666 static void scalar_driver(Functor_& functor)
667 {
668 functor.template factory< TensorProductFactory<ScalarDriver_, Shape_> >();
669 }
670 };
671
672 template<
673 typename ScalarDriver_,
674 typename Shape_>
675 class TensorProductFunctorHelper<ScalarDriver_, Shape_, false>
676 {
677 public:
678 template<typename Functor_>
679 static void scalar_driver(Functor_&)
680 {
681 // do nothing
682 }
683 };
684
685 template<typename ScalarDriver_>
686 class SimplexScalarFunctorHelper<ScalarDriver_, true>
687 {
688 public:
689 template<typename Functor_>
690 static void scalar_driver(Functor_& functor)
691 {
692 functor.template factory<SimplexScalarFactory<ScalarDriver_> >();
693 }
694 };
695
696 template<typename ScalarDriver_>
697 class SimplexScalarFunctorHelper<ScalarDriver_, false>
698 {
699 public:
700 template<typename Functor_>
701 static void scalar_driver(Functor_&)
702 {
703 // do nothing
704 }
705 };
706 } // namespace Intern
708 } // namespace Cubature
709} // namespace FEAT
Explicitly Specialized Cubature Factory Wrapper class template.
Partially Specialized Cubature Factory Wrapper class template.
Generic Cubature Factory Wrapper class template.
FEAT namespace.
Definition: adjactor.hpp:12
Hypercube shape tag struct template.
Definition: shape.hpp:64
Simplex shape tag struct template.
Definition: shape.hpp:44