Nektar++
Loading...
Searching...
No Matches
Classes | Functions
Nektar::AlignedTraceNormalTests Namespace Reference

Classes

struct  CurvedHex
 Storage for a hexahedron with curved faces; entities must outlive it. More...
 
struct  CurvedTet
 

Functions

static CurvedTet MakeCurvedTet (const int flip=0)
 Build a tetrahedron with a curved face 0. Setting bit i of flip traverses face i (1-3) the other way round, keeping its first edge on face 0 as TetGeom requires, which changes the orientation the element sees.
 
 BOOST_AUTO_TEST_CASE (TestDeformedFaceNormalWithDifferentQuadrature)
 
static void CheckAlignedNormals (LocalRegions::Expansion &elmt, const int face, LocalRegions::Expansion &bnd, const std::array< NekDouble, 3 > &centre)
 Check that the normals of face, sampled on bnd, are unit vectors orthogonal to the boundary expansion's own tangents and point from centre towards the face. A normal assigned to the wrong point of a curved face fails the orthogonality check.
 
static std::array< NekDouble, 3 > Centre (LocalRegions::Expansion &elmt)
 
 BOOST_AUTO_TEST_CASE (TestAlignedTriFaceNormals)
 
static void MakeCurvedHex (CurvedHex &p, const int rot, const bool reverse)
 Build a hexahedron whose faces are numbered rot steps around (and optionally reversed), so that the element sees non-trivial and transposed face orientations, then curve every edge and face with an asymmetric perturbation of their high-order nodes.
 
 BOOST_AUTO_TEST_CASE (TestAlignedQuadFaceNormals)
 
 BOOST_AUTO_TEST_CASE (TestDeformedQuadEdgeNormals)
 The edge normals of a straight-sided quadrilateral that is not a parallelogram, and so deformed, are the constant outward normals of its sides, on Gauss points of every count, one point per direction included.
 

Function Documentation

◆ BOOST_AUTO_TEST_CASE() [1/4]

Nektar::AlignedTraceNormalTests::BOOST_AUTO_TEST_CASE ( TestAlignedQuadFaceNormals  )

Definition at line 432 of file TestAlignedTraceNormal.cpp.

433{
434 using namespace LibUtilities;
435 // Different point counts per direction, so that a transposed face sees
436 // its extents exchanged.
437 const BasisKey b0(eModified_A, 4, PointsKey(5, eGaussLobattoLegendre));
438 const BasisKey b1(eModified_A, 4, PointsKey(6, eGaussLobattoLegendre));
439 const BasisKey b2(eModified_A, 4, PointsKey(7, eGaussLobattoLegendre));
440
441 std::set<StdRegions::Orientation> orients;
442 for (const bool reverse : {false, true})
443 {
444 for (int rot = 0; rot < 4; ++rot)
445 {
446 CurvedHex geom;
447 MakeCurvedHex(geom, rot, reverse);
448 auto volume =
450 b0, b1, b2, geom.hex.get());
451 const std::array<NekDouble, 3> centre = Centre(*volume);
452
453 for (int f = 0; f < 6; ++f)
454 {
455 orients.insert(volume->GetTraceOrient(f));
457 volume->GetAlignedTraceExp(f);
458 BOOST_REQUIRE_EQUAL(bnd->GetGeomFactors()->GetGtype(),
459 SpatialDomains::eDeformed);
460 CheckAlignedNormals(*volume, f, *bnd, centre);
461
462 // NormVectorIProductWRTBase must use the same aligned normals.
463 LocalRegions::ExpansionSharedPtr adjacent = volume;
464 bnd->SetAdjacentElementExp(f, adjacent);
465 const int nq = bnd->GetTotPoints();
467 volume->GetAlignedTraceNormal(f, *bnd);
468 Array<OneD, NekDouble> fx(nq), fy(nq), fz(nq), flux(nq);
469 for (int i = 0; i < nq; ++i)
470 {
471 fx[i] = 0.3 + 0.02 * i;
472 fy[i] = -0.4 + 0.01 * i;
473 fz[i] = 0.8 - 0.03 * i;
474 flux[i] =
475 n[0][i] * fx[i] + n[1][i] * fy[i] + n[2][i] * fz[i];
476 }
477 Array<OneD, NekDouble> actual(bnd->GetNcoeffs());
478 Array<OneD, NekDouble> expected(bnd->GetNcoeffs());
479 bnd->NormVectorIProductWRTBase(fx, fy, fz, actual);
480 bnd->IProductWRTBase(flux, expected);
481 for (int i = 0; i < expected.size(); ++i)
482 {
483 BOOST_CHECK_SMALL(actual[i] - expected[i], 1.0e-12);
484 }
485 }
486 }
487 }
488
489 // Exercise both non-trivial and transposing orientations.
490 BOOST_CHECK_GT(orients.size(), 2);
491 BOOST_CHECK(orients.lower_bound(StdRegions::eDir1FwdDir2_Dir2FwdDir1) !=
492 orients.end());
493}
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< Expansion > ExpansionSharedPtr
Definition Expansion.h:66

