Nektar++
Loading...
Searching...
No Matches
Typedefs | Functions
Nektar::StdRegionsUnitTests Namespace Reference

Typedefs

using ModeLabels = std::vector< std::array< int, 3 > >
 Mode indices (p, q, r) of an orthogonal expansion, in storage order.
 

Functions

void CheckInvBwdTrans (const StdRegions::StdExpansionSharedPtr &exp)
 
 BOOST_AUTO_TEST_CASE (TestQuadInvBwdTransPseudoInverse)
 
 BOOST_AUTO_TEST_CASE (TestHexInvBwdTransPseudoInverse)
 
static StdRegions::StdPyrExpSharedPtr MakeOrthoPyr (const unsigned int P, const unsigned int np)
 The orthogonal pyramid of order P on np points per direction of the default orthogonal rule: Gauss-Legendre, Gauss-Legendre and Gauss-Jacobi(1,0) in the collapsed direction.
 
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, n by n.
 
static DNekMatSharedPtr Mass (const StdRegions::StdPyrExpSharedPtr &e)
 
 BOOST_AUTO_TEST_CASE (TestPyrOrthoMassDiagonal)
 
 BOOST_AUTO_TEST_CASE (TestPyrOrthoPolynomials)
 Every monomial x^a y^b z^c of total degree at most P is in the span: its projection reproduces it at the quadrature points.
 
 BOOST_AUTO_TEST_CASE (TestPyrOrthoTriFaceTrace)
 
 BOOST_AUTO_TEST_CASE (TestPyrModifiedInOrthoSpan)
 
void CheckReduceOrderCoeffs (const StdRegions::StdExpansionSharedPtr &exp, const StdRegions::StdExpansionSharedPtr &ortho, const std::vector< int > &degree, const int numMin)
 Check ReduceOrderCoeffs mode by mode.
 
 BOOST_AUTO_TEST_CASE (TestSegReduceOrderCoeffs)
 
void CheckQuad (const int nm0, const int nm1, const int numMin)
 
 BOOST_AUTO_TEST_CASE (TestQuadReduceOrderCoeffs)
 
void CheckTri (const int nm, const int numMin)
 
 BOOST_AUTO_TEST_CASE (TestTriReduceOrderCoeffs)
 
void CheckTet (const int nm, const int numMin)
 
 BOOST_AUTO_TEST_CASE (TestTetReduceOrderCoeffs)
 
 BOOST_AUTO_TEST_CASE (TestPrismReduceOrderCoeffs)
 
void CheckSVVLaplacianFilter (const StdRegions::StdExpansionSharedPtr &ortho, const StdRegions::ConstFactorMap &factors, const std::vector< NekDouble > &weight)
 Check SVVLaplacianFilter mode by mode.
 
NekDouble DGKernelWeight (const std::vector< int > &nmodes, const std::array< int, 3 > &label, const NekDouble diffCoeff)
 DG kernel weight of the mode label of an expansion with nmodes.
 
NekDouble PowerKernelWeight (const std::vector< int > &nmodes, const std::array< int, 3 > &label, const NekDouble cutoff, const NekDouble diffCoeff)
 Power kernel weight of the mode label of an expansion with nmodes.
 
void CheckKernels (const StdRegions::StdExpansionSharedPtr &ortho, const std::vector< int > &nmodes, const ModeLabels &labels)
 Check the DG and power kernels of SVVLaplacianFilter.
 
StdRegions::StdExpansionSharedPtr OrthoQuad (const int nm0, const int nm1, ModeLabels &labels)
 Orthogonal quadrilateral; modes stored with p fastest.
 
StdRegions::StdExpansionSharedPtr OrthoHex (const int nm0, const int nm1, const int nm2, ModeLabels &labels)
 Orthogonal hexahedron; modes stored with p fastest, then q, then r.
 
 BOOST_AUTO_TEST_CASE (TestSegSVVLaplacianFilter)
 
 BOOST_AUTO_TEST_CASE (TestQuadSVVLaplacianFilter)
 
 BOOST_AUTO_TEST_CASE (TestHexSVVLaplacianFilter)
 
 BOOST_AUTO_TEST_CASE (TestTriSVVLaplacianFilter)
 
 BOOST_AUTO_TEST_CASE (TestTetSVVLaplacianFilter)
 
 BOOST_AUTO_TEST_CASE (TestPrismSVVLaplacianFilter)
 
 BOOST_AUTO_TEST_CASE (TestPyrSVVLaplacianFilter)
 
static StdRegions::StdTetExpSharedPtr MakeTet (const unsigned int np, const PointsType p0, const PointsType p1, const PointsType p2)
 The P3 orthogonal tet on np points per direction of the given types.
 
static NekDouble MassDifference (const StdRegions::StdTetExpSharedPtr &a, const StdRegions::StdTetExpSharedPtr &b)
 The largest entry of the difference between the mass matrices of a and b.
 
 BOOST_AUTO_TEST_CASE (TestTetExactMassRules)
 

Typedef Documentation

◆ ModeLabels

using Nektar::StdRegionsUnitTests::ModeLabels = typedef std::vector<std::array<int, 3> >

Mode indices (p, q, r) of an orthogonal expansion, in storage order.

Definition at line 55 of file TestSVVLaplacianFilter.cpp.

Function Documentation

◆ BOOST_AUTO_TEST_CASE() [1/19]

Nektar::StdRegionsUnitTests::BOOST_AUTO_TEST_CASE ( TestHexInvBwdTransPseudoInverse  )

Definition at line 99 of file TestInvBwdTrans.cpp.

100{
101 using namespace LibUtilities;
102
103 const PointsKey pointsKey(5, eGaussLobattoLegendre);
104 const BasisKey basisKey(eModified_A, 3, pointsKey);
105
108 basisKey, basisKey, basisKey);
109 CheckInvBwdTrans(exp);
110}
Describes the specification for a Basis.
Definition Basis.h:45
Defines a specification for a set of points.
Definition Points.h:50
General purpose memory allocation routines with the ability to allocate from thread specific memory p...
std::shared_ptr< StdExpansion > StdExpansionSharedPtr
void CheckInvBwdTrans(const StdRegions::StdExpansionSharedPtr &exp)

References Nektar::MemoryManager< DataType >::AllocateSharedPtr(), CheckInvBwdTrans(), Nektar::LibUtilities::eGaussLobattoLegendre, and Nektar::LibUtilities::eModified_A.

◆ BOOST_AUTO_TEST_CASE() [2/19]

Nektar::StdRegionsUnitTests::BOOST_AUTO_TEST_CASE ( TestHexSVVLaplacianFilter  )

Definition at line 270 of file TestSVVLaplacianFilter.cpp.

