Nektar++
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
35#include <LocalRegions/HexExp.h>
37#include <boost/test/tools/floating_point_comparison.hpp>
38#include <boost/test/unit_test.hpp>
39
40namespace Nektar
41{
42namespace HexExpTests
43{
45 unsigned int id, SpatialDomains::PointGeomSharedPtr v0,
47{
48 SpatialDomains::PointGeomSharedPtr vertices[] = {v0, v1};
50 new SpatialDomains::SegGeom(id, 3, vertices));
51 return result;
52}
53
63{
76
78 edgesF0[Nektar::SpatialDomains::QuadGeom::kNedges] = {e0, e1, e2, e3};
80 edgesF1[Nektar::SpatialDomains::QuadGeom::kNedges] = {e0, e5, e8, e4};
82 edgesF2[Nektar::SpatialDomains::QuadGeom::kNedges] = {e1, e6, e9, e5};
84 edgesF3[Nektar::SpatialDomains::QuadGeom::kNedges] = {e2, e6, e10, e7};
86 edgesF4[Nektar::SpatialDomains::QuadGeom::kNedges] = {e3, e7, e11, e4};
88 edgesF5[Nektar::SpatialDomains::QuadGeom::kNedges] = {e8, e9, e10, e11};
89
91 new SpatialDomains::QuadGeom(0, edgesF0));
93 new SpatialDomains::QuadGeom(1, edgesF1));
95 new SpatialDomains::QuadGeom(2, edgesF2));
97 new SpatialDomains::QuadGeom(3, edgesF3));
99 new SpatialDomains::QuadGeom(4, edgesF4));
101 new SpatialDomains::QuadGeom(5, edgesF5));
102
103 Nektar::SpatialDomains::QuadGeomSharedPtr qfaces[] = {face0, face1, face2,
104 face3, face4, face5};
106 new SpatialDomains::HexGeom(0, qfaces));
107 return hexGeom;
108}
109
110BOOST_AUTO_TEST_CASE(TestHexExpThatIsStdRegion)
111{
113 new SpatialDomains::PointGeom(3u, 0u, -1.0, -1.0, -1.0));
115 new SpatialDomains::PointGeom(3u, 1u, 1.0, -1.0, -1.0));
117 new SpatialDomains::PointGeom(3u, 2u, 1.0, 1.0, -1.0));
119 new SpatialDomains::PointGeom(3u, 3u, -1.0, 1.0, -1.0));
121 new SpatialDomains::PointGeom(3u, 4u, -1.0, -1.0, 1.0));
123 new SpatialDomains::PointGeom(3u, 5u, 1.0, -1.0, 1.0));
125 new SpatialDomains::PointGeom(3u, 6u, 1.0, 1.0, 1.0));
127 new SpatialDomains::PointGeom(3u, 7u, -1.0, 1.0, 1.0));
128
130 CreateHex(v0, v1, v2, v3, v4, v5, v6, v7);
131
132 Nektar::LibUtilities::PointsType quadPointsTypeDir1 =
134 Nektar::LibUtilities::BasisType basisTypeDir1 =
136 unsigned int numQuadPoints = 6;
137 const Nektar::LibUtilities::PointsKey quadPointsKeyDir1(numQuadPoints,
138 quadPointsTypeDir1);
139 const Nektar::LibUtilities::BasisKey basisKeyDir1(basisTypeDir1, 4,
140 quadPointsKeyDir1);
141
144 basisKeyDir1, basisKeyDir1, basisKeyDir1, hexGeom);
145
146 Array<OneD, NekDouble> c0 = Array<OneD, NekDouble>(hexExp->GetTotPoints());
147 Array<OneD, NekDouble> c1 = Array<OneD, NekDouble>(hexExp->GetTotPoints());
148 Array<OneD, NekDouble> c2 = Array<OneD, NekDouble>(hexExp->GetTotPoints());
149 hexExp->GetCoords(c0, c1, c2);
150 std::shared_ptr<StdRegions::StdHexExp> stdHex =
151 std::dynamic_pointer_cast<StdRegions::StdHexExp>(hexExp);
152 stdHex->GetCoords(c0, c1, c2);
153 double epsilon = 1.0e-8;
154 BOOST_CHECK_CLOSE(c0[0], -1.0, epsilon);
155 BOOST_CHECK_CLOSE(c0[1], -0.76505532392946474, epsilon);
156 BOOST_CHECK_CLOSE(c0[2], -0.28523151648064510, epsilon);
157 BOOST_CHECK_CLOSE(c0[3], 0.28523151648064510, epsilon);
158 BOOST_CHECK_CLOSE(c0[4], 0.76505532392946474, epsilon);
159 BOOST_CHECK_CLOSE(c0[5], 1.0, epsilon);
160}
161
162BOOST_AUTO_TEST_CASE(TestScaledAndTranslatedHexExp)
163{
165 new SpatialDomains::PointGeom(3u, 0u, 0.0, 0.0, 0.0));
167 new SpatialDomains::PointGeom(3u, 1u, 0.5, 0.0, 0.0));
169 new SpatialDomains::PointGeom(3u, 2u, 0.5, 0.5, 0.0));
171 new SpatialDomains::PointGeom(3u, 3u, 0.0, 0.5, 0.0));
173 new SpatialDomains::PointGeom(3u, 4u, 0.0, 0.0, 0.5));
175 new SpatialDomains::PointGeom(3u, 5u, 0.5, 0.0, 0.5));
177 new SpatialDomains::PointGeom(3u, 6u, 0.5, 0.5, 0.5));
179 new SpatialDomains::PointGeom(3u, 7u, 0.0, 0.5, 0.5));
180
182 CreateHex(v0, v1, v2, v3, v4, v5, v6, v7);
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);
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} // namespace HexExpTests
212} // namespace Nektar
Describes the specification for a Basis.
Definition: Basis.h:47
Defines a specification for a set of points.
Definition: Points.h:55
static std::shared_ptr< DataType > AllocateSharedPtr(const Args &...args)
Allocate a shared pointer from the memory pool.
static const int kNedges
Definition: QuadGeom.h:76
SpatialDomains::HexGeomSharedPtr CreateHex(SpatialDomains::PointGeomSharedPtr v0, SpatialDomains::PointGeomSharedPtr v1, SpatialDomains::PointGeomSharedPtr v2, SpatialDomains::PointGeomSharedPtr v3, SpatialDomains::PointGeomSharedPtr v4, SpatialDomains::PointGeomSharedPtr v5, SpatialDomains::PointGeomSharedPtr v6, SpatialDomains::PointGeomSharedPtr v7)
SpatialDomains::SegGeomSharedPtr CreateSegGeom(unsigned int id, SpatialDomains::PointGeomSharedPtr v0, SpatialDomains::PointGeomSharedPtr v1)
BOOST_AUTO_TEST_CASE(TestHexExpThatIsStdRegion)
@ eGaussLobattoLegendre
1D Gauss-Lobatto-Legendre quadrature points
Definition: PointsType.h:53
@ eModified_A
Principle Modified Functions .
Definition: BasisType.h:50
std::shared_ptr< HexExp > HexExpSharedPtr
Definition: HexExp.h:260
std::shared_ptr< QuadGeom > QuadGeomSharedPtr
Definition: HexGeom.h:47
std::shared_ptr< HexGeom > HexGeomSharedPtr
Definition: HexGeom.h:87
std::shared_ptr< SegGeom > SegGeomSharedPtr
Definition: Geometry2D.h:62
std::shared_ptr< PointGeom > PointGeomSharedPtr
Definition: Geometry.h:60
The above copyright notice and this permission notice shall be included.
Definition: CoupledSolver.h:2