References Nektar::MemoryManager< DataType >::AllocateSharedPtr(), Centre(), CheckAlignedNormals(), Nektar::SpatialDomains::eDeformed, Nektar::StdRegions::eDir1FwdDir2_Dir2FwdDir1, Nektar::LibUtilities::eGaussLobattoLegendre, Nektar::LibUtilities::eModified_A, Nektar::AlignedTraceNormalTests::CurvedHex::hex, and MakeCurvedHex().

◆ BOOST_AUTO_TEST_CASE() [2/4]

Nektar::AlignedTraceNormalTests::BOOST_AUTO_TEST_CASE ( TestAlignedTriFaceNormals  )

Definition at line 277 of file TestAlignedTraceNormal.cpp.

278{
279 using namespace LibUtilities;
280 const BasisKey b0(eModified_A, 5, PointsKey(7, eGaussLobattoLegendre));
281 const BasisKey b1(eModified_B, 5, PointsKey(6, eGaussRadauMAlpha1Beta0));
282 const BasisKey b2(eModified_C, 5, PointsKey(6, eGaussRadauMAlpha2Beta0));
283
284 std::set<StdRegions::Orientation> orients;
285 for (int flip = 0; flip < 16; flip += 2)
286 {
287 CurvedTet geom = MakeCurvedTet(flip);
289 b0, b1, b2, geom.tet.get());
290 const std::array<NekDouble, 3> centre = Centre(*volume);
291
292 for (int f = 0; f < 4; ++f)
293 {
294 orients.insert(volume->GetTraceOrient(f));
296 volume->GetAlignedTraceExp(f);
297 CheckAlignedNormals(*volume, f, *bnd, centre);
298 }
299 }
300
301 // The faces must not all share the element's frame, or the check above
302 // could not detect a missing reorientation.
303 BOOST_CHECK_GT(orients.size(), 1);
304}
static void CheckAlignedNormals(LocalRegions::Expansion &elmt, const int face, LocalRegions::Expansion &bnd, const std::array< NekDouble, 3 > &centre)
Check that the normals of face, sampled on bnd, are unit vectors orthogonal to the boundary expansion...
static CurvedTet MakeCurvedTet(const int flip=0)
Build a tetrahedron with a curved face 0. Setting bit i of flip traverses face i (1-3) the other way ...
static std::array< NekDouble, 3 > Centre(LocalRegions::Expansion &elmt)

References Nektar::MemoryManager< DataType >::AllocateSharedPtr(), Centre(), CheckAlignedNormals(), Nektar::LibUtilities::eGaussLobattoLegendre, Nektar::LibUtilities::eModified_A, Nektar::LibUtilities::eModified_B, Nektar::LibUtilities::eModified_C, MakeCurvedTet(), and Nektar::AlignedTraceNormalTests::CurvedTet::tet.

◆ BOOST_AUTO_TEST_CASE() [3/4]

Nektar::AlignedTraceNormalTests::BOOST_AUTO_TEST_CASE ( TestDeformedFaceNormalWithDifferentQuadrature  )

Definition at line 157 of file TestAlignedTraceNormal.cpp.

158{
159 CurvedTet geom = MakeCurvedTet();
160
161 using namespace LibUtilities;
162 const BasisKey high0(eModified_A, 5, PointsKey(7, eGaussLobattoLegendre));
163 const BasisKey high1(eModified_B, 5, PointsKey(6, eGaussRadauMAlpha1Beta0));
164 const BasisKey high2(eModified_C, 5, PointsKey(6, eGaussRadauMAlpha2Beta0));
166 high0, high1, high2, geom.tet.get());
167
168 const BasisKey low0(eModified_A, 3, PointsKey(4, eGaussLobattoLegendre));
169 const BasisKey low1(eModified_B, 3, PointsKey(3, eGaussRadauMAlpha1Beta0));
171 low0, low1, geom.faces[0].get());
172
173 LocalRegions::ExpansionSharedPtr adjacent = volume;
174 boundary->SetAdjacentElementExp(0, adjacent);
175
176 BOOST_REQUIRE_EQUAL(boundary->GetGeomFactors()->GetGtype(),
177 SpatialDomains::eDeformed);
178 BOOST_REQUIRE(volume->GetTraceBasisKey(0, 0) != low0 ||
179 volume->GetTraceBasisKey(0, 1) != low1);
180
181 const int nq = boundary->GetTotPoints();
182 Array<OneD, NekDouble> fx(nq), fy(nq), fz(nq);
183 for (int i = 0; i < nq; ++i)
184 {
185 fx[i] = 0.3 + 0.02 * i;
186 fy[i] = -0.4 + 0.01 * i;
187 fz[i] = 0.8 - 0.03 * i;
188 }
189
190 Array<OneD, NekDouble> actual(boundary->GetNcoeffs());
191 boundary->NormVectorIProductWRTBase(fx, fy, fz, actual);
192
193 const auto &normal = volume->GetTraceNormal(0);
194 Array<OneD, NekDouble> nx(nq), ny(nq), nz(nq);
195 Interp2D(volume->GetTraceBasisKey(0, 0), volume->GetTraceBasisKey(0, 1),
196 normal[0], low0, low1, nx);
197 Interp2D(volume->GetTraceBasisKey(0, 0), volume->GetTraceBasisKey(0, 1),
198 normal[1], low0, low1, ny);
199 Interp2D(volume->GetTraceBasisKey(0, 0), volume->GetTraceBasisKey(0, 1),
200 normal[2], low0, low1, nz);
201
202 Array<OneD, NekDouble> flux(nq);
203 for (int i = 0; i < nq; ++i)
204 {
205 flux[i] = nx[i] * fx[i] + ny[i] * fy[i] + nz[i] * fz[i];
206 }
207 Array<OneD, NekDouble> expected(boundary->GetNcoeffs());
208 boundary->IProductWRTBase(flux, expected);
209
210 for (int i = 0; i < expected.size(); ++i)
211 {
212 BOOST_CHECK_SMALL(actual[i] - expected[i], 1.0e-11);
213 }
214}
void Interp2D(const BasisKey &fbasis0, const BasisKey &fbasis1, const Array< OneD, const NekDouble > &from, const BasisKey &tbasis0, const BasisKey &tbasis1, Array< OneD, NekDouble > &to)
this function interpolates a 2D function evaluated at the quadrature points of the 2D basis,...
Definition Interp.cpp:101
std::array< SpatialDomains::TriGeomUniquePtr, 4 > faces

References Nektar::MemoryManager< DataType >::AllocateSharedPtr(), Nektar::SpatialDomains::eDeformed, Nektar::LibUtilities::eGaussLobattoLegendre, Nektar::LibUtilities::eModified_A, Nektar::LibUtilities::eModified_B, Nektar::LibUtilities::eModified_C, Nektar::AlignedTraceNormalTests::CurvedTet::faces, Nektar::LibUtilities::Interp2D(), MakeCurvedTet(), and Nektar::AlignedTraceNormalTests::CurvedTet::tet.

◆ BOOST_AUTO_TEST_CASE() [4/4]

Nektar::AlignedTraceNormalTests::BOOST_AUTO_TEST_CASE ( TestDeformedQuadEdgeNormals  )

The edge normals of a straight-sided quadrilateral that is not a parallelogram, and so deformed, are the constant outward normals of its sides, on Gauss points of every count, one point per direction included.

Definition at line 498 of file TestAlignedTraceNormal.cpp.

499{
500 using namespace LibUtilities;
501 const std::array<std::array<NekDouble, 2>, 4> x = {
502 {{{0.0, 0.0}}, {{2.0, 0.1}}, {{1.6, 1.0}}, {{0.3, 1.3}}}};
503
504 std::array<SpatialDomains::PointGeomUniquePtr, 4> verts;
505 for (int i = 0; i < 4; ++i)
506 {
507 verts[i] = SpatialDomains::PointGeomUniquePtr(
508 new SpatialDomains::PointGeom(2u, i, x[i][0], x[i][1], 0.0));
509 }
510 std::array<SpatialDomains::SegGeomUniquePtr, 4> edges;
511 std::array<SpatialDomains::SegGeom *, 4> edgePtrs;
512 for (int i = 0; i < 4; ++i)
513 {
514 std::array<SpatialDomains::PointGeom *, 2> ev = {
515 verts[i].get(), verts[(i + 1) % 4].get()};
516 edges[i] = SpatialDomains::SegGeomUniquePtr(
517 new SpatialDomains::SegGeom(i, 2, ev));
518 edgePtrs[i] = edges[i].get();
519 }
520 SpatialDomains::QuadGeomUniquePtr quad(
521 new SpatialDomains::QuadGeom(0, edgePtrs));
522
523 // Edge i runs from vertex i to vertex i + 1 anticlockwise, so its outward
524 // normal is its direction turned clockwise.
525 std::array<std::array<NekDouble, 2>, 4> exact;
526 for (int i = 0; i < 4; ++i)
527 {
528 const NekDouble dx = x[(i + 1) % 4][0] - x[i][0];
529 const NekDouble dy = x[(i + 1) % 4][1] - x[i][1];
530 const NekDouble len = std::sqrt(dx * dx + dy * dy);
531 exact[i] = {{dy / len, -dx / len}};
532 }
533
534 const std::array<std::array<int, 2>, 5> counts = {
535 {{{1, 1}}, {{2, 2}}, {{3, 3}}, {{1, 3}}, {{3, 1}}}};
536 for (const auto &n : counts)
537 {
538 const BasisKey b0(eOrtho_A, n[0], PointsKey(n[0], eGaussGaussLegendre));
539 const BasisKey b1(eOrtho_A, n[1], PointsKey(n[1], eGaussGaussLegendre));
540 auto exp = MemoryManager<LocalRegions::QuadExp>::AllocateSharedPtr(
541 b0, b1, quad.get());
542 BOOST_REQUIRE_EQUAL(exp->GetGeomFactors()->GetGtype(),
543 SpatialDomains::eDeformed);
544
545 for (int e = 0; e < 4; ++e)
546 {
547 const auto &normal = exp->GetTraceNormal(e);
548 for (size_t q = 0; q < normal[0].size(); ++q)
549 {
550 BOOST_CHECK_MESSAGE(
551 std::abs(normal[0][q] - exact[e][0]) < 1.0e-12 &&
552 std::abs(normal[1][q] - exact[e][1]) < 1.0e-12,
553 "points " << n[0] << " x " << n[1] << ", edge " << e
554 << ": normal (" << normal[0][q] << ", "
555 << normal[1][q] << ") against (" << exact[e][0]
556 << ", " << exact[e][1] << ")");
557 }
558 }
559 }
560}

