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

Classes

struct  PyrParts
 Storage for the entities a pyramid is built from, which must outlive it. More...
 

Functions

static void BuildPyr (PyrParts &p, const std::array< std::array< NekDouble, 3 >, 5 > &x)
 Build a straight-sided pyramid from five vertex positions.
 
static NekDouble WorstRoundTrip (SpatialDomains::Geometry *geom)
 Map a local coordinate forward and back, and report the largest component error over a set of interior points.
 
 BOOST_AUTO_TEST_CASE (TestPyrRoundTripParallelogramBase)
 
 BOOST_AUTO_TEST_CASE (TestPyrRoundTripSkewedBase)
 

Function Documentation

◆ BOOST_AUTO_TEST_CASE() [1/2]

Nektar::PyrInverseMapTests::BOOST_AUTO_TEST_CASE ( TestPyrRoundTripParallelogramBase  )

Definition at line 168 of file TestPyrInverseMap.cpp.

169{
170 PyrParts p;
171 BuildPyr(p, {{{{0.0, 0.0, 0.0}},
172 {{1.0, 0.0, 0.0}},
173 {{1.0, 1.0, 0.0}},
174 {{0.0, 1.0, 0.0}},
175 {{0.5, 0.5, 1.0}}}});
176
177 BOOST_CHECK_EQUAL(p.pyr->CalcGeomType(), SpatialDomains::eRegular);
178 BOOST_CHECK_SMALL(WorstRoundTrip(p.pyr.get()), 1e-8);
179}
static NekDouble WorstRoundTrip(SpatialDomains::Geometry *geom)
Map a local coordinate forward and back, and report the largest component error over a set of interio...
static void BuildPyr(PyrParts &p, const std::array< std::array< NekDouble, 3 >, 5 > &x)
Build a straight-sided pyramid from five vertex positions.
std::vector< double > p(NPUPPER)
Storage for the entities a pyramid is built from, which must outlive it.

References BuildPyr(), Nektar::SpatialDomains::eRegular, and WorstRoundTrip().

◆ BOOST_AUTO_TEST_CASE() [2/2]

Nektar::PyrInverseMapTests::BOOST_AUTO_TEST_CASE ( TestPyrRoundTripSkewedBase  )

Definition at line 186 of file TestPyrInverseMap.cpp.

187{
188 PyrParts p;
189 BuildPyr(p, {{{{0.0, 0.0, 0.0}},
190 {{1.0, 0.0, 0.0}},
191 {{1.0, 1.0, 0.0}},
192 {{0.0, 1.3, 0.0}},
193 {{0.5, 0.5, 1.0}}}});
194
195 BOOST_CHECK_EQUAL(p.pyr->CalcGeomType(), SpatialDomains::eDeformed);
196 BOOST_CHECK_SMALL(WorstRoundTrip(p.pyr.get()), 1e-8);
197}

References BuildPyr(), Nektar::SpatialDomains::eDeformed, and WorstRoundTrip().

◆ BuildPyr()

static void Nektar::PyrInverseMapTests::BuildPyr ( PyrParts &  p,
const std::array< std::array< NekDouble, 3 >, 5 > &  x 
)
static

Build a straight-sided pyramid from five vertex positions.

Definition at line 61 of file TestPyrInverseMap.cpp.