271{
272 // Anisotropic orders tell a mode's p, q and r apart.
273 for (auto [nm0, nm1, nm2] :
274 {std::array{4, 4, 4}, std::array{3, 4, 5}, std::array{5, 4, 3}})
275 {
276 ModeLabels labels;
277 auto ortho = OrthoHex(nm0, nm1, nm2, labels);
278 CheckKernels(ortho, {nm0, nm1, nm2}, labels);
279
280 // Exponential kernel, acting on each index separately.
281 const NekDouble svvDiffCoeff = 0.5, cutoffRatio = 0.5;
282 StdRegions::ConstFactorMap factors;
283 factors[StdRegions::eFactorSVVCutoffRatio] = cutoffRatio;
284 factors[StdRegions::eFactorSVVDiffCoeff] = svvDiffCoeff;
285
286 const int cutoff = static_cast<int>(cutoffRatio * std::min(nm0, nm1));
287 const int nmodes = std::max({nm0, nm1, nm2});
288 auto fac = [&](const int j) {
289 NekDouble f = 1.0;
290 if (j >= cutoff)
291 {
292 f = std::abs((j - nmodes) / (j - cutoff + 1.0));
293 f *= f;
294 }
295 return f;
296 };
297
298 std::vector<NekDouble> weight(labels.size());
299 for (size_t n = 0; n < labels.size(); ++n)
300 {
301 const auto [p, q, r] = labels[n];
302 weight[n] =
303 (p >= cutoff || q >= cutoff || r >= cutoff)
304 ? svvDiffCoeff * std::exp(-(fac(p) + fac(q) + fac(r)))
305 : 0.0;
306 }
307 CheckSVVLaplacianFilter(ortho, factors, weight);
308 }
309}
std::vector< std::array< int, 3 > > ModeLabels
Mode indices (p, q, r) of an orthogonal expansion, in storage order.
void CheckKernels(const StdRegions::StdExpansionSharedPtr &ortho, const std::vector< int > &nmodes, const ModeLabels &labels)
Check the DG and power kernels of SVVLaplacianFilter.
void CheckSVVLaplacianFilter(const StdRegions::StdExpansionSharedPtr &ortho, const StdRegions::ConstFactorMap &factors, const std::vector< NekDouble > &weight)
Check SVVLaplacianFilter mode by mode.
StdRegions::StdExpansionSharedPtr OrthoHex(const int nm0, const int nm1, const int nm2, ModeLabels &labels)
Orthogonal hexahedron; modes stored with p fastest, then q, then r.
std::vector< double > p(NPUPPER)
StdRegions::ConstFactorMap factors

References CheckKernels(), CheckSVVLaplacianFilter(), Nektar::StdRegions::eFactorSVVCutoffRatio, Nektar::StdRegions::eFactorSVVDiffCoeff, and OrthoHex().

◆ BOOST_AUTO_TEST_CASE() [3/19]

Nektar::StdRegionsUnitTests::BOOST_AUTO_TEST_CASE ( TestPrismReduceOrderCoeffs  )

Definition at line 217 of file StdRegions/TestReduceOrderCoeffs.cpp.

218{
219 using namespace LibUtilities;
220 const int nm = 4;
221 const PointsKey pkey0(nm + 1, eGaussLobattoLegendre);
222 const PointsKey pkey2(nm, eGaussRadauMAlpha1Beta0);
223 const BasisKey b0(eModified_A, nm, pkey0), b2(eModified_B, nm, pkey2);
224 const BasisKey o0(eOrtho_A, nm, pkey0), o2(eOrtho_B, nm, pkey2);
225
226 auto exp =
228 auto ortho =
230
231 // Modes are stored with p outermost, then q, then r < nm - p; the degree
232 // is the larger of q and the collapsed pair's total p + r.
233 std::vector<int> degree;
234 for (int p = 0; p < nm; ++p)
235 {
236 for (int q = 0; q < nm; ++q)
237 {
238 for (int r = 0; r < nm - p; ++r)
239 {
240 degree.push_back(std::max(q, p + r));
241 }
242 }
243 }
244 CheckReduceOrderCoeffs(exp, ortho, degree, nm - 1);
245}
void CheckReduceOrderCoeffs(const StdRegions::StdExpansionSharedPtr &exp, const StdRegions::StdExpansionSharedPtr &ortho, const std::vector< int > &degree, const int numMin)
Check ReduceOrderCoeffs mode by mode.

References Nektar::MemoryManager< DataType >::AllocateSharedPtr(), CheckReduceOrderCoeffs(), Nektar::LibUtilities::eGaussLobattoLegendre, Nektar::LibUtilities::eModified_A, Nektar::LibUtilities::eModified_B, Nektar::LibUtilities::eOrtho_A, and Nektar::LibUtilities::eOrtho_B.

◆ BOOST_AUTO_TEST_CASE() [4/19]

Nektar::StdRegionsUnitTests::BOOST_AUTO_TEST_CASE ( TestPrismSVVLaplacianFilter  )

Definition at line 361 of file TestSVVLaplacianFilter.cpp.

362{
363 const int nm = 4;
364 const BasisKey b0(eOrtho_A, nm, PointsKey(nm + 1, eGaussLobattoLegendre));
365 const BasisKey b2(eOrtho_B, nm, PointsKey(nm, eGaussRadauMAlpha1Beta0));
366 auto ortho =
368
369 // Modes are stored with p outermost, then q, then r < nm - p.
370 ModeLabels labels;
371 for (int p = 0; p < nm; ++p)
372 {
373 for (int q = 0; q < nm; ++q)
374 {
375 for (int r = 0; r < nm - p; ++r)
376 {
377 labels.push_back({p, q, r});
378 }
379 }
380 }
381 CheckKernels(ortho, {nm, nm, nm}, labels);
382}

References Nektar::MemoryManager< DataType >::AllocateSharedPtr(), CheckKernels(), Nektar::LibUtilities::eGaussLobattoLegendre, Nektar::LibUtilities::eOrtho_A, and Nektar::LibUtilities::eOrtho_B.

◆ BOOST_AUTO_TEST_CASE() [5/19]

Nektar::StdRegionsUnitTests::BOOST_AUTO_TEST_CASE ( TestPyrModifiedInOrthoSpan  )

The modified (C0) pyramid against the orthogonal span, which spectral vanishing viscosity and other modal operations transform to. Its five vertex modes, rational functions of (x, y, z), lie in the span for every order, where with the old p+q exponent four of them did not even at P = 1. Up to P = 2 every modified mode lies in it. From P = 3 the modified quadrilateral-face and interior modes whose exponent p+q-2 exceeds max(p,q) do not; they carry the same mismatch the orthogonal pyramid had.

Definition at line 289 of file TestPyrExactMass.cpp.

290{
291 for (unsigned int P = 1; P <= 6; ++P)
292 {
293 // One grid for both, rich enough for either space.
294 const unsigned int np = P + 3;
295 const PointsKey gll(np, eGaussLobattoLegendre);
296 const PointsKey grj(np, eGaussRadauMAlpha2Beta0);
297 const auto mod =
299 BasisKey(eModified_A, P + 1, gll),
300 BasisKey(eModified_A, P + 1, gll),
301 BasisKey(eModifiedPyr_C, P + 1, grj));
302 const auto orth =
304 BasisKey(eOrtho_A, P + 1, gll), BasisKey(eOrtho_A, P + 1, gll),
305 BasisKey(eOrthoPyr_C, P + 1, grj));
306 BOOST_REQUIRE_EQUAL(mod->GetNcoeffs(), orth->GetNcoeffs());
307
308 std::vector<unsigned int> modes;
309 if (P <= 2)
310 {
311 for (unsigned int m = 0; m < mod->GetNcoeffs(); ++m)
312 {
313 modes.push_back(m);
314 }
315 }
316 else
317 {
318 for (unsigned int v = 0; v < 5; ++v)
319 {
320 modes.push_back(mod->GetVertexMap(v));
321 }
322 }
323
324 const unsigned int nq = mod->GetTotPoints();
325 Array<OneD, NekDouble> f(nq), c(orth->GetNcoeffs()), g(nq);
326 for (const unsigned int m : modes)
327 {
328 mod->FillMode(m, f);
329 orth->FwdTrans(f, c);
330 orth->BwdTrans(c, g);
331 NekDouble err = 0.0, scale = 0.0;
332 for (unsigned int i = 0; i < nq; ++i)
333 {
334 err = std::max(err, std::abs(g[i] - f[i]));
335 scale = std::max(scale, std::abs(f[i]));
336 }
337 BOOST_TEST_INFO("P = " << P << ", modified mode " << m);
338 BOOST_CHECK_SMALL(err / scale, 1.0e-11);
339 }
340 }
341}
#define P(i)