References Nektar::MemoryManager< DataType >::AllocateSharedPtr(), Nektar::SpatialDomains::eDeformed, Nektar::LibUtilities::eGaussGaussLegendre, and Nektar::LibUtilities::eOrtho_A.

◆ Centre()

static std::array< NekDouble, 3 > Nektar::AlignedTraceNormalTests::Centre ( LocalRegions::Expansion &  elmt)
static

Definition at line 268 of file TestAlignedTraceNormal.cpp.

269{
270 const int nq = elmt.GetTotPoints();
271 Array<OneD, NekDouble> x(nq), y(nq), z(nq);
272 elmt.GetCoords(x, y, z);
273 return {Vmath::Vsum(nq, x, 1) / nq, Vmath::Vsum(nq, y, 1) / nq,
274 Vmath::Vsum(nq, z, 1) / nq};
275}
int GetTotPoints() const
This function returns the total number of quadrature points used in the element.
void GetCoords(Array< OneD, NekDouble > &coords_1, Array< OneD, NekDouble > &coords_2=NullNekDouble1DArray, Array< OneD, NekDouble > &coords_3=NullNekDouble1DArray)
this function returns the physical coordinates of the quadrature points of the expansion
T Vsum(int n, const T *x, const int incx)
Subtract return sum(x)
Definition Vmath.hpp:611

References Nektar::StdRegions::StdExpansion::GetCoords(), Nektar::StdRegions::StdExpansion::GetTotPoints(), and Vmath::Vsum().

Referenced by BOOST_AUTO_TEST_CASE(), and BOOST_AUTO_TEST_CASE().

◆ CheckAlignedNormals()

static void Nektar::AlignedTraceNormalTests::CheckAlignedNormals ( LocalRegions::Expansion &  elmt,
const int  face,
LocalRegions::Expansion &  bnd,
const std::array< NekDouble, 3 > &  centre 
)
static

Check that the normals of face, sampled on bnd, are unit vectors orthogonal to the boundary expansion's own tangents and point from centre towards the face. A normal assigned to the wrong point of a curved face fails the orthogonality check.

Definition at line 220 of file TestAlignedTraceNormal.cpp.

223{
224 const int nq = bnd.GetTotPoints();
225 const LocalRegions::NormalVector n = elmt.GetAlignedTraceNormal(face, bnd);
226 BOOST_REQUIRE_EQUAL(n.size(), 3);
227
228 std::array<Array<OneD, NekDouble>, 3> x, t0, t1;
229 for (int d = 0; d < 3; ++d)
230 {
231 BOOST_REQUIRE_EQUAL(n[d].size(), nq);
232 x[d] = Array<OneD, NekDouble>(nq);
233 t0[d] = Array<OneD, NekDouble>(nq);
234 t1[d] = Array<OneD, NekDouble>(nq);
235 }
236 bnd.GetCoords(x[0], x[1], x[2]);
237 for (int d = 0; d < 3; ++d)
238 {
239 bnd.StdPhysDeriv(x[d], t0[d], t1[d]);
240 }
241
242 std::array<NekDouble, 3> faceCentre;
243 for (int d = 0; d < 3; ++d)
244 {
245 faceCentre[d] = Vmath::Vsum(nq, x[d], 1) / nq;
246 }
247
248 for (int i = 0; i < nq; ++i)
249 {
250 NekDouble nn = 0.0, nt0 = 0.0, nt1 = 0.0, tt0 = 0.0, tt1 = 0.0;
251 NekDouble out = 0.0;
252 for (int d = 0; d < 3; ++d)
253 {
254 nn += n[d][i] * n[d][i];
255 nt0 += n[d][i] * t0[d][i];
256 nt1 += n[d][i] * t1[d][i];
257 tt0 += t0[d][i] * t0[d][i];
258 tt1 += t1[d][i] * t1[d][i];
259 out += n[d][i] * (faceCentre[d] - centre[d]);
260 }
261 BOOST_CHECK_SMALL(nn - 1.0, 1.0e-12);
262 BOOST_CHECK_SMALL(nt0 / std::sqrt(tt0), 1.0e-10);
263 BOOST_CHECK_SMALL(nt1 / std::sqrt(tt1), 1.0e-10);
264 BOOST_CHECK_GT(out, 0.0);
265 }
266}
NormalVector GetAlignedTraceNormal(const int traceid, const StdRegions::StdExpansion &traceExp)
Return the normals of trace traceid at the quadrature points of traceExp, in the frame of the shared ...
Definition Expansion.h:286
NEK_DEVICE_KERNEL void const TData *NEK_RESTRICT const TData *NEK_RESTRICT const size_t const unsigned int const unsigned int const unsigned int const unsigned int const size_t const TData *NEK_RESTRICT const TData *NEK_RESTRICT const TUseSharedWsp TData *NEK_RESTRICT const TData *NEK_RESTRICT TData *NEK_RESTRICT out
std::vector< double > d(NPUPPER *NPUPPER)