63{
64 for (int i = 0; i < 5; ++i)
65 {
67 new SpatialDomains::PointGeom(3u, i, x[i][0], x[i][1], x[i][2]));
68 }
69
70 const std::array<std::array<int, 2>, 8> edgeVerts = {{{{0, 1}},
71 {{1, 2}},
72 {{3, 2}},
73 {{0, 3}},
74 {{0, 4}},
75 {{1, 4}},
76 {{2, 4}},
77 {{3, 4}}}};
78 for (int i = 0; i < 8; ++i)
79 {
80 std::array<SpatialDomains::PointGeom *, 2> ev = {
81 p.verts[edgeVerts[i][0]].get(), p.verts[edgeVerts[i][1]].get()};
82 p.edges[i] = SpatialDomains::SegGeomUniquePtr(
83 new SpatialDomains::SegGeom(i, 3, ev));
84 }
85
86 const std::array<std::array<int, 4>, 5> faceEdges = {{{{0, 1, 2, 3}},
87 {{0, 5, 4, -1}},
88 {{1, 6, 5, -1}},
89 {{2, 7, 6, -1}},
90 {{3, 7, 4, -1}}}};
91
92 std::array<SpatialDomains::Geometry2D *, 5> faces;
93 for (int i = 0; i < 5; ++i)
94 {
95 if (i == 0)
96 {
97 std::array<SpatialDomains::SegGeom *, 4> f;
98 for (int j = 0; j < 4; ++j)
99 {
100 f[j] = p.edges[faceEdges[i][j]].get();
101 }
102 p.quad = SpatialDomains::QuadGeomUniquePtr(
103 new SpatialDomains::QuadGeom(i, f));
104 faces[i] = p.quad.get();
105 }
106 else
107 {
108 std::array<SpatialDomains::SegGeom *, 3> f;
109 for (int j = 0; j < 3; ++j)
110 {
111 f[j] = p.edges[faceEdges[i][j]].get();
112 }
113 p.tris[i - 1] = SpatialDomains::TriGeomUniquePtr(
114 new SpatialDomains::TriGeom(i, f));
115 faces[i] = p.tris[i - 1].get();
116 }
117 }
118
119 p.pyr =
120 SpatialDomains::PyrGeomUniquePtr(new SpatialDomains::PyrGeom(0, faces));
121 p.pyr->Setup();
122}
unique_ptr_objpool< PointGeom > PointGeomUniquePtr
Definition Geometry.h:60

Referenced by BOOST_AUTO_TEST_CASE(), and BOOST_AUTO_TEST_CASE().

◆ WorstRoundTrip()

static NekDouble Nektar::PyrInverseMapTests::WorstRoundTrip ( SpatialDomains::Geometry *  geom)
static

Map a local coordinate forward and back, and report the largest component error over a set of interior points.

Definition at line 126 of file TestPyrInverseMap.cpp.

127{
128 auto locator = SpatialDomains::GeometryLocator::Create(geom);
129
130 // Points strictly inside the reference pyramid, which is bounded by
131 // xi_i >= -1 and xi_0 + xi_2 <= 0, xi_1 + xi_2 <= 0.
132 const std::array<std::array<NekDouble, 3>, 6> probes = {
133 {{{-0.5, -0.5, 0.0}},
134 {{0.0, 0.0, -0.5}},
135 {{-0.2, -0.3, 0.3}},
136 {{-0.6, 0.2, 0.5}},
137 {{-0.25, -0.25, 0.25}},
138 {{0.3, -0.4, -0.6}}}};
139
140 NekDouble worst = 0.0;
141 for (auto &probe : probes)
142 {
143 Array<OneD, NekDouble> xi(3), x(3), back(3, 0.0);
144 for (int d = 0; d < 3; ++d)
145 {
146 xi[d] = probe[d];
147 }
148
149 // Forward: the chi mapping, as GetCoord evaluates it.
150 for (int d = 0; d < 3; ++d)
151 {
152 x[d] = geom->GetCoord(d, xi);
153 }
154
155 // Inverse: whatever route the locator chooses.
156 locator->GetLocCoords(x, back);
157
158 for (int d = 0; d < 3; ++d)
159 {
160 worst = std::max(worst, std::abs(back[d] - xi[d]));
161 }
162 }
163 return worst;
164}
NekDouble GetCoord(const int i, const Array< OneD, const NekDouble > &Lcoord)
Evaluate the mapping: physical coordinate in direction i at the local collapsed coordinate Lcoord.
Definition Geometry.h:615
std::vector< double > d(NPUPPER *NPUPPER)

References Nektar::SpatialDomains::GeometryLocator::Create(), and Nektar::SpatialDomains::Geometry::GetCoord().

Referenced by BOOST_AUTO_TEST_CASE(), and BOOST_AUTO_TEST_CASE().