References Nektar::MemoryManager< DataType >::AllocateSharedPtr(), Nektar::LibUtilities::eGaussLobattoLegendre, Nektar::LibUtilities::eModified_A, Nektar::LibUtilities::eModifiedPyr_C, Nektar::LibUtilities::eOrtho_A, Nektar::LibUtilities::eOrthoPyr_C, and Nektar::LibUtilities::P.

◆ BOOST_AUTO_TEST_CASE() [6/19]

Nektar::StdRegionsUnitTests::BOOST_AUTO_TEST_CASE ( TestPyrOrthoMassDiagonal  )

With the default NUMPOINTS = NUMMODES the mass matrix is diagonal, and its diagonal is that of the mass matrix on an over-integrated rule: every mode has degree at most P in the collapsed direction, so the products the rule integrates have degree at most 2P + 1, its exactness.

Definition at line 115 of file TestPyrExactMass.cpp.

116{
117 for (unsigned int P = 1; P <= 8; ++P)
118 {
119 const auto m = Mass(MakeOrthoPyr(P, P + 1));
120 const auto ref = Mass(MakeOrthoPyr(P, 3 * P + 6));
121 const unsigned int n = m->GetRows();
122 NekDouble dmax = 0.0;
123 for (unsigned int i = 0; i < n; ++i)
124 {
125 dmax = std::max(dmax, std::abs(ref->GetValue(i, i)));
126 }
127 NekDouble off = 0.0, diag = 0.0;
128 for (unsigned int i = 0; i < n; ++i)
129 {
130 for (unsigned int j = 0; j < n; ++j)
131 {
132 if (i == j)
133 {
134 diag = std::max(diag, std::abs(m->GetValue(i, i) -
135 ref->GetValue(i, i)));
136 }
137 else
138 {
139 off = std::max(off, std::abs(m->GetValue(i, j)));
140 }
141 }
142 }
143 BOOST_TEST_INFO("P = " << P);
144 BOOST_CHECK_SMALL(off / dmax, 1.0e-13);
145 BOOST_CHECK_SMALL(diag / dmax, 1.0e-13);
146 }
147}
static DNekMatSharedPtr Mass(const StdRegions::StdPyrExpSharedPtr &e)
static StdRegions::StdPyrExpSharedPtr MakeOrthoPyr(const unsigned int P, const unsigned int np)
The orthogonal pyramid of order P on np points per direction of the default orthogonal rule: Gauss-Le...

References MakeOrthoPyr(), Mass(), and Nektar::LibUtilities::P.

◆ BOOST_AUTO_TEST_CASE() [7/19]

Nektar::StdRegionsUnitTests::BOOST_AUTO_TEST_CASE ( TestPyrOrthoPolynomials  )

Every monomial x^a y^b z^c of total degree at most P is in the span: its projection reproduces it at the quadrature points.

Definition at line 151 of file TestPyrExactMass.cpp.

152{
153 for (unsigned int P = 1; P <= 6; ++P)
154 {
155 const auto e = MakeOrthoPyr(P, P + 3);
156 const unsigned int nq = e->GetTotPoints();
157 Array<OneD, NekDouble> x(nq), y(nq), z(nq), f(nq), c(e->GetNcoeffs()),
158 g(nq);
159 e->GetCoords(x, y, z);
160 for (unsigned int a = 0; a <= P; ++a)
161 {
162 for (unsigned int b = 0; a + b <= P; ++b)
163 {
164 for (unsigned int k = 0; a + b + k <= P; ++k)
165 {
166 for (unsigned int i = 0; i < nq; ++i)
167 {
168 f[i] = std::pow(x[i], a) * std::pow(y[i], b) *
169 std::pow(z[i], k);
170 }
171 e->FwdTrans(f, c);
172 e->BwdTrans(c, g);
173 NekDouble err = 0.0;
174 for (unsigned int i = 0; i < nq; ++i)
175 {
176 err = std::max(err, std::abs(g[i] - f[i]));
177 }
178 BOOST_TEST_INFO("P = " << P << ", x^" << a << " y^" << b
179 << " z^" << k);
180 BOOST_CHECK_SMALL(err, 1.0e-11);
181 }
182 }
183 }
184 }
185}

References MakeOrthoPyr(), and Nektar::LibUtilities::P.

◆ BOOST_AUTO_TEST_CASE() [8/19]

Nektar::StdRegionsUnitTests::BOOST_AUTO_TEST_CASE ( TestPyrOrthoTriFaceTrace  )

On the triangular face y = -1 every mode is a polynomial of total degree at most P in (x, z), as on a tetrahedron's face. Each mode is interpolated from a degree-P fit on a lattice of the face and checked at other face points.

Definition at line 193 of file TestPyrExactMass.cpp.

194{
195 for (unsigned int P = 1; P <= 6; ++P)
196 {
197 // Enough points that evaluating a mode from its values is exact.
198 const auto e = MakeOrthoPyr(P, 2 * P + 3);
199 const unsigned int nq = e->GetTotPoints();
200 const unsigned int nm = e->GetNcoeffs();
201
202 // A lattice of the face shrunk about its centroid, so the apex is
203 // not sampled, and the degree-P monomials in (x, z).
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)
207 {
208 for (unsigned int k = 0; i + k <= P; ++k)
209 {
210 const NekDouble lx = -1.0 + 2.0 * i / P;
211 const NekDouble lz = -1.0 + 2.0 * k / P;
212 lattice.push_back(
213 {cx + shrink * (lx - cx), cz + shrink * (lz - cz)});
214 }
215 }
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}})
218 {
219 check.push_back({-1.0 + 2.0 * st[0], -1.0 + 2.0 * st[1]});
220 }
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)
226 {
227 for (unsigned int k = 0; a + k <= P; ++k, ++cnt)
228 {
229 if (cnt == j)
230 {
231 return std::pow(pt[0], a) * std::pow(pt[1], k);
232 }
233 }
234 }
235 return 0.0;
236 };
237 std::vector<NekDouble> V(nl * nl);
238 for (unsigned int i = 0; i < nl; ++i)
239 {
240 for (unsigned int j = 0; j < nl; ++j)
241 {
242 V[i * nl + j] = monomial(lattice[i], j);
243 }
244 }
245
246 Array<OneD, NekDouble> phys(nq), coord(3);
247 for (unsigned int m = 0; m < nm; ++m)
248 {
249 e->FillMode(m, phys);
250 auto eval = [&](const std::array<NekDouble, 2> &pt) {
251 coord[0] = pt[0];
252 coord[1] = -1.0;
253 coord[2] = pt[1];
254 return e->PhysEvaluate(coord, phys);
255 };
256 std::vector<NekDouble> vals(nl);
257 for (unsigned int i = 0; i < nl; ++i)
258 {
259 vals[i] = eval(lattice[i]);
260 }
261 const std::vector<NekDouble> coef = Solve(V, vals, nl);
262 NekDouble err = 0.0, scale = 1.0;
263 for (const auto &pt : check)
264 {
265 NekDouble fit = 0.0;
266 for (unsigned int j = 0; j < nl; ++j)
267 {
268 fit += coef[j] * monomial(pt, j);
269 }
270 const NekDouble v = eval(pt);
271 err = std::max(err, std::abs(fit - v));
272 scale = std::max(scale, std::abs(v));
273 }
274 BOOST_TEST_INFO("P = " << P << ", mode " << m);
275 BOOST_CHECK_SMALL(err / scale, 1.0e-9);
276 }
277 }
278}
#define V(k, j)
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...
STL namespace.

References MakeOrthoPyr(), Nektar::LibUtilities::P, Solve(), and V.

◆ BOOST_AUTO_TEST_CASE() [9/19]

Nektar::StdRegionsUnitTests::BOOST_AUTO_TEST_CASE ( TestPyrSVVLaplacianFilter  )