References Nektar::LocalRegions::Expansion::GetAlignedTraceNormal(), and Vmath::Vsum().

Referenced by BOOST_AUTO_TEST_CASE(), and BOOST_AUTO_TEST_CASE().

◆ MakeCurvedHex()

static void Nektar::AlignedTraceNormalTests::MakeCurvedHex ( CurvedHex &  p,
const int  rot,
const bool  reverse 
)
static

Build a hexahedron whose faces are numbered rot steps around (and optionally reversed), so that the element sees non-trivial and transposed face orientations, then curve every edge and face with an asymmetric perturbation of their high-order nodes.

Definition at line 322 of file TestAlignedTraceNormal.cpp.

323{
324 const std::array<std::array<NekDouble, 3>, 8> x = {{{{0.0, 0.0, 0.0}},
325 {{1.0, 0.0, 0.0}},
326 {{1.3, 1.0, 0.0}},
327 {{0.0, 1.1, 0.0}},
328 {{0.1, 0.2, 1.0}},
329 {{1.0, 0.0, 1.2}},
330 {{1.4, 1.2, 1.0}},
331 {{0.0, 1.0, 1.3}}}};
332 for (int i = 0; i < 8; ++i)
333 {
334 p.verts[i] = SpatialDomains::PointGeomUniquePtr(
335 new SpatialDomains::PointGeom(3u, i, x[i][0], x[i][1], x[i][2]));
336 }
337
338 const std::array<std::array<int, 2>, 12> edgeVerts = {{{{0, 1}},
339 {{1, 2}},
340 {{2, 3}},
341 {{3, 0}},
342 {{0, 4}},
343 {{1, 5}},
344 {{2, 6}},
345 {{3, 7}},
346 {{4, 5}},
347 {{5, 6}},
348 {{6, 7}},
349 {{7, 4}}}};
350 for (int i = 0; i < 12; ++i)
351 {
352 std::array<SpatialDomains::PointGeom *, 2> ev = {
353 p.verts[edgeVerts[i][0]].get(), p.verts[edgeVerts[i][1]].get()};
354 p.edges[i] = SpatialDomains::SegGeomUniquePtr(
355 new SpatialDomains::SegGeom(i, 3, ev));
356 }
357
358 const std::array<std::array<int, 4>, 6> faceEdges = {{{{0, 1, 2, 3}},
359 {{0, 5, 8, 4}},
360 {{1, 6, 9, 5}},
361 {{2, 6, 10, 7}},
362 {{3, 7, 11, 4}},
363 {{8, 9, 10, 11}}}};
364 std::array<SpatialDomains::QuadGeom *, 6> facePtrs;
365 for (int i = 0; i < 6; ++i)
366 {
367 // Rotating or reversing the closed edge loop renumbers the face as a
368 // neighbouring element might have, giving it a different orientation.
369 std::array<SpatialDomains::SegGeom *, 4> fe;
370 for (int j = 0; j < 4; ++j)
371 {
372 const int cyc = reverse ? (4 - j) % 4 : j;
373 fe[j] = p.edges[faceEdges[i][(cyc + rot + i) % 4]].get();
374 }
375 p.faces[i] = SpatialDomains::QuadGeomUniquePtr(
376 new SpatialDomains::QuadGeom(i, fe));
377 facePtrs[i] = p.faces[i].get();
378 }
379 p.hex = SpatialDomains::HexGeomUniquePtr(
380 new SpatialDomains::HexGeom(0, facePtrs));
381 p.hex->Setup();
382
383 std::vector<SpatialDomains::Curve *> curves;
384 auto keep = [&](SpatialDomains::Geometry *geom,
385 SpatialDomains::CurveMap &curved) {
386 geom->FillGeom();
387 auto curveAndNodes =
388 geom->MakeOrder(3, LibUtilities::ePolyEvenlySpaced);
389 for (auto &node : curveAndNodes.second)
390 {
391 p.nodes.push_back(std::move(node));
392 }
393 curves.push_back(curveAndNodes.first.get());
394 curved[geom->GetGlobalID()] = std::move(curveAndNodes.first);
395 };
396 for (auto &edge : p.edges)
397 {
398 keep(edge.get(), p.curvedEdges);
399 }
400 for (auto &face : p.faces)
401 {
402 keep(face.get(), p.curvedFaces);
403 }
404
405 // Move every node that is not a vertex by a smooth, asymmetric function
406 // of its position. Nodes shared by an edge and a face start at the same
407 // place and so stay coincident.
408 std::set<SpatialDomains::PointGeom *> moved;
409 for (auto *curve : curves)
410 {
411 for (auto *node : curve->m_points)
412 {
413 bool isVertex = false;
414 for (auto &v : p.verts)
415 {
416 isVertex = isVertex || node->dist(*v) < 1.0e-12;
417 }
418 if (isVertex || !moved.insert(node).second)
419 {
420 continue;
421 }
422 const NekDouble px = (*node)(0), py = (*node)(1), pz = (*node)(2);
423 node->UpdatePosition(
424 px + 0.06 * std::sin(2.1 * px + 0.3 * py + 1.7 * pz + 0.5),
425 py + 0.06 * std::sin(0.4 * px + 2.3 * py + 0.9 * pz + 1.1),
426 pz + 0.06 * std::sin(1.5 * px + 0.8 * py + 2.2 * pz + 0.2));
427 }
428 }
429 p.hex->Reset(p.curvedEdges, p.curvedFaces);
430}
std::vector< double > p(NPUPPER)

