Nektar++
Loading...
Searching...
No Matches
TestGLLSpaced.cpp
Go to the documentation of this file.
1///////////////////////////////////////////////////////////////////////////////
2//
3// File: TestGLLSpaced.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
40#include <boost/test/tools/floating_point_comparison.hpp>
41#include <boost/test/unit_test.hpp>
42
44{
45
46BOOST_AUTO_TEST_CASE(TestTriExpInterpGLLSpaced)
47{
48 using namespace LibUtilities;
49
50 PointsType PointsTypeDir1 = eGaussLobattoLegendre;
51 PointsType PointsTypeDir2 = eGaussRadauMAlpha1Beta0;
52 BasisType basisTypeDir1 = eModified_A;
53 BasisType basisTypeDir2 = eModified_B;
54
55 unsigned int numPoints = 8;
56 unsigned int numEQ = 6;
57
58 const PointsKey PointsKeyDir1(numPoints, PointsTypeDir1);
59 const BasisKey basisKeyDir1(basisTypeDir1, numEQ, PointsKeyDir1);
60 const PointsKey PointsKeyDir2(numPoints - 1, PointsTypeDir2);
61 const BasisKey basisKeyDir2(basisTypeDir2, numEQ, PointsKeyDir2);
62
65 basisKeyDir1, basisKeyDir2);
66
67 // define an equispaced Tri points
68 PointsType PointsTypeEq = eNodalTriElec;
69
72 basisKeyDir1, basisKeyDir2, PointsTypeEq);
73
74 Array<OneD, NekDouble> c0 = Array<OneD, NekDouble>(Exp->GetTotPoints());
75 Array<OneD, NekDouble> c1 = Array<OneD, NekDouble>(Exp->GetTotPoints());
76 Array<OneD, NekDouble> c2 = Array<OneD, NekDouble>(Exp->GetTotPoints());
77 Exp->GetCoords(c0, c1, c2);
78
79 // Get coordinates at equispaced points
80 Array<OneD, NekDouble> ceq0 = Array<OneD, NekDouble>(Exp->GetTotPoints());
81 Array<OneD, NekDouble> ceq1 = Array<OneD, NekDouble>(Exp->GetTotPoints());
82 Array<OneD, NekDouble> ceq2 = Array<OneD, NekDouble>(Exp->GetTotPoints());
83 ExpEq->GetCoords(ceq0, ceq1, ceq2);
84
85 Array<OneD, NekDouble> out = Array<OneD, NekDouble>(Exp->GetNcoeffs());
86 Array<OneD, NekDouble> outeq = Array<OneD, NekDouble>(Exp->GetNcoeffs());
87
88 double epsilon = 1.0e-8;
89
90 Array<OneD, int> sorted;
92
93 // compare x-coordinates
94 Exp->PhysInterpToGLL(c0, out, numEQ);
95 ExpEq->FwdTrans(ceq0, outeq);
96 for (int i = 0; i < Exp->GetNcoeffs(); ++i)
97 {
98 BOOST_CHECK_CLOSE(out[i], outeq[sorted[i]], epsilon);
99 }
100
101 // compare y-coordinates
102 Exp->PhysInterpToGLL(c1, out, numEQ);
103 ExpEq->FwdTrans(ceq1, outeq);
104 for (int i = 0; i < Exp->GetNcoeffs(); ++i)
105 {
106 BOOST_CHECK_CLOSE(out[i], outeq[sorted[i]], epsilon);
107 }
108}
109
110BOOST_AUTO_TEST_CASE(TestTetpInterpPhysToGLLSpaced)
111{
112 using namespace LibUtilities;
113
114 PointsType PointsTypeDir1 = eGaussLobattoLegendre;
115 PointsType PointsTypeDir2 = eGaussRadauMAlpha1Beta0;
116 PointsType PointsTypeDir3 = eGaussRadauMAlpha2Beta0;
117 BasisType basisTypeDir1 = eModified_A;
118 BasisType basisTypeDir2 = eModified_B;
119 BasisType basisTypeDir3 = eModified_C;
120
121 unsigned int numPoints = 10;
122 unsigned int numEQ = 8;
123
124 // Set up standard element.
125 const PointsKey PointsKeyDir1(numPoints, PointsTypeDir1);
126 const PointsKey PointsKeyDir2(numPoints - 1, PointsTypeDir2);
127 const PointsKey PointsKeyDir3(numPoints - 1, PointsTypeDir3);
128 const BasisKey basisKeyDir2(basisTypeDir2, numEQ, PointsKeyDir2);
129 const BasisKey basisKeyDir1(basisTypeDir1, numEQ, PointsKeyDir1);
130 const BasisKey basisKeyDir3(basisTypeDir3, numEQ, PointsKeyDir3);
131
134 basisKeyDir1, basisKeyDir2, basisKeyDir3);
135
136 // define an equispaced Tet points
137 PointsType PointsTypeEq = eNodalTetElec;
138
141 basisKeyDir1, basisKeyDir2, basisKeyDir3, PointsTypeEq);
142
143 // Get coordinates at quadrature points
144 Array<OneD, NekDouble> c0 = Array<OneD, NekDouble>(Exp->GetTotPoints());
145 Array<OneD, NekDouble> c1 = Array<OneD, NekDouble>(Exp->GetTotPoints());
146 Array<OneD, NekDouble> c2 = Array<OneD, NekDouble>(Exp->GetTotPoints());
147 Exp->GetCoords(c0, c1, c2);
148
149 // Get coordinates at equispaced points
150 Array<OneD, NekDouble> ceq0 = Array<OneD, NekDouble>(Exp->GetTotPoints());
151 Array<OneD, NekDouble> ceq1 = Array<OneD, NekDouble>(Exp->GetTotPoints());
152 Array<OneD, NekDouble> ceq2 = Array<OneD, NekDouble>(Exp->GetTotPoints());
153 ExpEq->GetCoords(ceq0, ceq1, ceq2);
154
155 Array<OneD, NekDouble> out = Array<OneD, NekDouble>(Exp->GetNcoeffs());
156 Array<OneD, NekDouble> outeq = Array<OneD, NekDouble>(Exp->GetNcoeffs());
157 double epsilon = 1.0e-8;
158
159 Array<OneD, int> sorted;
161
162 // compare x-coordinates
163 Exp->PhysInterpToGLL(c0, out, numEQ);
164 ExpEq->FwdTrans(ceq0, outeq);
165 for (int i = 0; i < Exp->GetNcoeffs(); ++i)
166 {
167 BOOST_CHECK_CLOSE(out[i], outeq[sorted[i]], epsilon);
168 }
169
170 // compare y-coordinates
171 Exp->PhysInterpToGLL(c1, out, numEQ);
172 ExpEq->FwdTrans(ceq1, outeq);
173 for (int i = 0; i < Exp->GetNcoeffs(); ++i)
174 {
175 BOOST_CHECK_CLOSE(out[i], outeq[sorted[i]], epsilon);
176 }
177
178 // compare z-coordinates
179 Exp->PhysInterpToGLL(c2, out, numEQ);
180 ExpEq->FwdTrans(ceq2, outeq);
181 for (int i = 0; i < Exp->GetNcoeffs(); ++i)
182 {
183 BOOST_CHECK_CLOSE(out[i], outeq[sorted[i]], epsilon);
184 }
185}
186
187BOOST_AUTO_TEST_CASE(TestPrismpInterpPhysToGLLSpaced)
188{
189 using namespace LibUtilities;
190
191 PointsType PointsTypeDir1 = eGaussLobattoLegendre;
192 PointsType PointsTypeDir2 = eGaussLobattoLegendre;
193 PointsType PointsTypeDir3 = eGaussRadauMAlpha1Beta0;
194 BasisType basisTypeDir1 = eModified_A;
195 BasisType basisTypeDir2 = eModified_A;
196 BasisType basisTypeDir3 = eModified_B;
197
198 unsigned int numPoints = 5;
199 unsigned int numPt = 4;
200
201 // Set up standard element.
202 const PointsKey PointsKeyDir1(numPoints, PointsTypeDir1);
203 const PointsKey PointsKeyDir2(numPoints, PointsTypeDir2);
204 const PointsKey PointsKeyDir3(numPoints - 1, PointsTypeDir3);
205 const BasisKey basisKeyDir1(basisTypeDir1, numPt, PointsKeyDir1);
206 const BasisKey basisKeyDir2(basisTypeDir2, numPt, PointsKeyDir2);
207 const BasisKey basisKeyDir3(basisTypeDir3, numPt, PointsKeyDir3);
208
211 basisKeyDir1, basisKeyDir2, basisKeyDir3);
212
213 // define Prism points
215
218 basisKeyDir1, basisKeyDir2, basisKeyDir3, PointsType);
219
220 // Get coordinates at quadrature points
221 Array<OneD, NekDouble> c0 = Array<OneD, NekDouble>(Exp->GetTotPoints());
222 Array<OneD, NekDouble> c1 = Array<OneD, NekDouble>(Exp->GetTotPoints());
223 Array<OneD, NekDouble> c2 = Array<OneD, NekDouble>(Exp->GetTotPoints());
224 Exp->GetCoords(c0, c1, c2);
225
226 // Get coordinates at gll points
227 Array<OneD, NekDouble> cgll0 = Array<OneD, NekDouble>(Exp->GetTotPoints());
228 Array<OneD, NekDouble> cgll1 = Array<OneD, NekDouble>(Exp->GetTotPoints());
229 Array<OneD, NekDouble> cgll2 = Array<OneD, NekDouble>(Exp->GetTotPoints());
230 ExpGll->GetCoords(cgll0, cgll1, cgll2);
231
232 Array<OneD, NekDouble> out = Array<OneD, NekDouble>(Exp->GetNcoeffs());
233 Array<OneD, NekDouble> outgll = Array<OneD, NekDouble>(Exp->GetNcoeffs());
234 double epsilon = 1.0e-8;
235
236 Array<OneD, int> sorted;
238
239 // compare x-coordinates
240 Exp->PhysInterpToGLL(c0, out, numPt);
241 ExpGll->FwdTrans(cgll0, outgll);
242 for (int i = 0; i < Exp->GetNcoeffs(); ++i)
243 {
244 BOOST_CHECK_CLOSE(out[i], outgll[sorted[i]], epsilon);
245 }
246
247 // compare y-coordinates
248 Exp->PhysInterpToGLL(c1, out, numPt);
249 ExpGll->FwdTrans(cgll1, outgll);
250 for (int i = 0; i < Exp->GetNcoeffs(); ++i)
251 {
252 BOOST_CHECK_CLOSE(out[i], outgll[sorted[i]], epsilon);
253 }
254
255 // compare z-coordinates
256 Exp->PhysInterpToGLL(c2, out, numPt);
257 ExpGll->FwdTrans(cgll2, outgll);
258 for (int i = 0; i < Exp->GetNcoeffs(); ++i)
259 {
260 BOOST_CHECK_CLOSE(out[i], outgll[sorted[i]], epsilon);
261 }
262}
263
264} // namespace Nektar::QuadEquiSpaced
Describes the specification for a Basis.
Definition Basis.h:45
static void CartesianOrdering(const int nq, Array< OneD, int > &sorted)
Definition NodalUtil.h:363
static void CartesianOrdering(const int nq, Array< OneD, int > &sorted)
Definition NodalUtil.h:256
static void CartesianOrdering(const int nq, Array< OneD, int > &sorted)
Definition NodalUtil.h:178
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.
@ eNodalTriElec
2D Nodal Electrostatic Points on a Triangle
Definition PointsType.h:81
@ eGaussLobattoLegendre
1D Gauss-Lobatto-Legendre quadrature points
Definition PointsType.h:51
@ eNodalPrismElec
3D electrostatically spaced points on a Prism
Definition PointsType.h:87
@ eNodalTetElec
3D Nodal Electrostatic Points on a Tetrahedron
Definition PointsType.h:85
@ eModified_B
Principle Modified Functions .
Definition BasisType.h:49
@ eModified_C
Principle Modified Functions .
Definition BasisType.h:50
@ eModified_A
Principle Modified Functions .
Definition BasisType.h:48
BOOST_AUTO_TEST_CASE(TestQuadExpInterpPhysToEquiSpaced)
std::shared_ptr< StdPrismExp > StdPrismExpSharedPtr
std::shared_ptr< StdTetExp > StdTetExpSharedPtr
Definition StdTetExp.h:187
std::shared_ptr< StdTriExp > StdTriExpSharedPtr
Definition StdTriExp.h:177