Definition at line 384 of file TestSVVLaplacianFilter.cpp.

385{
386 const int nm = 4;
387 const BasisKey b0(eOrtho_A, nm, PointsKey(nm + 1, eGaussLobattoLegendre));
388 const BasisKey b2(eOrthoPyr_C, nm, PointsKey(nm, eGaussRadauMAlpha2Beta0));
389 auto ortho =
391
392 // Modes are stored with p outermost, then q, then r < nm - max(p, q).
393 ModeLabels labels;
394 for (int p = 0; p < nm; ++p)
395 {
396 for (int q = 0; q < nm; ++q)
397 {
398 for (int r = 0; r < nm - std::max(p, q); ++r)
399 {
400 labels.push_back({p, q, r});
401 }
402 }
403 }
404 CheckKernels(ortho, {nm, nm, nm}, labels);
405}

References Nektar::MemoryManager< DataType >::AllocateSharedPtr(), CheckKernels(), Nektar::LibUtilities::eGaussLobattoLegendre, Nektar::LibUtilities::eOrtho_A, and Nektar::LibUtilities::eOrthoPyr_C.

◆ BOOST_AUTO_TEST_CASE() [10/19]

Nektar::StdRegionsUnitTests::BOOST_AUTO_TEST_CASE ( TestQuadInvBwdTransPseudoInverse  )

Definition at line 86 of file TestInvBwdTrans.cpp.

87{
88 using namespace LibUtilities;
89
90 const PointsKey pointsKey(6, eGaussLobattoLegendre);
91 const BasisKey basisKey(eModified_A, 4, pointsKey);
92
95 basisKey);
97}

References Nektar::MemoryManager< DataType >::AllocateSharedPtr(), CheckInvBwdTrans(), Nektar::LibUtilities::eGaussLobattoLegendre, and Nektar::LibUtilities::eModified_A.

◆ BOOST_AUTO_TEST_CASE() [11/19]

Nektar::StdRegionsUnitTests::BOOST_AUTO_TEST_CASE ( TestQuadReduceOrderCoeffs  )

Definition at line 139 of file StdRegions/TestReduceOrderCoeffs.cpp.

140{
141 CheckQuad(4, 4, 3);
142 CheckQuad(4, 4, 2);
143 // Anisotropic: numMin above the smaller mode count, and below it.
144 CheckQuad(4, 6, 5);
145 CheckQuad(6, 4, 3);
146}
void CheckQuad(const int nm0, const int nm1, const int numMin)

References CheckQuad().

◆ BOOST_AUTO_TEST_CASE() [12/19]

Nektar::StdRegionsUnitTests::BOOST_AUTO_TEST_CASE ( TestQuadSVVLaplacianFilter  )

Definition at line 236 of file TestSVVLaplacianFilter.cpp.

237{
238 // Anisotropic orders tell a mode's p and q apart.
239 for (auto [nm0, nm1] :
240 {std::array{5, 5}, std::array{4, 6}, std::array{6, 4}})
241 {
242 ModeLabels labels;
243 auto ortho = OrthoQuad(nm0, nm1, labels);
244 CheckKernels(ortho, {nm0, nm1}, labels);
245
246 // Exponential kernel, acting on the total degree p + q.
247 const NekDouble svvDiffCoeff = 0.5, cutoffRatio = 0.5;
248 StdRegions::ConstFactorMap factors;
249 factors[StdRegions::eFactorSVVCutoffRatio] = cutoffRatio;
250 factors[StdRegions::eFactorSVVDiffCoeff] = svvDiffCoeff;
251
252 const int nmodes = std::min(nm0, nm1);
253 const int cutoff = static_cast<int>(cutoffRatio * nmodes);
254 std::vector<NekDouble> weight(labels.size());
255 for (size_t n = 0; n < labels.size(); ++n)
256 {
257 const int deg = labels[n][0] + labels[n][1];
258 weight[n] =
259 deg >= cutoff
260 ? svvDiffCoeff *
261 std::exp(-(deg - nmodes) * (deg - nmodes) /
262 static_cast<NekDouble>((deg - cutoff + 1) *
263 (deg - cutoff + 1)))
264 : 0.0;
265 }
266 CheckSVVLaplacianFilter(ortho, factors, weight);
267 }
268}
StdRegions::StdExpansionSharedPtr OrthoQuad(const int nm0, const int nm1, ModeLabels &labels)
Orthogonal quadrilateral; modes stored with p fastest.

References CheckKernels(), CheckSVVLaplacianFilter(), Nektar::StdRegions::eFactorSVVCutoffRatio, Nektar::StdRegions::eFactorSVVDiffCoeff, and OrthoQuad().

◆ BOOST_AUTO_TEST_CASE() [13/19]

Nektar::StdRegionsUnitTests::BOOST_AUTO_TEST_CASE ( TestSegReduceOrderCoeffs  )

Definition at line 95 of file StdRegions/TestReduceOrderCoeffs.cpp.

96{
97 using namespace LibUtilities;
98 const int nm = 5;
99 const PointsKey pkey(nm + 1, eGaussLobattoLegendre);
100 const BasisKey bkey(eModified_A, nm, pkey);
101 const BasisKey okey(eOrtho_A, nm, pkey);
102
105
106 std::vector<int> degree(nm);
107 for (int p = 0; p < nm; ++p)
108 {
109 degree[p] = p;
110 }
111 CheckReduceOrderCoeffs(exp, ortho, degree, nm - 1);
112 CheckReduceOrderCoeffs(exp, ortho, degree, nm - 2);
113}

References Nektar::MemoryManager< DataType >::AllocateSharedPtr(), CheckReduceOrderCoeffs(), Nektar::LibUtilities::eGaussLobattoLegendre, Nektar::LibUtilities::eModified_A, and Nektar::LibUtilities::eOrtho_A.

◆ BOOST_AUTO_TEST_CASE() [14/19]

Nektar::StdRegionsUnitTests::BOOST_AUTO_TEST_CASE ( TestSegSVVLaplacianFilter  )

Definition at line 210 of file TestSVVLaplacianFilter.cpp.

211{
212 const int nm = 6;
213 const BasisKey b0(eOrtho_A, nm, PointsKey(nm + 1, eGaussLobattoLegendre));
215
216 // Exponential kernel, adding no diffusion to the modes below the cutoff.
217 const NekDouble svvDiffCoeff = 0.5, cutoffRatio = 0.5;
219 factors[StdRegions::eFactorSVVCutoffRatio] = cutoffRatio;
220 factors[StdRegions::eFactorSVVDiffCoeff] = svvDiffCoeff;
221
222 const int cutoff = static_cast<int>(cutoffRatio * nm);
223 std::vector<NekDouble> weight(nm);
224 for (int p = 0; p < nm; ++p)
225 {
226 weight[p] = p >= cutoff
227 ? svvDiffCoeff *
228 std::exp(-(p - nm) * (p - nm) /
229 static_cast<NekDouble>((p - cutoff + 1) *
230 (p - cutoff + 1)))
231 : 0.0;
232 }
233 CheckSVVLaplacianFilter(ortho, factors, weight);
234}
std::map< ConstFactorType, NekDouble > ConstFactorMap

References Nektar::MemoryManager< DataType >::AllocateSharedPtr(), CheckSVVLaplacianFilter(), Nektar::StdRegions::eFactorSVVCutoffRatio, Nektar::StdRegions::eFactorSVVDiffCoeff, Nektar::LibUtilities::eGaussLobattoLegendre, and Nektar::LibUtilities::eOrtho_A.

◆ BOOST_AUTO_TEST_CASE() [15/19]

Nektar::StdRegionsUnitTests::BOOST_AUTO_TEST_CASE ( TestTetExactMassRules  )

