117 for (
unsigned int P = 1;
P <= 8; ++
P)
121 const unsigned int n = m->GetRows();
123 for (
unsigned int i = 0; i < n; ++i)
125 dmax = std::max(dmax, std::abs(ref->GetValue(i, i)));
128 for (
unsigned int i = 0; i < n; ++i)
130 for (
unsigned int j = 0; j < n; ++j)
134 diag = std::max(diag, std::abs(m->GetValue(i, i) -
135 ref->GetValue(i, i)));
139 off = std::max(off, std::abs(m->GetValue(i, j)));
143 BOOST_TEST_INFO(
"P = " <<
P);
144 BOOST_CHECK_SMALL(off / dmax, 1.0e-13);
145 BOOST_CHECK_SMALL(diag / dmax, 1.0e-13);
153 for (
unsigned int P = 1;
P <= 6; ++
P)
156 const unsigned int nq = e->GetTotPoints();
159 e->GetCoords(x, y, z);
160 for (
unsigned int a = 0; a <=
P; ++a)
162 for (
unsigned int b = 0; a + b <=
P; ++b)
164 for (
unsigned int k = 0; a + b + k <=
P; ++k)
166 for (
unsigned int i = 0; i < nq; ++i)
168 f[i] = std::pow(x[i], a) * std::pow(y[i], b) *
174 for (
unsigned int i = 0; i < nq; ++i)
176 err = std::max(err, std::abs(g[i] - f[i]));
178 BOOST_TEST_INFO(
"P = " <<
P <<
", x^" << a <<
" y^" << b
180 BOOST_CHECK_SMALL(err, 1.0e-11);
195 for (
unsigned int P = 1;
P <= 6; ++
P)
199 const unsigned int nq = e->GetTotPoints();
200 const unsigned int nm = e->GetNcoeffs();
204 const NekDouble shrink = 0.8, cx = -1.0 / 3.0, cz = -1.0 / 3.0;
205 std::vector<std::array<NekDouble, 2>> lattice, check;
206 for (
unsigned int i = 0; i <=
P; ++i)
208 for (
unsigned int k = 0; i + k <=
P; ++k)
213 {cx + shrink * (lx - cx), cz + shrink * (lz - cz)});
216 for (
const auto &st : std::vector<std::array<NekDouble, 2>>{
217 {0.13, 0.21}, {0.37, 0.11}, {0.05, 0.60}, {0.41, 0.33}})
219 check.push_back({-1.0 + 2.0 * st[0], -1.0 + 2.0 * st[1]});
221 const unsigned int nl = lattice.size();
222 auto monomial = [
P](
const std::array<NekDouble, 2> &pt,
223 const unsigned int j) {
224 unsigned int cnt = 0;
225 for (
unsigned int a = 0; a <=
P; ++a)
227 for (
unsigned int k = 0; a + k <=
P; ++k, ++cnt)
231 return std::pow(pt[0], a) * std::pow(pt[1], k);
237 std::vector<NekDouble>
V(nl * nl);
238 for (
unsigned int i = 0; i < nl; ++i)
240 for (
unsigned int j = 0; j < nl; ++j)
242 V[i * nl + j] = monomial(lattice[i], j);
247 for (
unsigned int m = 0; m < nm; ++m)
249 e->FillMode(m, phys);
250 auto eval = [&](
const std::array<NekDouble, 2> &pt) {
254 return e->PhysEvaluate(coord, phys);
256 std::vector<NekDouble> vals(nl);
257 for (
unsigned int i = 0; i < nl; ++i)
259 vals[i] = eval(lattice[i]);
261 const std::vector<NekDouble> coef =
Solve(
V, vals, nl);
263 for (
const auto &pt : check)
266 for (
unsigned int j = 0; j < nl; ++j)
268 fit += coef[j] * monomial(pt, j);
271 err = std::max(err, std::abs(fit - v));
272 scale = std::max(scale, std::abs(v));
274 BOOST_TEST_INFO(
"P = " <<
P <<
", mode " << m);
275 BOOST_CHECK_SMALL(err / scale, 1.0e-9);
291 for (
unsigned int P = 1;
P <= 6; ++
P)
294 const unsigned int np =
P + 3;
296 const PointsKey grj(np, eGaussRadauMAlpha2Beta0);
306 BOOST_REQUIRE_EQUAL(mod->GetNcoeffs(), orth->GetNcoeffs());
308 std::vector<unsigned int> modes;
311 for (
unsigned int m = 0; m < mod->GetNcoeffs(); ++m)
318 for (
unsigned int v = 0; v < 5; ++v)
320 modes.push_back(mod->GetVertexMap(v));
324 const unsigned int nq = mod->GetTotPoints();
326 for (
const unsigned int m : modes)
329 orth->FwdTrans(f, c);
330 orth->BwdTrans(c, g);
332 for (
unsigned int i = 0; i < nq; ++i)
334 err = std::max(err, std::abs(g[i] - f[i]));
335 scale = std::max(scale, std::abs(f[i]));
337 BOOST_TEST_INFO(
"P = " <<
P <<
", modified mode " << m);
338 BOOST_CHECK_SMALL(err / scale, 1.0e-11);
static std::vector< NekDouble > Solve(std::vector< NekDouble > A, std::vector< NekDouble > b, const unsigned int n)
Solve the dense system A x = b in place by Gaussian elimination with partial pivoting; A is row major...