FEAT 3
Finite Element Analysis Toolbox
Loading...
Searching...
No Matches
trapezoidal_driver.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_base.hpp>
10#include <kernel/util/meta_math.hpp>
11
12namespace FEAT
13{
14 namespace Cubature
15 {
17 namespace Intern
18 {
19 template<typename Shape_>
20 class TrapezoidalDriverBase :
21 public DriverBase<Shape_>
22 {
23 public:
25 static constexpr bool variadic = false;
26
28 static String name()
29 {
30 return "trapezoidal";
31 }
32 };
33 } // namespace Intern
35
47 template<typename Shape_>
48 class TrapezoidalDriver DOXY({});
49
50 // Simplex specialization
51 template<int dim_>
52 class TrapezoidalDriver<Shape::Simplex<dim_> > :
53 public Intern::TrapezoidalDriverBase<Shape::Simplex<dim_> >
54 {
55 public:
56 static constexpr int num_points = dim_ + 1;
57
64 template<
65 typename Weight_,
66 typename Coord_,
67 typename Point_>
68 static void fill(Rule<Shape::Simplex<dim_>, Weight_, Coord_, Point_>& rule)
69 {
70 for(int i(0); i <= (dim_); ++i)
71 {
72 // set weight
73 rule.get_weight(i) = Weight_(1) / Weight_(MetaMath::Factorial<dim_ + 1>::value);
74
75 // set point coords
76 for(int j(0); j < (dim_); ++j)
77 {
78 rule.get_coord(i,j) = (j+1) == i ? Coord_(1) : Coord_(0);
79 }
80 }
81 }
82 }; // class TrapezoidalDriver<Simplex<...>>
83
84 // Hypercube specialization
85 template<int dim_>
86 class TrapezoidalDriver<Shape::Hypercube<dim_> > :
87 public Intern::TrapezoidalDriverBase<Shape::Hypercube<dim_> >
88 {
89 public:
90 static constexpr int num_points = (1 << dim_); // = 2^dim_
91
98 template<
99 typename Weight_,
100 typename Coord_,
101 typename Point_>
102 static void fill(Rule<Shape::Hypercube<dim_>, Weight_, Coord_, Point_>& rule)
103 {
104 for(int i(0); i < (1 << dim_); ++i)
105 {
106 // set weight
107 rule.get_weight(i) = Weight_(1);
108
109 // set point coords
110 for(int j(0); j < (dim_); ++j)
111 {
112 rule.get_coord(i,j) = Coord_(((i >> j) & 1) << 1) - Coord_(1);
113 }
114 }
115 }
116 }; // class TrapezoidalDriver<Hypercube<...>>
117 } // namespace Cubature
118} // namespace FEAT
Cubature Rule class template.
Definition: rule.hpp:38
static void fill(Rule< Shape::Hypercube< dim_ >, Weight_, Coord_, Point_ > &rule)
Fills the cubature rule structure.
static void fill(Rule< Shape::Simplex< dim_ >, Weight_, Coord_, Point_ > &rule)
Fills the cubature rule structure.
Trapezoidal driver class template.
FEAT namespace.
Definition: adjactor.hpp:12
Factorial template meta-program.
Definition: meta_math.hpp:31
Hypercube shape tag struct template.
Definition: shape.hpp:64
Simplex shape tag struct template.
Definition: shape.hpp:44