Definition at line 84 of file TestTetExactMass.cpp.

85{
86 // Reference: the default collapsed rules on twice the points, exact
87 // well beyond the degree 2P = 6 the P3 mass matrix needs.
88 const auto ref = MakeTet(8, eGaussLobattoLegendre, eGaussRadauMAlpha1Beta0,
89 eGaussRadauMAlpha2Beta0);
90
91 // Rule D: Gauss-Legendre in the first two directions, Gauss-Jacobi(1,0)
92 // in the third.
93 const auto ruleD = MakeTet(4, eGaussGaussLegendre, eGaussGaussLegendre,
94 eGaussGaussAlpha1Beta0);
95 BOOST_CHECK_SMALL(MassDifference(ruleD, ref), 1.0e-13);
96
97 // Rule C: Gauss-Jacobi(1,0) in the second and third directions.
98 const auto ruleC = MakeTet(4, eGaussGaussLegendre, eGaussGaussAlpha1Beta0,
99 eGaussGaussAlpha1Beta0);
100 BOOST_CHECK_SMALL(MassDifference(ruleC, ref), 1.0e-13);
101
102 // Gauss-Legendre in every direction is exact to degree 5 only, so the
103 // top modes' mass is wrong: the reason for the rules above.
104 const auto gl = MakeTet(4, eGaussGaussLegendre, eGaussGaussLegendre,
105 eGaussGaussLegendre);
106 BOOST_CHECK(MassDifference(gl, ref) > 1.0e-3);
107}
static StdRegions::StdTetExpSharedPtr MakeTet(const unsigned int np, const PointsType p0, const PointsType p1, const PointsType p2)
The P3 orthogonal tet on np points per direction of the given types.
static NekDouble MassDifference(const StdRegions::StdTetExpSharedPtr &a, const StdRegions::StdTetExpSharedPtr &b)
The largest entry of the difference between the mass matrices of a and b.

References Nektar::LibUtilities::eGaussGaussAlpha1Beta0, Nektar::LibUtilities::eGaussGaussLegendre, Nektar::LibUtilities::eGaussLobattoLegendre, MakeTet(), and MassDifference().

◆ BOOST_AUTO_TEST_CASE() [16/19]

Nektar::StdRegionsUnitTests::BOOST_AUTO_TEST_CASE ( TestTetReduceOrderCoeffs  )

Definition at line 211 of file StdRegions/TestReduceOrderCoeffs.cpp.

212{
213 CheckTet(4, 3);
214 CheckTet(5, 3);
215}
void CheckTet(const int nm, const int numMin)

References CheckTet().

◆ BOOST_AUTO_TEST_CASE() [17/19]

Nektar::StdRegionsUnitTests::BOOST_AUTO_TEST_CASE ( TestTetSVVLaplacianFilter  )

Definition at line 331 of file TestSVVLaplacianFilter.cpp.

332{
333 for (auto [nm0, nm1, nm2] : {std::array{4, 4, 4}, std::array{6, 6, 6}})
334 {
335 const BasisKey b0(eOrtho_A, nm0,
336 PointsKey(nm0 + 1, eGaussLobattoLegendre));
337 const BasisKey b1(eOrtho_B, nm1,
338 PointsKey(nm1, eGaussRadauMAlpha1Beta0));
339 const BasisKey b2(eOrtho_C, nm2,
340 PointsKey(nm2, eGaussRadauMAlpha2Beta0));
341 auto ortho =
342 MemoryManager<StdRegions::StdTetExp>::AllocateSharedPtr(b0, b1, b2);
343
344 // Modes are stored with p outermost, then q < nm1 - p, then
345 // r < nm2 - p - q.
346 ModeLabels labels;
347 for (int p = 0; p < nm0; ++p)
348 {
349 for (int q = 0; q < nm1 - p; ++q)
350 {
351 for (int r = 0; r < nm2 - p - q; ++r)
352 {
353 labels.push_back({p, q, r});
354 }
355 }
356 }
357 CheckKernels(ortho, {nm0, nm1, nm2}, labels);
358 }
359}

References Nektar::MemoryManager< DataType >::AllocateSharedPtr(), CheckKernels(), Nektar::LibUtilities::eGaussLobattoLegendre, Nektar::LibUtilities::eOrtho_A, Nektar::LibUtilities::eOrtho_B, and Nektar::LibUtilities::eOrtho_C.

◆ BOOST_AUTO_TEST_CASE() [18/19]

Nektar::StdRegionsUnitTests::BOOST_AUTO_TEST_CASE ( TestTriReduceOrderCoeffs  )

Definition at line 172 of file StdRegions/TestReduceOrderCoeffs.cpp.

173{
174 CheckTri(4, 3);
175 // More than one order removed.
176 CheckTri(5, 3);
177}
void CheckTri(const int nm, const int numMin)

References CheckTri().

◆ BOOST_AUTO_TEST_CASE() [19/19]

Nektar::StdRegionsUnitTests::BOOST_AUTO_TEST_CASE ( TestTriSVVLaplacianFilter  )

Definition at line 311 of file TestSVVLaplacianFilter.cpp.

312{
313 const int nm = 5;
314 const BasisKey b0(eOrtho_A, nm, PointsKey(nm + 1, eGaussLobattoLegendre));
315 const BasisKey b1(eOrtho_B, nm, PointsKey(nm, eGaussRadauMAlpha1Beta0));
316 auto ortho =
318
319 // Modes are stored with p outermost and q < nm - p.
320 ModeLabels labels;
321 for (int p = 0; p < nm; ++p)
322 {
323 for (int q = 0; q < nm - p; ++q)
324 {
325 labels.push_back({p, q, 0});
326 }
327 }
328 CheckKernels(ortho, {nm, nm}, labels);
329}

References Nektar::MemoryManager< DataType >::AllocateSharedPtr(), CheckKernels(), Nektar::LibUtilities::eGaussLobattoLegendre, Nektar::LibUtilities::eOrtho_A, and Nektar::LibUtilities::eOrtho_B.

◆ CheckInvBwdTrans()

void Nektar::StdRegionsUnitTests::CheckInvBwdTrans ( const StdRegions::StdExpansionSharedPtr &  exp)

Definition at line 44 of file TestInvBwdTrans.cpp.

45{
46 const StdRegions::StdMatrixKey bwdKey(StdRegions::eBwdTrans,
47 exp->DetShapeType(), *exp);
48 const StdRegions::StdMatrixKey invKey(StdRegions::eInvBwdTrans,
49 exp->DetShapeType(), *exp);
50 const StdRegions::StdMatrixKey invIProdKey(StdRegions::eInvIProductWRTBase,
51 exp->DetShapeType(), *exp);
52
53 DNekMatSharedPtr bwd = exp->GetStdMatrix(bwdKey);
54 DNekMatSharedPtr invBwd = exp->GetStdMatrix(invKey);
55 DNekMatSharedPtr invIProd = exp->GetStdMatrix(invIProdKey);
56
57 BOOST_REQUIRE_EQUAL(bwd->GetRows(), exp->GetTotPoints());
58 BOOST_REQUIRE_EQUAL(bwd->GetColumns(), exp->GetNcoeffs());
59 BOOST_REQUIRE_EQUAL(invBwd->GetRows(), exp->GetNcoeffs());
60 BOOST_REQUIRE_EQUAL(invBwd->GetColumns(), exp->GetTotPoints());
61 BOOST_REQUIRE_EQUAL(invIProd->GetRows(), exp->GetTotPoints());
62 BOOST_REQUIRE_EQUAL(invIProd->GetColumns(), exp->GetNcoeffs());
63
64 const NekDouble epsilon = 1.0e-8;
65 DNekMat identity = (*invBwd) * (*bwd);
66
67 for (unsigned int i = 0; i < identity.GetRows(); ++i)
68 {
69 for (unsigned int j = 0; j < identity.GetColumns(); ++j)
70 {
71 const NekDouble expected = i == j ? 1.0 : 0.0;
72 BOOST_CHECK_SMALL(std::abs(*identity(i, j) - expected), epsilon);
73 }
74 }
75
76 for (unsigned int i = 0; i < invBwd->GetRows(); ++i)
77 {
78 for (unsigned int j = 0; j < invBwd->GetColumns(); ++j)
79 {
80 BOOST_CHECK_SMALL(std::abs(*(*invIProd)(j, i) - *(*invBwd)(i, j)),
81 epsilon);
82 }
83 }
84}
std::shared_ptr< DNekMat > DNekMatSharedPtr

