Nektar++
Loading...
Searching...
No Matches
TestGetCoords.cpp
Go to the documentation of this file.
1///////////////////////////////////////////////////////////////////////////////
2//
3// File: TestGetCoords.cpp
4//
5// For more information, please see: http://www.nektar.info
6//
7// The MIT License
8//
9// Copyright (c) 2006 Division of Applied Mathematics, Brown University (USA),
10// Department of Aeronautics, Imperial College London (UK), and Scientific
11// Computing and Imaging Institute, University of Utah (USA).
12//
13// Permission is hereby granted, free of charge, to any person obtaining a
14// copy of this software and associated documentation files (the "Software"),
15// to deal in the Software without restriction, including without limitation
16// the rights to use, copy, modify, merge, publish, distribute, sublicense,
17// and/or sell copies of the Software, and to permit persons to whom the
18// Software is furnished to do so, subject to the following conditions:
19//
20// The above copyright notice and this permission notice shall be included
21// in all copies or substantial portions of the Software.
22//
23// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
24// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
25// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
26// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
27// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
28// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
29// DEALINGS IN THE SOFTWARE.
30//
31// Description:
32//
33///////////////////////////////////////////////////////////////////////////////
34
36#include <LocalRegions/HexExp.h>
38#include <boost/test/tools/floating_point_comparison.hpp>
39#include <boost/test/unit_test.hpp>
40
42{
46{
47 std::array<SpatialDomains::PointGeom *, 2> vertices = {v0, v1};
49 new SpatialDomains::SegGeom(id, 3, vertices));
50 return result;
51}
52
54 std::array<SpatialDomains::PointGeom *, 8> v,
55 std::array<SpatialDomains::SegGeomUniquePtr, 12> &segVec,
56 std::array<SpatialDomains::QuadGeomUniquePtr, 6> &faceVec)
57{
58 std::array<std::array<int, 2>, 12> edgeVerts = {{{{0, 1}},
59 {{1, 2}},
60 {{2, 3}},
61 {{3, 0}},
62 {{0, 4}},
63 {{1, 5}},
64 {{2, 6}},
65 {{3, 7}},
66 {{4, 5}},
67 {{5, 6}},
68 {{6, 7}},
69 {{7, 4}}}};
70 std::array<std::array<int, 4>, 6> faceEdges = {{{{0, 1, 2, 3}},
71 {{0, 5, 8, 4}},
72 {{1, 6, 9, 5}},
73 {{2, 6, 10, 7}},
74 {{3, 7, 11, 4}},
75 {{8, 9, 10, 11}}}};
76
77 // Create segments from vertices
78 for (int i = 0; i < 12; ++i)
79 {
80 segVec[i] = CreateSegGeom(i, v[edgeVerts[i][0]], v[edgeVerts[i][1]]);
81 }
82
83 // Create faces from edges
84 std::array<SpatialDomains::QuadGeom *, 6> faces;
85 for (int i = 0; i < 6; ++i)
86 {
87 std::array<SpatialDomains::SegGeom *, 4> face;
88 for (int j = 0; j < 4; ++j)
89 {
90 face[j] = segVec[faceEdges[i][j]].get();
91 }
93 new SpatialDomains::QuadGeom(i, face));
94 faces[i] = faceVec[i].get();
95 }
96
98 new SpatialDomains::HexGeom(0, faces));
99 return hexGeom;
100}
101
102BOOST_AUTO_TEST_CASE(TestHexExpThatIsStdRegion)
103{
105 new SpatialDomains::PointGeom(3u, 0u, -1.0, -1.0, -1.0));
107 new SpatialDomains::PointGeom(3u, 1u, 1.0, -1.0, -1.0));
109 new SpatialDomains::PointGeom(3u, 2u, 1.0, 1.0, -1.0));
111 new SpatialDomains::PointGeom(3u, 3u, -1.0, 1.0, -1.0));
113 new SpatialDomains::PointGeom(3u, 4u, -1.0, -1.0, 1.0));
115 new SpatialDomains::PointGeom(3u, 5u, 1.0, -1.0, 1.0));
117 new SpatialDomains::PointGeom(3u, 6u, 1.0, 1.0, 1.0));
119 new SpatialDomains::PointGeom(3u, 7u, -1.0, 1.0, 1.0));
120
121 std::array<SpatialDomains::PointGeom *, 8> v = {
122 v0.get(), v1.get(), v2.get(), v3.get(),
123 v4.get(), v5.get(), v6.get(), v7.get()};
124 std::array<SpatialDomains::SegGeomUniquePtr, 12> segVec;
125 std::array<SpatialDomains::QuadGeomUniquePtr, 6> faceVec;
126 SpatialDomains::HexGeomUniquePtr hexGeom = CreateHex(v, segVec, faceVec);
127
128 Nektar::LibUtilities::PointsType quadPointsTypeDir1 =
130 Nektar::LibUtilities::BasisType basisTypeDir1 =
132 unsigned int numQuadPoints = 6;
133 const Nektar::LibUtilities::PointsKey quadPointsKeyDir1(numQuadPoints,
134 quadPointsTypeDir1);
135 const Nektar::LibUtilities::BasisKey basisKeyDir1(basisTypeDir1, 4,
136 quadPointsKeyDir1);
137
140 basisKeyDir1, basisKeyDir1, basisKeyDir1, hexGeom.get());
141
142 Array<OneD, NekDouble> c0 = Array<OneD, NekDouble>(hexExp->GetTotPoints());
143 Array<OneD, NekDouble> c1 = Array<OneD, NekDouble>(hexExp->GetTotPoints());
144 Array<OneD, NekDouble> c2 = Array<OneD, NekDouble>(hexExp->GetTotPoints());
145 hexExp->GetCoords(c0, c1, c2);
146 std::shared_ptr<StdRegions::StdHexExp> stdHex =
147 std::dynamic_pointer_cast<StdRegions::StdHexExp>(hexExp);
148 stdHex->GetCoords(c0, c1, c2);
149 double epsilon = 1.0e-8;
150 BOOST_CHECK_CLOSE(c0[0], -1.0, epsilon);
151 BOOST_CHECK_CLOSE(c0[1], -0.76505532392946474, epsilon);
152 BOOST_CHECK_CLOSE(c0[2], -0.28523151648064510, epsilon);
153 BOOST_CHECK_CLOSE(c0[3], 0.28523151648064510, epsilon);
154 BOOST_CHECK_CLOSE(c0[4], 0.76505532392946474, epsilon);
155 BOOST_CHECK_CLOSE(c0[5], 1.0, epsilon);
156}
157
158BOOST_AUTO_TEST_CASE(TestScaledAndTranslatedHexExp)
159{
161 new SpatialDomains::PointGeom(3u, 0u, 0.0, 0.0, 0.0));
163 new SpatialDomains::PointGeom(3u, 1u, 0.5, 0.0, 0.0));
165 new SpatialDomains::PointGeom(3u, 2u, 0.5, 0.5, 0.0));
167 new SpatialDomains::PointGeom(3u, 3u, 0.0, 0.5, 0.0));
169 new SpatialDomains::PointGeom(3u, 4u, 0.0, 0.0, 0.5));
171 new SpatialDomains::PointGeom(3u, 5u, 0.5, 0.0, 0.5));
173 new SpatialDomains::PointGeom(3u, 6u, 0.5, 0.5, 0.5));
175 new SpatialDomains::PointGeom(3u, 7u, 0.0, 0.5, 0.5));
176
177 std::array<SpatialDomains::PointGeom *, 8> v = {
178 v0.get(), v1.get(), v2.get(), v3.get(),
179 v4.get(), v5.get(), v6.get(), v7.get()};
180 std::array<SpatialDomains::SegGeomUniquePtr, 12> segVec;
181 std::array<SpatialDomains::QuadGeomUniquePtr, 6> faceVec;
182 SpatialDomains::HexGeomUniquePtr hexGeom = CreateHex(v, segVec, faceVec);
183
184 Nektar::LibUtilities::PointsType quadPointsTypeDir1 =
186 Nektar::LibUtilities::BasisType basisTypeDir1 =
188 unsigned int numQuadPoints = 6;
189 const Nektar::LibUtilities::PointsKey quadPointsKeyDir1(numQuadPoints,
190 quadPointsTypeDir1);
191 const Nektar::LibUtilities::BasisKey basisKeyDir1(basisTypeDir1, 4,
192 quadPointsKeyDir1);
193
196 basisKeyDir1, basisKeyDir1, basisKeyDir1, hexGeom.get());
197
198 Array<OneD, NekDouble> c0 = Array<OneD, NekDouble>(hexExp->GetTotPoints());
199 Array<OneD, NekDouble> c1 = Array<OneD, NekDouble>(hexExp->GetTotPoints());
200 Array<OneD, NekDouble> c2 = Array<OneD, NekDouble>(hexExp->GetTotPoints());
201 hexExp->GetCoords(c0, c1, c2);
202
203 double epsilon = 1.0e-8;
204 BOOST_CHECK_EQUAL(c0[0], 0.0);
205 BOOST_CHECK_CLOSE(c0[1], .05873616902, epsilon);
206 BOOST_CHECK_CLOSE(c0[2], .17869212088, epsilon);
207 BOOST_CHECK_CLOSE(c0[3], .32130787912, epsilon);
208 BOOST_CHECK_CLOSE(c0[4], .44126383098, epsilon);
209 BOOST_CHECK_CLOSE(c0[5], .5, epsilon);
210}
211
212BOOST_AUTO_TEST_CASE(TestPointExpThatIsStdRegion)
213{
215 new SpatialDomains::PointGeom(3u, 0u, -1.0, -1.0, -1.0));
216
217 Nektar::LibUtilities::PointsType quadPointsTypeDir1 =
219 Nektar::LibUtilities::BasisType basisTypeDir1 =
221 unsigned int numQuadPoints = 1;
222 unsigned int numModes = 1;
223 const Nektar::LibUtilities::PointsKey quadPointsKeyDir1(numQuadPoints,
224 quadPointsTypeDir1);
225 const Nektar::LibUtilities::BasisKey basisKeyDir1(basisTypeDir1, numModes,
226 quadPointsKeyDir1);
227
230 v0.get());
231
232 NekDouble c0 = 0, c1 = 0, c2 = 0;
233 pointExp->GetCoords(c0, c1, c2);
234
235 std::shared_ptr<StdRegions::StdPointExp> stdPoint =
236 std::dynamic_pointer_cast<StdRegions::StdPointExp>(pointExp);
237
239 Array<OneD, NekDouble>(pointExp->GetTotPoints());
241 Array<OneD, NekDouble>(pointExp->GetTotPoints());
243 Array<OneD, NekDouble>(pointExp->GetTotPoints());
244 stdPoint->GetCoords(c0_arr, c1_arr, c2_arr);
245
246 double epsilon = 1.0e-8;
247 BOOST_CHECK_CLOSE(c0, -1.0, epsilon);
248 BOOST_CHECK_CLOSE(c0_arr[0], -1.0, epsilon);
249
250 // Get GeomFactors and check it's a nullptr for pointExp
251 BOOST_CHECK_EQUAL(pointExp->GetGeomFactors(), nullptr);
252}
253
254} // namespace Nektar::HexExpTests
Describes the specification for a Basis.
Definition Basis.h:45
Defines a specification for a set of points.
Definition Points.h:50
static std::shared_ptr< DataType > AllocateSharedPtr(const Args &...args)
Allocate a shared pointer from the memory pool.
BOOST_AUTO_TEST_CASE(TestHexExpThatIsStdRegion)
SpatialDomains::SegGeomUniquePtr CreateSegGeom(unsigned int id, SpatialDomains::PointGeom *v0, SpatialDomains::PointGeom *v1)
SpatialDomains::HexGeomUniquePtr CreateHex(std::array< SpatialDomains::PointGeom *, 8 > v, std::array< SpatialDomains::SegGeomUniquePtr, 12 > &segVec, std::array< SpatialDomains::QuadGeomUniquePtr, 6 > &faceVec)
@ eGaussLobattoLegendre
1D Gauss-Lobatto-Legendre quadrature points
Definition PointsType.h:51
@ eModified_A
Principle Modified Functions .
Definition BasisType.h:48
std::shared_ptr< PointExp > PointExpSharedPtr
Definition PointExp.h:130
std::shared_ptr< HexExp > HexExpSharedPtr
Definition HexExp.h:189
unique_ptr_objpool< HexGeom > HexGeomUniquePtr
Definition MeshGraph.h:108
unique_ptr_objpool< QuadGeom > QuadGeomUniquePtr
Definition MeshGraph.h:104
unique_ptr_objpool< SegGeom > SegGeomUniquePtr
Definition MeshGraph.h:102
unique_ptr_objpool< PointGeom > PointGeomUniquePtr
Definition MeshGraph.h:99