FEAT 3
Finite Element Analysis Toolbox
Loading...
Searching...
No Matches
newton_cotes_closed_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/scalar/driver_base.hpp>
10
11namespace FEAT
12{
13 namespace Cubature
14 {
15 namespace Scalar
16 {
26 public DriverBase
27 {
28 public:
30 static constexpr bool variadic = true;
32 static constexpr int min_points = 2;
34 static constexpr int max_points = 7;
35
37 static String name()
38 {
39 return "newton-cotes-closed";
40 }
41
48 template<typename Functor_>
49 static void alias(Functor_& functor)
50 {
51 functor.alias("simpson", 3);
52 functor.alias("pulcherrima", 4);
53 functor.alias("milne-boole", 5);
54 functor.alias("6-point", 6);
55 functor.alias("weddle", 7);
56 }
57
67 template<
68 typename Weight_,
69 typename Coord_>
70 static void fill(Rule<Weight_, Coord_>& rule, int num_points)
71 {
72 // how many points do we have?
73 switch(num_points)
74 {
75 case 2:
76 rule.get_coord(0) = -Coord_(1);
77 rule.get_coord(1) = Coord_(1);
78
79 rule.get_weight(0) = Weight_(1);
80 rule.get_weight(1) = Weight_(1);
81 break;
82
83 case 3:
84 rule.get_coord(0) = -Coord_(1);
85 rule.get_coord(1) = Coord_(0);
86 rule.get_coord(2) = Coord_(1);
87
88 rule.get_weight(0) = Weight_(1) / Weight_(3);
89 rule.get_weight(1) = Weight_(4) / Weight_(3);
90 rule.get_weight(2) = Weight_(1) / Weight_(3);
91 break;
92
93 case 4:
94 rule.get_coord(0) = -Coord_(1);
95 rule.get_coord(1) = -Coord_(1) / Coord_(3);
96 rule.get_coord(2) = Coord_(1) / Coord_(3);
97 rule.get_coord(3) = Coord_(1);
98
99 rule.get_weight(0) = Weight_(1) / Weight_(4);
100 rule.get_weight(1) = Weight_(3) / Weight_(4);
101 rule.get_weight(2) = Weight_(3) / Weight_(4);
102 rule.get_weight(3) = Weight_(1) / Weight_(4);
103 break;
104
105 case 5:
106 rule.get_coord(0) = -Coord_(1);
107 rule.get_coord(1) = -Coord_(1) / Coord_(2);
108 rule.get_coord(2) = Coord_(0);
109 rule.get_coord(3) = Coord_(1) / Coord_(2);
110 rule.get_coord(4) = Coord_(1);
111
112 rule.get_weight(0) = Weight_(7) / Weight_(45);
113 rule.get_weight(1) = Weight_(32) / Weight_(45);
114 rule.get_weight(2) = Weight_(12) / Weight_(45);
115 rule.get_weight(3) = Weight_(32) / Weight_(45);
116 rule.get_weight(4) = Weight_(7) / Weight_(45);
117 break;
118
119 case 6:
120 rule.get_coord(0) = -Coord_(1);
121 rule.get_coord(1) = -Coord_(3) / Coord_(5);
122 rule.get_coord(2) = -Coord_(1) / Coord_(5);
123 rule.get_coord(3) = Coord_(1) / Coord_(5);
124 rule.get_coord(4) = Coord_(3) / Coord_(5);
125 rule.get_coord(5) = Coord_(1);
126
127 rule.get_weight(0) = Weight_(19) / Weight_(144);
128 rule.get_weight(1) = Weight_(75) / Weight_(144);
129 rule.get_weight(2) = Weight_(50) / Weight_(144);
130 rule.get_weight(3) = Weight_(50) / Weight_(144);
131 rule.get_weight(4) = Weight_(75) / Weight_(144);
132 rule.get_weight(5) = Weight_(19) / Weight_(144);
133 break;
134
135 case 7:
136 rule.get_coord(0) = -Coord_(1);
137 rule.get_coord(1) = -Coord_(2) / Coord_(3);
138 rule.get_coord(2) = -Coord_(1) / Coord_(3);
139 rule.get_coord(3) = Coord_(0);
140 rule.get_coord(4) = Coord_(1) / Coord_(3);
141 rule.get_coord(5) = Coord_(2) / Coord_(3);
142 rule.get_coord(6) = Coord_(1);
143
144 rule.get_weight(0) = Weight_(41) / Weight_(420);
145 rule.get_weight(1) = Weight_(216) / Weight_(420);
146 rule.get_weight(2) = Weight_(27) / Weight_(420);
147 rule.get_weight(3) = Weight_(272) / Weight_(420);
148 rule.get_weight(4) = Weight_(27) / Weight_(420);
149 rule.get_weight(5) = Weight_(216) / Weight_(420);
150 rule.get_weight(6) = Weight_(41) / Weight_(420);
151 break;
152 }
153 }
154 }; // class NewtonCotesClosedDriver<...>
155 } // namespace Scalar
156 } // namespace Cubature
157} // namespace FEAT
Scalar cubature driver base class.
Definition: driver_base.hpp:23
Closed Newton-Cotes Rule driver class template.
static constexpr int max_points
this rule has at most 7 points
static constexpr bool variadic
this rule is variadic
static void alias(Functor_ &functor)
Adds the driver's aliases.
static void fill(Rule< Weight_, Coord_ > &rule, int num_points)
Fills the cubature rule structure.
static constexpr int min_points
this rule has at least 2 points
static String name()
Returns the name of the cubature rule.
Scalar Cubature Rule class template.
Definition: rule.hpp:39
String class implementation.
Definition: string.hpp:46
FEAT namespace.
Definition: adjactor.hpp:12