References Nektar::StdRegions::eBwdTrans, Nektar::StdRegions::eInvBwdTrans, and Nektar::StdRegions::eInvIProductWRTBase.

Referenced by BOOST_AUTO_TEST_CASE(), and BOOST_AUTO_TEST_CASE().

◆ CheckKernels()

void Nektar::StdRegionsUnitTests::CheckKernels ( const StdRegions::StdExpansionSharedPtr &  ortho,
const std::vector< int > &  nmodes,
const ModeLabels &  labels 
)

Check the DG and power kernels of SVVLaplacianFilter.

The weight of a mode depends only on its indices (p, q, r) and the mode counts, so a mode filtered under the wrong indices, or not at all, shows as a coefficient scaled by the wrong weight.

Definition at line 139 of file TestSVVLaplacianFilter.cpp.

141{
142 BOOST_REQUIRE_EQUAL(static_cast<int>(labels.size()), ortho->GetNcoeffs());
143
144 const NekDouble svvDiffCoeff = 0.5, kerDiffCoeff = 3.0, cutoff = 0.7;
145 std::vector<NekDouble> weight(labels.size());
146
148 dgFactors[StdRegions::eFactorSVVCutoffRatio] = cutoff;
149 dgFactors[StdRegions::eFactorSVVDiffCoeff] = svvDiffCoeff;
150 dgFactors[StdRegions::eFactorSVVDGKerDiffCoeff] = kerDiffCoeff;
151 for (size_t n = 0; n < labels.size(); ++n)
152 {
153 weight[n] =
154 DGKernelWeight(nmodes, labels[n], svvDiffCoeff * kerDiffCoeff);
155 }
156 CheckSVVLaplacianFilter(ortho, dgFactors, weight);
157
158 StdRegions::ConstFactorMap powerFactors;
159 powerFactors[StdRegions::eFactorSVVCutoffRatio] = cutoff;
160 powerFactors[StdRegions::eFactorSVVDiffCoeff] = svvDiffCoeff;
161 powerFactors[StdRegions::eFactorSVVPowerKerDiffCoeff] = kerDiffCoeff;
162 for (size_t n = 0; n < labels.size(); ++n)
163 {
164 weight[n] = PowerKernelWeight(nmodes, labels[n], cutoff,
165 svvDiffCoeff * kerDiffCoeff);
166 }
167 CheckSVVLaplacianFilter(ortho, powerFactors, weight);
168}
NekDouble DGKernelWeight(const std::vector< int > &nmodes, const std::array< int, 3 > &label, const NekDouble diffCoeff)
DG kernel weight of the mode label of an expansion with nmodes.

References CheckSVVLaplacianFilter(), DGKernelWeight(), Nektar::StdRegions::eFactorSVVCutoffRatio, Nektar::StdRegions::eFactorSVVDGKerDiffCoeff, Nektar::StdRegions::eFactorSVVDiffCoeff, Nektar::StdRegions::eFactorSVVPowerKerDiffCoeff, and PowerKernelWeight().

Referenced by BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), and BOOST_AUTO_TEST_CASE().

◆ CheckQuad()

void Nektar::StdRegionsUnitTests::CheckQuad ( const int  nm0,
const int  nm1,
const int  numMin 
)

Definition at line 115 of file StdRegions/TestReduceOrderCoeffs.cpp.

116{
117 using namespace LibUtilities;
118 const PointsKey pkey0(nm0 + 1, eGaussLobattoLegendre);
119 const PointsKey pkey1(nm1 + 1, eGaussLobattoLegendre);
120 const BasisKey b0(eModified_A, nm0, pkey0), b1(eModified_A, nm1, pkey1);
121 const BasisKey o0(eOrtho_A, nm0, pkey0), o1(eOrtho_A, nm1, pkey1);
122
124 auto ortho =
126
127 // Mode (p, q) is stored with p fastest; its degree is the larger index.
128 std::vector<int> degree(nm0 * nm1);
129 for (int q = 0; q < nm1; ++q)
130 {
131 for (int p = 0; p < nm0; ++p)
132 {
133 degree[q * nm0 + p] = std::max(p, q);
134 }
135 }
136 CheckReduceOrderCoeffs(exp, ortho, degree, numMin);
137}

References Nektar::MemoryManager< DataType >::AllocateSharedPtr(), CheckReduceOrderCoeffs(), Nektar::LibUtilities::eGaussLobattoLegendre, Nektar::LibUtilities::eModified_A, and Nektar::LibUtilities::eOrtho_A.

Referenced by BOOST_AUTO_TEST_CASE().

◆ CheckReduceOrderCoeffs()

void Nektar::StdRegionsUnitTests::CheckReduceOrderCoeffs ( const StdRegions::StdExpansionSharedPtr &  exp,
const StdRegions::StdExpansionSharedPtr &  ortho,
const std::vector< int > &  degree,
const int  numMin 
)

Check ReduceOrderCoeffs mode by mode.

Each mode of the orthogonal expansion ortho, of the same shape, order and points as exp, is expressed in exp's basis and reduced to numMin. A mode whose degree, in the sense the shape truncates, is below numMin must come back unchanged; every other mode must vanish.

Definition at line 57 of file StdRegions/TestReduceOrderCoeffs.cpp.

60{
61 const int nm = exp->GetNcoeffs();
62 const int nq = exp->GetTotPoints();
63
64 BOOST_REQUIRE_EQUAL(ortho->GetNcoeffs(), nm);
65 BOOST_REQUIRE_EQUAL(ortho->GetTotPoints(), nq);
66 BOOST_REQUIRE_EQUAL(static_cast<int>(degree.size()), nm);
67
68 const NekDouble tol = 1.0e-8;
69
70 for (int mode = 0; mode < nm; ++mode)
71 {
72 Array<OneD, NekDouble> orthoCoeffs(nm, 0.0);
73 orthoCoeffs[mode] = 1.0;
74
75 Array<OneD, NekDouble> phys(nq), coeffs(nm), reduced(nm), back(nq);
76 ortho->BwdTrans(orthoCoeffs, phys);
77 exp->FwdTrans(phys, coeffs);
78 exp->ReduceOrderCoeffs(numMin, coeffs, reduced);
79 exp->BwdTrans(reduced, back);
80
81 const bool kept = degree[mode] < numMin;
82 NekDouble diff = 0.0;
83 for (int q = 0; q < nq; ++q)
84 {
85 const NekDouble expected = kept ? phys[q] : 0.0;
86 diff = std::max(diff, std::abs(back[q] - expected));
87 }
88 BOOST_CHECK_MESSAGE(diff < tol,
89 "mode " << mode << " of degree " << degree[mode]
90 << (kept ? " changed by " : " left ")
91 << diff << " with numMin " << numMin);
92 }
93}

Referenced by BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), CheckQuad(), CheckTet(), and CheckTri().

◆ CheckSVVLaplacianFilter()