References Nektar::LibUtilities::ePolyEvenlySpaced, Nektar::SpatialDomains::Geometry::FillGeom(), Nektar::SpatialDomains::Geometry::GetGlobalID(), and Nektar::SpatialDomains::Geometry::MakeOrder().

Referenced by BOOST_AUTO_TEST_CASE().

◆ MakeCurvedTet()

static CurvedTet Nektar::AlignedTraceNormalTests::MakeCurvedTet ( const int  flip = 0)
static

Build a tetrahedron with a curved face 0. Setting bit i of flip traverses face i (1-3) the other way round, keeping its first edge on face 0 as TetGeom requires, which changes the orientation the element sees.

Definition at line 72 of file TestAlignedTraceNormal.cpp.

73{
74 CurvedTet p;
75 const std::array<std::array<NekDouble, 3>, 4> x = {{{{0.0, 0.0, 0.0}},
76 {{1.0, 0.0, 0.0}},
77 {{0.1, 1.0, 0.0}},
78 {{0.2, 0.1, 1.1}}}};
79
80 for (int i = 0; i < 4; ++i)
81 {
82 p.verts[i] = SpatialDomains::PointGeomUniquePtr(
83 new SpatialDomains::PointGeom(3u, i, x[i][0], x[i][1], x[i][2]));
84 }
85
86 const std::array<std::array<int, 2>, 6> edgeVerts = {
87 {{{0, 1}}, {{1, 2}}, {{0, 2}}, {{0, 3}}, {{1, 3}}, {{2, 3}}}};
88 for (int i = 0; i < 6; ++i)
89 {
90 std::array<SpatialDomains::PointGeom *, 2> ev = {
91 p.verts[edgeVerts[i][0]].get(), p.verts[edgeVerts[i][1]].get()};
92 p.edges[i] = SpatialDomains::SegGeomUniquePtr(
93 new SpatialDomains::SegGeom(i, 3, ev));
94 }
95
96 const std::array<std::array<int, 3>, 4> faceEdges = {
97 {{{0, 1, 2}}, {{0, 4, 3}}, {{1, 5, 4}}, {{2, 5, 3}}}};
98 std::array<SpatialDomains::TriGeom *, 4> facePtrs;
99 for (int i = 0; i < 4; ++i)
100 {
101 std::array<SpatialDomains::SegGeom *, 3> fe;
102 for (int j = 0; j < 3; ++j)
103 {
104 const int cyc = (flip >> i) & 1 ? (3 - j) % 3 : j;
105 fe[j] = p.edges[faceEdges[i][cyc]].get();
106 }
107 p.faces[i] = SpatialDomains::TriGeomUniquePtr(
108 new SpatialDomains::TriGeom(i, fe));
109 facePtrs[i] = p.faces[i].get();
110 }
111 p.tet = SpatialDomains::TetGeomUniquePtr(
112 new SpatialDomains::TetGeom(0, facePtrs));
113 p.tet->Setup();
114
115 for (auto &edge : p.edges)
116 {
117 edge->FillGeom();
118 auto curveAndNodes =
119 edge->MakeOrder(3, LibUtilities::ePolyEvenlySpaced);
120 for (auto &node : curveAndNodes.second)
121 {
122 p.nodes.push_back(std::move(node));
123 }
124 p.curvedEdges[edge->GetGlobalID()] = std::move(curveAndNodes.first);
125 }
126 for (auto &face : p.faces)
127 {
128 face->FillGeom();
129 auto curveAndNodes =
130 face->MakeOrder(3, LibUtilities::eNodalTriEvenlySpaced);
131 for (auto &node : curveAndNodes.second)
132 {
133 p.nodes.push_back(std::move(node));
134 }
135 p.curvedFaces[face->GetGlobalID()] = std::move(curveAndNodes.first);
136 }
137
138 // At order three the final triangular node is the single face interior
139 // node. Moving it out of the face plane makes the normal vary over the
140 // face; the other faces are bent too, so that their orientation matters.
141 const std::array<std::array<NekDouble, 3>, 4> bump = {
142 {{{0.0, 0.0, 0.2}},
143 {{0.02, -0.1, 0.03}},
144 {{0.08, 0.05, 0.04}},
145 {{-0.1, 0.02, 0.01}}}};
146 for (int i = 0; i < 4; ++i)
147 {
148 SpatialDomains::PointGeom *interior = p.curvedFaces[i]->m_points.back();
149 interior->UpdatePosition((*interior)(0) + bump[i][0],
150 (*interior)(1) + bump[i][1],
151 (*interior)(2) + bump[i][2]);
152 }
153 p.tet->Reset(p.curvedEdges, p.curvedFaces);
154 return p;
155}

References Nektar::LibUtilities::eNodalTriEvenlySpaced, Nektar::LibUtilities::ePolyEvenlySpaced, and Nektar::SpatialDomains::PointGeom::UpdatePosition().

Referenced by BOOST_AUTO_TEST_CASE(), and BOOST_AUTO_TEST_CASE().