Skip to content

Commit 4e9a637

Browse files
committed
QUAD: changed type to enum class, containing S and Q so far
1 parent f6c19b7 commit 4e9a637

File tree

3 files changed

+16
-13
lines changed

3 files changed

+16
-13
lines changed

include/pfasst/encap/imex_sweeper.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -199,9 +199,9 @@ namespace pfasst
199199
auto is_proper = this->get_is_proper();
200200
assert(nodes.size() >= 1);
201201

202-
this->s_mat = compute_quadrature(nodes, nodes, is_proper, 's');
202+
this->s_mat = compute_quadrature(nodes, nodes, is_proper, QuadratureMatrix::S);
203203

204-
auto q_mat = compute_quadrature(nodes, nodes, is_proper, 'q');
204+
auto q_mat = compute_quadrature(nodes, nodes, is_proper, QuadratureMatrix::Q);
205205
this->b_mat = matrix<time>(1, nodes.size());
206206
for (size_t m = 0; m < nodes.size(); m++) {
207207
this->b_mat(0, m) = q_mat(nodes.size() - 2, m);

include/pfasst/quadrature.hpp

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -227,10 +227,11 @@ namespace pfasst
227227
return pair<vector<node>, vector<bool>>(nodes, is_proper);
228228
}
229229

230-
230+
// enum class QuadratureMatrix {S, Q, QQ}; // returning QQ might be cool for 2nd-order stuff
231+
enum class QuadratureMatrix {S,Q};
231232
template<typename node = time_precision>
232233
matrix<node> compute_quadrature(vector<node> dst, vector<node> src, vector<bool> is_proper,
233-
char type)
234+
QuadratureMatrix type)
234235
{
235236
const size_t ndst = dst.size();
236237
const size_t nsrc = src.size();
@@ -247,7 +248,7 @@ namespace pfasst
247248
p[0] = 1.0;
248249
for (size_t j = 1; j < nsrc + 1; j++) { p[j] = 0.0; }
249250
for (size_t m = 0; m < nsrc; m++) {
250-
if ((!is_proper[m]) || (m == i)) { continue; }
251+
if ((!is_proper[m]) || (m == i)) { continue; }
251252

252253
// p_{m+1}(x) = (x - x_j) * p_m(x)
253254
p1[0] = 0.0;
@@ -261,12 +262,14 @@ namespace pfasst
261262
auto P = p.integrate();
262263
for (size_t j = 1; j < ndst; j++) {
263264
node q = 0.0;
264-
if (type == 's') {
265-
q = P.evaluate(dst[j]) - P.evaluate(dst[j - 1]);
265+
if (type == QuadratureMatrix::S) {
266+
q = P.evaluate(dst[j]) - P.evaluate(dst[j - 1]);
267+
} else if (type == QuadratureMatrix::Q) {
268+
q = P.evaluate(dst[j]) - P.evaluate(0.0);
266269
} else {
267-
q = P.evaluate(dst[j]) - P.evaluate(0.0);
270+
throw ValueError("Further matrix types are not implemented yet");
268271
}
269-
272+
270273
mat(j - 1, i) = q / den;
271274
}
272275
}

tests/test_quadrature.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -223,20 +223,20 @@ TEST(QuadratureTest, GaussLobattoNodes)
223223
{
224224
auto l3 = pfasst::compute_nodes<long double>(3, "gauss-lobatto");
225225
auto a3 = pfasst::augment_nodes(l3);
226-
auto s3 = pfasst::compute_quadrature(get<0>(a3), get<0>(a3), get<1>(a3), 's');
226+
auto s3 = pfasst::compute_quadrature(get<0>(a3), get<0>(a3), get<1>(a3), pfasst::QuadratureMatrix::S);
227227
const long double s3e[6] = { 0.20833333333333333,
228228
0.33333333333333333,
229229
-0.04166666666666666,
230230
-0.04166666666666666,
231231
0.33333333333333333,
232232
0.20833333333333333
233233
};
234-
234+
235235
EXPECT_THAT(s3.data(), testing::Pointwise(DoubleNear(), s3e));
236236

237237
auto l5 = pfasst::compute_nodes<long double>(5, "gauss-lobatto");
238238
auto a5 = pfasst::augment_nodes(l5);
239-
auto s5 = pfasst::compute_quadrature(get<0>(a5), get<0>(a5), get<1>(a5), 's');
239+
auto s5 = pfasst::compute_quadrature(get<0>(a5), get<0>(a5), get<1>(a5), pfasst::QuadratureMatrix::S);
240240
const long double s5e[] = { 0.067728432186156897969267419174073482,
241241
0.11974476934341168251615379970493965,
242242
-0.021735721866558113665511351745074292,
@@ -265,7 +265,7 @@ TEST(QuadratureTest, ClenshawCurtisNodes)
265265
{
266266
auto c4 = pfasst::compute_nodes<long double>(4, "clenshaw-curtis");
267267
auto a4 = pfasst::augment_nodes(c4);
268-
auto s4 = pfasst::compute_quadrature(get<0>(a4), get<0>(a4), get<1>(a4), 's');
268+
auto s4 = pfasst::compute_quadrature(get<0>(a4), get<0>(a4), get<1>(a4), pfasst::QuadratureMatrix::S);
269269
const long double s4e[] = { 0.10243055555555555555555555555555556,
270270
0.16319444444444444444444444444444444,
271271
-0.024305555555555555555555555555555556,

0 commit comments

Comments
 (0)