void Nektar::StdRegionsUnitTests::CheckSVVLaplacianFilter ( const StdRegions::StdExpansionSharedPtr &  ortho,
const StdRegions::ConstFactorMap &  factors,
const std::vector< NekDouble > &  weight 
)

Check SVVLaplacianFilter mode by mode.

Each mode of the orthogonal expansion ortho is transformed to physical space and filtered with factors. The filter acts diagonally on the orthogonal coefficients, so the result must be the same mode scaled by weight, and every other coefficient must vanish.

Definition at line 65 of file TestSVVLaplacianFilter.cpp.

68{
69 const int nm = ortho->GetNcoeffs();
70 const int nq = ortho->GetTotPoints();
71
72 BOOST_REQUIRE_EQUAL(static_cast<int>(weight.size()), nm);
73
74 const StdRegions::StdMatrixKey mkey(StdRegions::eLaplacian,
75 ortho->DetShapeType(), *ortho, factors);
76 const NekDouble tol = 1.0e-10;
77
78 for (int mode = 0; mode < nm; ++mode)
79 {
80 Array<OneD, NekDouble> orthoCoeffs(nm, 0.0);
81 orthoCoeffs[mode] = 1.0;
82
83 Array<OneD, NekDouble> phys(nq), filtered(nm);
84 ortho->BwdTrans(orthoCoeffs, phys);
85 ortho->SVVLaplacianFilter(phys, mkey);
86 ortho->FwdTrans(phys, filtered);
87
88 NekDouble diff = 0.0;
89 for (int n = 0; n < nm; ++n)
90 {
91 const NekDouble expected = n == mode ? weight[mode] : 0.0;
92 diff = std::max(diff, std::abs(filtered[n] - expected));
93 }
94 BOOST_CHECK_MESSAGE(diff < tol, "mode " << mode << " of weight "
95 << weight[mode] << " off by "
96 << diff);
97 }
98}

References Nektar::StdRegions::eLaplacian.

Referenced by BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), and CheckKernels().

◆ CheckTet()

void Nektar::StdRegionsUnitTests::CheckTet ( const int  nm,
const int  numMin 
)

Definition at line 179 of file StdRegions/TestReduceOrderCoeffs.cpp.

180{
181 using namespace LibUtilities;
182 const PointsKey pkey0(nm + 1, eGaussLobattoLegendre);
183 const PointsKey pkey1(nm, eGaussRadauMAlpha1Beta0);
184 const PointsKey pkey2(nm, eGaussRadauMAlpha2Beta0);
185 const BasisKey b0(eModified_A, nm, pkey0), b1(eModified_B, nm, pkey1),
186 b2(eModified_C, nm, pkey2);
187 const BasisKey o0(eOrtho_A, nm, pkey0), o1(eOrtho_B, nm, pkey1),
188 o2(eOrtho_C, nm, pkey2);
189
190 auto exp =
192 auto ortho =
194
195 // Modes are stored with p outermost, then q < nm - p, then r < nm - p - q;
196 // the degree is p + q + r.
197 std::vector<int> degree;
198 for (int p = 0; p < nm; ++p)
199 {
200 for (int q = 0; q < nm - p; ++q)
201 {
202 for (int r = 0; r < nm - p - q; ++r)
203 {
204 degree.push_back(p + q + r);
205 }
206 }
207 }
208 CheckReduceOrderCoeffs(exp, ortho, degree, numMin);
209}

References Nektar::MemoryManager< DataType >::AllocateSharedPtr(), CheckReduceOrderCoeffs(), Nektar::LibUtilities::eGaussLobattoLegendre, Nektar::LibUtilities::eModified_A, Nektar::LibUtilities::eModified_B, Nektar::LibUtilities::eModified_C, Nektar::LibUtilities::eOrtho_A, Nektar::LibUtilities::eOrtho_B, and Nektar::LibUtilities::eOrtho_C.

Referenced by BOOST_AUTO_TEST_CASE().

◆ CheckTri()

void Nektar::StdRegionsUnitTests::CheckTri ( const int  nm,
const int  numMin 
)

Definition at line 148 of file StdRegions/TestReduceOrderCoeffs.cpp.

149{
150 using namespace LibUtilities;
151 const PointsKey pkey0(nm + 1, eGaussLobattoLegendre);
152 const PointsKey pkey1(nm, eGaussRadauMAlpha1Beta0);
153 const BasisKey b0(eModified_A, nm, pkey0), b1(eModified_B, nm, pkey1);
154 const BasisKey o0(eOrtho_A, nm, pkey0), o1(eOrtho_B, nm, pkey1);
155
157 auto ortho =
159
160 // Modes are stored with p outermost and q < nm - p; the degree is p + q.
161 std::vector<int> degree;
162 for (int p = 0; p < nm; ++p)
163 {
164 for (int q = 0; q < nm - p; ++q)
165 {
166 degree.push_back(p + q);
167 }
168 }
169 CheckReduceOrderCoeffs(exp, ortho, degree, numMin);
170}

References Nektar::MemoryManager< DataType >::AllocateSharedPtr(), CheckReduceOrderCoeffs(), Nektar::LibUtilities::eGaussLobattoLegendre, Nektar::LibUtilities::eModified_A, Nektar::LibUtilities::eModified_B, Nektar::LibUtilities::eOrtho_A, and Nektar::LibUtilities::eOrtho_B.

Referenced by BOOST_AUTO_TEST_CASE().

◆ DGKernelWeight()

NekDouble Nektar::StdRegionsUnitTests::DGKernelWeight ( const std::vector< int > &  nmodes,
const std::array< int, 3 > &  label,
const NekDouble  diffCoeff 
)

DG kernel weight of the mode label of an expansion with nmodes.

Definition at line 101 of file TestSVVLaplacianFilter.cpp.

104{
105 int maxModes = 0, maxLabel = 0;
106 for (size_t d = 0; d < nmodes.size(); ++d)
107 {
108 maxModes = std::max(maxModes, nmodes[d]);
109 maxLabel = std::max(maxLabel, label[d]);
110 }
111 const int row = std::clamp(maxModes - StdRegions::kSVVDGFiltermodesmin, 0,
112 StdRegions::kSVVDGFiltermodesmax -
113 StdRegions::kSVVDGFiltermodesmin);
114 const int col = std::min(maxLabel, StdRegions::kSVVDGFiltermodesmax - 1);
115 return diffCoeff * StdRegions::kSVVDGFilter[row][col];
116}

References Nektar::StdRegions::kSVVDGFilter, Nektar::StdRegions::kSVVDGFiltermodesmax, and Nektar::StdRegions::kSVVDGFiltermodesmin.

Referenced by CheckKernels().

◆ MakeOrthoPyr()

static StdRegions::StdPyrExpSharedPtr Nektar::StdRegionsUnitTests::MakeOrthoPyr ( const unsigned int  P,
const unsigned int  np 
)
static

The orthogonal pyramid of order P on np points per direction of the default orthogonal rule: Gauss-Legendre, Gauss-Legendre and Gauss-Jacobi(1,0) in the collapsed direction.

Definition at line 52 of file TestPyrExactMass.cpp.

54{
55 const BasisKey b0(eOrtho_A, P + 1, PointsKey(np, eGaussGaussLegendre));
56 const BasisKey b2(eOrthoPyr_C, P + 1,
57 PointsKey(np, eGaussGaussAlpha1Beta0));
59}

References Nektar::MemoryManager< DataType >::AllocateSharedPtr(), Nektar::LibUtilities::eGaussGaussAlpha1Beta0, Nektar::LibUtilities::eGaussGaussLegendre, Nektar::LibUtilities::eOrtho_A, Nektar::LibUtilities::eOrthoPyr_C, and Nektar::LibUtilities::P.

Referenced by BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), and BOOST_AUTO_TEST_CASE().

◆ MakeTet()

