48#include <boost/test/unit_test.hpp>
60 std::array<SpatialDomains::PointGeomUniquePtr, 4>
verts;
61 std::array<SpatialDomains::SegGeomUniquePtr, 6>
edges;
62 std::array<SpatialDomains::TriGeomUniquePtr, 4>
faces;
66 std::vector<SpatialDomains::PointGeomUniquePtr>
nodes;
75 const std::array<std::array<NekDouble, 3>, 4> x = {{{{0.0, 0.0, 0.0}},
80 for (
int i = 0; i < 4; ++i)
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)
90 std::array<SpatialDomains::PointGeom *, 2> ev = {
91 p.verts[edgeVerts[i][0]].get(), p.verts[edgeVerts[i][1]].get()};
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)
101 std::array<SpatialDomains::SegGeom *, 3> fe;
102 for (
int j = 0; j < 3; ++j)
104 const int cyc = (flip >> i) & 1 ? (3 - j) % 3 : j;
105 fe[j] = p.edges[faceEdges[i][cyc]].get();
109 facePtrs[i] = p.faces[i].get();
115 for (
auto &edge : p.edges)
120 for (
auto &node : curveAndNodes.second)
122 p.nodes.push_back(std::move(node));
124 p.curvedEdges[edge->GetGlobalID()] = std::move(curveAndNodes.first);
126 for (
auto &face : p.faces)
131 for (
auto &node : curveAndNodes.second)
133 p.nodes.push_back(std::move(node));
135 p.curvedFaces[face->GetGlobalID()] = std::move(curveAndNodes.first);
141 const std::array<std::array<NekDouble, 3>, 4> bump = {
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)
150 (*interior)(1) + bump[i][1],
151 (*interior)(2) + bump[i][2]);
153 p.tet->Reset(p.curvedEdges, p.curvedFaces);
161 using namespace LibUtilities;
166 high0, high1, high2, geom.
tet.get());
171 low0, low1, geom.
faces[0].get());
174 boundary->SetAdjacentElementExp(0, adjacent);
176 BOOST_REQUIRE_EQUAL(boundary->GetGeomFactors()->GetGtype(),
178 BOOST_REQUIRE(volume->GetTraceBasisKey(0, 0) != low0 ||
179 volume->GetTraceBasisKey(0, 1) != low1);
181 const int nq = boundary->GetTotPoints();
183 for (
int i = 0; i < nq; ++i)
185 fx[i] = 0.3 + 0.02 * i;
186 fy[i] = -0.4 + 0.01 * i;
187 fz[i] = 0.8 - 0.03 * i;
191 boundary->NormVectorIProductWRTBase(fx, fy, fz, actual);
193 const auto &normal = volume->GetTraceNormal(0);
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);
203 for (
int i = 0; i < nq; ++i)
205 flux[i] = nx[i] * fx[i] + ny[i] * fy[i] + nz[i] * fz[i];
208 boundary->IProductWRTBase(flux, expected);
210 for (
int i = 0; i < expected.size(); ++i)
212 BOOST_CHECK_SMALL(actual[i] - expected[i], 1.0e-11);
222 const std::array<NekDouble, 3> ¢re)
224 const int nq = bnd.GetTotPoints();
226 BOOST_REQUIRE_EQUAL(n.size(), 3);
228 std::array<Array<OneD, NekDouble>, 3> x, t0, t1;
229 for (
int d = 0; d < 3; ++d)
231 BOOST_REQUIRE_EQUAL(n[d].size(), nq);
236 bnd.GetCoords(x[0], x[1], x[2]);
237 for (
int d = 0; d < 3; ++d)
239 bnd.StdPhysDeriv(x[d], t0[d], t1[d]);
242 std::array<NekDouble, 3> faceCentre;
243 for (
int d = 0; d < 3; ++d)
248 for (
int i = 0; i < nq; ++i)
250 NekDouble nn = 0.0, nt0 = 0.0, nt1 = 0.0, tt0 = 0.0, tt1 = 0.0;
252 for (
int d = 0; d < 3; ++d)
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]);
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);
279 using namespace LibUtilities;
284 std::set<StdRegions::Orientation> orients;
285 for (
int flip = 0; flip < 16; flip += 2)
289 b0, b1, b2, geom.
tet.get());
290 const std::array<NekDouble, 3> centre =
Centre(*volume);
292 for (
int f = 0; f < 4; ++f)
294 orients.insert(volume->GetTraceOrient(f));
296 volume->GetAlignedTraceExp(f);
303 BOOST_CHECK_GT(orients.size(), 1);
309 std::array<SpatialDomains::PointGeomUniquePtr, 8>
verts;
310 std::array<SpatialDomains::SegGeomUniquePtr, 12>
edges;
311 std::array<SpatialDomains::QuadGeomUniquePtr, 6>
faces;
315 std::vector<SpatialDomains::PointGeomUniquePtr>
nodes;
324 const std::array<std::array<NekDouble, 3>, 8> x = {{{{0.0, 0.0, 0.0}},
332 for (
int i = 0; i < 8; ++i)
338 const std::array<std::array<int, 2>, 12> edgeVerts = {{{{0, 1}},
350 for (
int i = 0; i < 12; ++i)
352 std::array<SpatialDomains::PointGeom *, 2> ev = {
353 p.verts[edgeVerts[i][0]].get(), p.verts[edgeVerts[i][1]].get()};
358 const std::array<std::array<int, 4>, 6> faceEdges = {{{{0, 1, 2, 3}},
364 std::array<SpatialDomains::QuadGeom *, 6> facePtrs;
365 for (
int i = 0; i < 6; ++i)
369 std::array<SpatialDomains::SegGeom *, 4> fe;
370 for (
int j = 0; j < 4; ++j)
372 const int cyc = reverse ? (4 - j) % 4 : j;
373 fe[j] = p.edges[faceEdges[i][(cyc + rot + i) % 4]].get();
377 facePtrs[i] = p.faces[i].get();
383 std::vector<SpatialDomains::Curve *> curves;
389 for (
auto &node : curveAndNodes.second)
391 p.nodes.push_back(std::move(node));
393 curves.push_back(curveAndNodes.first.get());
394 curved[geom->
GetGlobalID()] = std::move(curveAndNodes.first);
396 for (
auto &edge : p.edges)
398 keep(edge.get(), p.curvedEdges);
400 for (
auto &face : p.faces)
402 keep(face.get(), p.curvedFaces);
408 std::set<SpatialDomains::PointGeom *> moved;
409 for (
auto *curve : curves)
411 for (
auto *node : curve->m_points)
413 bool isVertex =
false;
414 for (
auto &v : p.verts)
416 isVertex = isVertex || node->dist(*v) < 1.0e-12;
418 if (isVertex || !moved.insert(node).second)
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));
429 p.hex->Reset(p.curvedEdges, p.curvedFaces);
434 using namespace LibUtilities;
441 std::set<StdRegions::Orientation> orients;
442 for (
const bool reverse : {
false,
true})
444 for (
int rot = 0; rot < 4; ++rot)
450 b0, b1, b2, geom.
hex.get());
451 const std::array<NekDouble, 3> centre =
Centre(*volume);
453 for (
int f = 0; f < 6; ++f)
455 orients.insert(volume->GetTraceOrient(f));
457 volume->GetAlignedTraceExp(f);
458 BOOST_REQUIRE_EQUAL(bnd->GetGeomFactors()->GetGtype(),
464 bnd->SetAdjacentElementExp(f, adjacent);
465 const int nq = bnd->GetTotPoints();
467 volume->GetAlignedTraceNormal(f, *bnd);
469 for (
int i = 0; i < nq; ++i)
471 fx[i] = 0.3 + 0.02 * i;
472 fy[i] = -0.4 + 0.01 * i;
473 fz[i] = 0.8 - 0.03 * i;
475 n[0][i] * fx[i] + n[1][i] * fy[i] + n[2][i] * fz[i];
479 bnd->NormVectorIProductWRTBase(fx, fy, fz, actual);
480 bnd->IProductWRTBase(flux, expected);
481 for (
int i = 0; i < expected.size(); ++i)
483 BOOST_CHECK_SMALL(actual[i] - expected[i], 1.0e-12);
490 BOOST_CHECK_GT(orients.size(), 2);
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}}}};
504 std::array<SpatialDomains::PointGeomUniquePtr, 4> verts;
505 for (
int i = 0; i < 4; ++i)
510 std::array<SpatialDomains::SegGeomUniquePtr, 4> edges;
511 std::array<SpatialDomains::SegGeom *, 4> edgePtrs;
512 for (
int i = 0; i < 4; ++i)
514 std::array<SpatialDomains::PointGeom *, 2> ev = {
515 verts[i].get(), verts[(i + 1) % 4].get()};
518 edgePtrs[i] = edges[i].get();
525 std::array<std::array<NekDouble, 2>, 4> exact;
526 for (
int i = 0; i < 4; ++i)
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}};
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)
542 BOOST_REQUIRE_EQUAL(exp->GetGeomFactors()->GetGtype(),
545 for (
int e = 0; e < 4; ++e)
547 const auto &normal = exp->GetTraceNormal(e);
548 for (
size_t q = 0; q < normal[0].size(); ++q)
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] <<
")");
Describes the specification for a Basis.
Defines a specification for a set of points.
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 ...
static std::shared_ptr< DataType > AllocateSharedPtr(const Args &...args)
Allocate a shared pointer from the memory pool.
int GetGlobalID(void) const
Get the ID of this object.
void FillGeom()
Gather the coefficients of from this object's boundary, unless that has already been done.
std::pair< CurveUniquePtr, std::vector< PointGeomUniquePtr > > MakeOrder(int order, const LibUtilities::PointsType pType)
Re-express this object's curvature at polynomial order order, returning the curve and the points gene...
void UpdatePosition(NekDouble x, NekDouble y, NekDouble z)
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
static void CheckAlignedNormals(LocalRegions::Expansion &elmt, const int face, LocalRegions::Expansion &bnd, const std::array< NekDouble, 3 > ¢re)
Check that the normals of face, sampled on bnd, are unit vectors orthogonal to the boundary expansion...
BOOST_AUTO_TEST_CASE(TestDeformedFaceNormalWithDifferentQuadrature)
static void MakeCurvedHex(CurvedHex &p, const int rot, const bool reverse)
Build a hexahedron whose faces are numbered rot steps around (and optionally reversed),...
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)
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,...
@ eNodalTriEvenlySpaced
2D Evenly-spaced points on a Triangle
@ eGaussLobattoLegendre
1D Gauss-Lobatto-Legendre quadrature points
@ ePolyEvenlySpaced
1D Evenly-spaced points using Lagrange polynomial
@ eGaussGaussLegendre
1D Gauss-Gauss-Legendre quadrature points
@ eModified_B
Principle Modified Functions .
@ eOrtho_A
Principle Orthogonal Functions .
@ eModified_C
Principle Modified Functions .
@ eModified_A
Principle Modified Functions .
std::shared_ptr< Expansion > ExpansionSharedPtr
unique_ptr_objpool< HexGeom > HexGeomUniquePtr
std::map< int, CurveUniquePtr > CurveMap
unique_ptr_objpool< QuadGeom > QuadGeomUniquePtr
@ eDeformed
Geometry is curved or has non-constant factors.
unique_ptr_objpool< SegGeom > SegGeomUniquePtr
unique_ptr_objpool< PointGeom > PointGeomUniquePtr
unique_ptr_objpool< TriGeom > TriGeomUniquePtr
unique_ptr_objpool< TetGeom > TetGeomUniquePtr
@ eDir1FwdDir2_Dir2FwdDir1
T Vsum(int n, const T *x, const int incx)
Subtract return sum(x)
Storage for a hexahedron with curved faces; entities must outlive it.
std::vector< SpatialDomains::PointGeomUniquePtr > nodes
SpatialDomains::HexGeomUniquePtr hex
std::array< SpatialDomains::QuadGeomUniquePtr, 6 > faces
std::array< SpatialDomains::PointGeomUniquePtr, 8 > verts
std::array< SpatialDomains::SegGeomUniquePtr, 12 > edges
SpatialDomains::CurveMap curvedEdges
SpatialDomains::CurveMap curvedFaces
SpatialDomains::CurveMap curvedEdges
SpatialDomains::TetGeomUniquePtr tet
SpatialDomains::CurveMap curvedFaces
std::vector< SpatialDomains::PointGeomUniquePtr > nodes
std::array< SpatialDomains::SegGeomUniquePtr, 6 > edges
std::array< SpatialDomains::PointGeomUniquePtr, 4 > verts
std::array< SpatialDomains::TriGeomUniquePtr, 4 > faces