Nektar++
Loading...
Searching...
No Matches
TestInvBwdTrans.cpp
Go to the documentation of this file.
1///////////////////////////////////////////////////////////////////////////////
2//
3// File: TestInvBwdTrans.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 OR
24// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
25// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
26// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
27// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
28// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
29// SOFTWARE.
30//
31// Description: Unit tests for inverse backward transform matrices.
32//
33///////////////////////////////////////////////////////////////////////////////
34
37#include <boost/test/tools/floating_point_comparison.hpp>
38#include <boost/test/unit_test.hpp>
39#include <cmath>
40
42{
43
45{
47 exp->DetShapeType(), *exp);
49 exp->DetShapeType(), *exp);
51 exp->DetShapeType(), *exp);
52
53 DNekMatSharedPtr bwd = exp->GetStdMatrix(bwdKey);
54 DNekMatSharedPtr invBwd = exp->GetStdMatrix(invKey);
55 DNekMatSharedPtr invIProd = exp->GetStdMatrix(invIProdKey);
56
57 BOOST_REQUIRE_EQUAL(bwd->GetRows(), exp->GetTotPoints());
58 BOOST_REQUIRE_EQUAL(bwd->GetColumns(), exp->GetNcoeffs());
59 BOOST_REQUIRE_EQUAL(invBwd->GetRows(), exp->GetNcoeffs());
60 BOOST_REQUIRE_EQUAL(invBwd->GetColumns(), exp->GetTotPoints());
61 BOOST_REQUIRE_EQUAL(invIProd->GetRows(), exp->GetTotPoints());
62 BOOST_REQUIRE_EQUAL(invIProd->GetColumns(), exp->GetNcoeffs());
63
64 const NekDouble epsilon = 1.0e-8;
65 DNekMat identity = (*invBwd) * (*bwd);
66
67 for (unsigned int i = 0; i < identity.GetRows(); ++i)
68 {
69 for (unsigned int j = 0; j < identity.GetColumns(); ++j)
70 {
71 const NekDouble expected = i == j ? 1.0 : 0.0;
72 BOOST_CHECK_SMALL(std::abs(*identity(i, j) - expected), epsilon);
73 }
74 }
75
76 for (unsigned int i = 0; i < invBwd->GetRows(); ++i)
77 {
78 for (unsigned int j = 0; j < invBwd->GetColumns(); ++j)
79 {
80 BOOST_CHECK_SMALL(std::abs(*(*invIProd)(j, i) - *(*invBwd)(i, j)),
81 epsilon);
82 }
83 }
84}
85
86BOOST_AUTO_TEST_CASE(TestQuadInvBwdTransPseudoInverse)
87{
88 using namespace LibUtilities;
89
90 const PointsKey pointsKey(6, eGaussLobattoLegendre);
91 const BasisKey basisKey(eModified_A, 4, pointsKey);
92
95 basisKey);
97}
98
99BOOST_AUTO_TEST_CASE(TestHexInvBwdTransPseudoInverse)
100{
101 using namespace LibUtilities;
102
103 const PointsKey pointsKey(5, eGaussLobattoLegendre);
104 const BasisKey basisKey(eModified_A, 3, pointsKey);
105
108 basisKey, basisKey, basisKey);
109 CheckInvBwdTrans(exp);
110}
111} // namespace Nektar::StdRegionsUnitTests
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.
@ eGaussLobattoLegendre
1D Gauss-Lobatto-Legendre quadrature points
Definition PointsType.h:51
@ eModified_A
Principle Modified Functions .
Definition BasisType.h:48
std::shared_ptr< StdExpansion > StdExpansionSharedPtr
void CheckInvBwdTrans(const StdRegions::StdExpansionSharedPtr &exp)
BOOST_AUTO_TEST_CASE(TestQuadInvBwdTransPseudoInverse)
std::shared_ptr< DNekMat > DNekMatSharedPtr