static StdRegions::StdTetExpSharedPtr Nektar::StdRegionsUnitTests::MakeTet ( const unsigned int  np,
const PointsType  p0,
const PointsType  p1,
const PointsType  p2 
)
static

The P3 orthogonal tet on np points per direction of the given types.

Definition at line 48 of file TestTetExactMass.cpp.

52{
53 const unsigned int nm = 4;
54 const BasisKey b0(eOrtho_A, nm, PointsKey(np, p0));
55 const BasisKey b1(eOrtho_B, nm, PointsKey(np, p1));
56 const BasisKey b2(eOrtho_C, nm, PointsKey(np, p2));
58}

References Nektar::MemoryManager< DataType >::AllocateSharedPtr(), Nektar::LibUtilities::eOrtho_A, Nektar::LibUtilities::eOrtho_B, and Nektar::LibUtilities::eOrtho_C.

Referenced by BOOST_AUTO_TEST_CASE().

◆ Mass()

static DNekMatSharedPtr Nektar::StdRegionsUnitTests::Mass ( const StdRegions::StdPyrExpSharedPtr &  e)
static

Definition at line 103 of file TestPyrExactMass.cpp.

104{
105 return e->GetStdMatrix(
106 StdRegions::StdMatrixKey(StdRegions::eMass, ePyramid, *e));
107}

References Nektar::StdRegions::eMass, and Nektar::LibUtilities::ePyramid.

Referenced by BOOST_AUTO_TEST_CASE().

◆ MassDifference()

static NekDouble Nektar::StdRegionsUnitTests::MassDifference ( const StdRegions::StdTetExpSharedPtr &  a,
const StdRegions::StdTetExpSharedPtr &  b 
)
static

The largest entry of the difference between the mass matrices of a and b.

Definition at line 62 of file TestTetExactMass.cpp.

64{
65 const DNekMatSharedPtr ma = a->GetStdMatrix(
66 StdRegions::StdMatrixKey(StdRegions::eMass, eTetrahedron, *a));
67 const DNekMatSharedPtr mb = b->GetStdMatrix(
68 StdRegions::StdMatrixKey(StdRegions::eMass, eTetrahedron, *b));
69 BOOST_REQUIRE_EQUAL(ma->GetRows(), mb->GetRows());
70 BOOST_REQUIRE_EQUAL(ma->GetColumns(), mb->GetColumns());
71
72 NekDouble diff = 0.0;
73 for (unsigned int i = 0; i < ma->GetRows(); ++i)
74 {
75 for (unsigned int j = 0; j < ma->GetColumns(); ++j)
76 {
77 diff = std::max(diff,
78 std::abs(ma->GetValue(i, j) - mb->GetValue(i, j)));
79 }
80 }
81 return diff;
82}

References Nektar::StdRegions::eMass, and Nektar::LibUtilities::eTetrahedron.

Referenced by BOOST_AUTO_TEST_CASE().

◆ OrthoHex()

StdRegions::StdExpansionSharedPtr Nektar::StdRegionsUnitTests::OrthoHex ( const int  nm0,
const int  nm1,
const int  nm2,
ModeLabels &  labels 
)

Orthogonal hexahedron; modes stored with p fastest, then q, then r.

Definition at line 189 of file TestSVVLaplacianFilter.cpp.

191{
192 const BasisKey b0(eOrtho_A, nm0, PointsKey(nm0 + 1, eGaussLobattoLegendre));
193 const BasisKey b1(eOrtho_A, nm1, PointsKey(nm1 + 1, eGaussLobattoLegendre));
194 const BasisKey b2(eOrtho_A, nm2, PointsKey(nm2 + 1, eGaussLobattoLegendre));
195
196 labels.clear();
197 for (int r = 0; r < nm2; ++r)
198 {
199 for (int q = 0; q < nm1; ++q)
200 {
201 for (int p = 0; p < nm0; ++p)
202 {
203 labels.push_back({p, q, r});
204 }
205 }
206 }
207 return MemoryManager<StdRegions::StdHexExp>::AllocateSharedPtr(b0, b1, b2);
208}

References Nektar::MemoryManager< DataType >::AllocateSharedPtr(), Nektar::LibUtilities::eGaussLobattoLegendre, and Nektar::LibUtilities::eOrtho_A.

Referenced by BOOST_AUTO_TEST_CASE().

◆ OrthoQuad()

StdRegions::StdExpansionSharedPtr Nektar::StdRegionsUnitTests::OrthoQuad ( const int  nm0,
const int  nm1,
ModeLabels &  labels 
)

Orthogonal quadrilateral; modes stored with p fastest.

Definition at line 171 of file TestSVVLaplacianFilter.cpp.

173{
174 const BasisKey b0(eOrtho_A, nm0, PointsKey(nm0 + 1, eGaussLobattoLegendre));
175 const BasisKey b1(eOrtho_A, nm1, PointsKey(nm1 + 1, eGaussLobattoLegendre));
176
177 labels.clear();
178 for (int q = 0; q < nm1; ++q)
179 {
180 for (int p = 0; p < nm0; ++p)
181 {
182 labels.push_back({p, q, 0});
183 }
184 }
185 return MemoryManager<StdRegions::StdQuadExp>::AllocateSharedPtr(b0, b1);
186}

References Nektar::MemoryManager< DataType >::AllocateSharedPtr(), Nektar::LibUtilities::eGaussLobattoLegendre, and Nektar::LibUtilities::eOrtho_A.

Referenced by BOOST_AUTO_TEST_CASE().

◆ PowerKernelWeight()

NekDouble Nektar::StdRegionsUnitTests::PowerKernelWeight ( const std::vector< int > &  nmodes,
const std::array< int, 3 > &  label,
const NekDouble  cutoff,
const NekDouble  diffCoeff 
)

Power kernel weight of the mode label of an expansion with nmodes.

Definition at line 119 of file TestSVVLaplacianFilter.cpp.

122{
123 NekDouble fac = 0.0;
124 for (size_t d = 0; d < nmodes.size(); ++d)
125 {
126 fac = std::max(fac, std::pow((1.0 * label[d]) / (nmodes[d] - 1),
127 cutoff * nmodes[d]));
128 }
129 return diffCoeff * fac;
130}

Referenced by CheckKernels().

◆ Solve()

static std::vector< NekDouble > Nektar::StdRegionsUnitTests::Solve ( std::vector< NekDouble >  A,
std::vector< NekDouble >  b,
const unsigned int  n 
)
static

Solve the dense system A x = b in place by Gaussian elimination with partial pivoting; A is row major, n by n.

Definition at line 63 of file TestPyrExactMass.cpp.

66{
67 for (unsigned int k = 0; k < n; ++k)
68 {
69 unsigned int piv = k;
70 for (unsigned int i = k + 1; i < n; ++i)
71 {
72 if (std::abs(A[i * n + k]) > std::abs(A[piv * n + k]))
73 {
74 piv = i;
75 }
76 }
77 for (unsigned int j = 0; j < n; ++j)
78 {
79 std::swap(A[k * n + j], A[piv * n + j]);
80 }
81 std::swap(b[k], b[piv]);
82 for (unsigned int i = k + 1; i < n; ++i)
83 {
84 const NekDouble f = A[i * n + k] / A[k * n + k];
85 for (unsigned int j = k; j < n; ++j)
86 {
87 A[i * n + j] -= f * A[k * n + j];
88 }
89 b[i] -= f * b[k];
90 }
91 }
92 for (unsigned int k = n; k-- > 0;)
93 {
94 for (unsigned int j = k + 1; j < n; ++j)
95 {
96 b[k] -= A[k * n + j] * b[j];
97 }
98 b[k] /= A[k * n + k];
99 }
100 return b;
101}

Referenced by BOOST_AUTO_TEST_CASE().