Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
KiT-RT
KiT-RT
Commits
09dd328d
Commit
09dd328d
authored
Dec 14, 2020
by
Steffen Schotthöfer
Browse files
added unit tests for monomial basis
parent
70731b6e
Changes
1
Hide whitespace changes
Inline
Side-by-side
code/tests/test_sphericalBasis.cpp
View file @
09dd328d
...
...
@@ -6,6 +6,7 @@
#include "toolboxes/sphericalmonomials.h"
#include <fstream>
#include <iostream>
#include <sstream>
double
Y0_0
(
double
,
double
)
{
return
sqrt
(
1
/
(
4
*
M_PI
)
);
}
...
...
@@ -39,6 +40,21 @@ TEST_CASE( "test spherical harmonics basis ", "[spherical_harmonics]" ) {
SphericalHarmonics
testBase
(
maxMomentDegree
);
SECTION
(
"Test Global Indexing"
)
{
bool
indexingRight
=
true
;
if
(
testBase
.
GetGlobalIndexBasis
(
0
,
0
)
!=
0
)
indexingRight
=
false
;
if
(
testBase
.
GetGlobalIndexBasis
(
1
,
-
1
)
!=
1
)
indexingRight
=
false
;
if
(
testBase
.
GetGlobalIndexBasis
(
1
,
0
)
!=
2
)
indexingRight
=
false
;
if
(
testBase
.
GetGlobalIndexBasis
(
1
,
1
)
!=
3
)
indexingRight
=
false
;
if
(
testBase
.
GetGlobalIndexBasis
(
2
,
-
2
)
!=
4
)
indexingRight
=
false
;
if
(
testBase
.
GetGlobalIndexBasis
(
2
,
-
1
)
!=
5
)
indexingRight
=
false
;
if
(
testBase
.
GetGlobalIndexBasis
(
2
,
0
)
!=
6
)
indexingRight
=
false
;
if
(
testBase
.
GetGlobalIndexBasis
(
2
,
1
)
!=
7
)
indexingRight
=
false
;
if
(
testBase
.
GetGlobalIndexBasis
(
2
,
2
)
!=
8
)
indexingRight
=
false
;
REQUIRE
(
indexingRight
);
}
SECTION
(
"Test against analytical solution"
)
{
std
::
vector
<
double
>
legendre
;
Vector
moment
;
...
...
@@ -170,12 +186,12 @@ TEST_CASE( "test spherical harmonics basis ", "[spherical_harmonics]" ) {
moment1
=
testBase
.
ComputeSphericalBasis
(
x
,
y
,
z
);
moment2
=
testBase
.
ComputeSphericalBasis
(
-
x
,
-
y
,
-
z
);
int
idx_sys
;
unsigned
idx_sys
;
double
result
=
0.
;
for
(
int
l_idx
=
0
;
l_idx
<=
int
(
maxMomentDegree
);
l_idx
++
)
{
for
(
int
k_idx
=
-
l_idx
;
k_idx
<=
l_idx
;
k_idx
++
)
{
idx_sys
=
testBase
.
GlobalI
d
xBasis
(
l_idx
,
k_idx
);
idx_sys
=
testBase
.
Get
GlobalI
nde
xBasis
(
l_idx
,
k_idx
);
if
(
l_idx
%
2
==
0
)
result
=
moment2
[
idx_sys
]
-
moment1
[
idx_sys
];
...
...
@@ -194,7 +210,7 @@ TEST_CASE( "test spherical harmonics basis ", "[spherical_harmonics]" ) {
Vector
moment1
=
testBase
.
ComputeSphericalBasis
(
0
,
0
);
Vector
moment2
=
testBase
.
ComputeSphericalBasis
(
0
,
0
);
int
idx_sys
;
unsigned
idx_sys
;
double
result
=
0.
;
// // test in polar coordinates
...
...
@@ -206,7 +222,7 @@ TEST_CASE( "test spherical harmonics basis ", "[spherical_harmonics]" ) {
for
(
int
l_idx
=
0
;
l_idx
<=
int
(
maxMomentDegree
);
l_idx
++
)
{
for
(
int
k_idx
=
-
l_idx
;
k_idx
<=
l_idx
;
k_idx
++
)
{
idx_sys
=
testBase
.
GlobalI
d
xBasis
(
l_idx
,
k_idx
);
idx_sys
=
testBase
.
Get
GlobalI
nde
xBasis
(
l_idx
,
k_idx
);
if
(
l_idx
%
2
==
0
)
result
=
moment2
[
idx_sys
]
-
moment1
[
idx_sys
];
...
...
@@ -241,6 +257,30 @@ TEST_CASE( "test spherical monomial basis", "[spherical_monomials]" ) {
unsigned
maxMomentDegree
=
2
;
//==> 6+3+1 basis functions
SphericalMonomials
testBase
(
maxMomentDegree
);
SECTION
(
"Test Global Indexing"
)
{
bool
currDimRight
=
true
;
if
(
testBase
.
GetCurrDegreeSize
(
0
)
!=
1
)
currDimRight
=
false
;
if
(
testBase
.
GetCurrDegreeSize
(
1
)
!=
3
)
currDimRight
=
false
;
if
(
testBase
.
GetCurrDegreeSize
(
2
)
!=
6
)
currDimRight
=
false
;
REQUIRE
(
currDimRight
);
bool
indexingRight
=
true
;
if
(
testBase
.
GetGlobalIndexBasis
(
0
,
0
)
!=
0
)
indexingRight
=
false
;
if
(
testBase
.
GetGlobalIndexBasis
(
1
,
0
)
!=
1
)
indexingRight
=
false
;
if
(
testBase
.
GetGlobalIndexBasis
(
1
,
1
)
!=
2
)
indexingRight
=
false
;
if
(
testBase
.
GetGlobalIndexBasis
(
1
,
2
)
!=
3
)
indexingRight
=
false
;
if
(
testBase
.
GetGlobalIndexBasis
(
2
,
0
)
!=
4
)
indexingRight
=
false
;
if
(
testBase
.
GetGlobalIndexBasis
(
2
,
1
)
!=
5
)
indexingRight
=
false
;
if
(
testBase
.
GetGlobalIndexBasis
(
2
,
2
)
!=
6
)
indexingRight
=
false
;
if
(
testBase
.
GetGlobalIndexBasis
(
2
,
3
)
!=
7
)
indexingRight
=
false
;
if
(
testBase
.
GetGlobalIndexBasis
(
2
,
4
)
!=
8
)
indexingRight
=
false
;
if
(
testBase
.
GetGlobalIndexBasis
(
2
,
5
)
!=
9
)
indexingRight
=
false
;
REQUIRE
(
indexingRight
);
}
SECTION
(
"Test against analytical solution"
)
{
Vector
moment
;
std
::
vector
<
bool
>
validMoment
(
10
,
true
);
...
...
jannick.wolters
@jm2154
mentioned in commit
88ff7659
·
Apr 30, 2021
mentioned in commit
88ff7659
mentioned in commit 88ff7659fafddd522c97585abfdb76a330c1dd39
Toggle commit list
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment