Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
SWIFTsim
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
SWIFT
SWIFTsim
Commits
9313f2ed
Commit
9313f2ed
authored
Aug 9, 2016
by
Bert Vandenbroucke
Browse files
Options
Downloads
Patches
Plain Diff
Added unit test for TRRS Riemann solver.
parent
c99f0782
No related branches found
No related tags found
1 merge request
!223
Merge Gizmo-SPH into the master branch
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
.gitignore
+1
-0
1 addition, 0 deletions
.gitignore
tests/Makefile.am
+4
-2
4 additions, 2 deletions
tests/Makefile.am
tests/testRiemannExact.c
+1
-1
1 addition, 1 deletion
tests/testRiemannExact.c
tests/testRiemannTRRS.c
+223
-0
223 additions, 0 deletions
tests/testRiemannTRRS.c
with
229 additions
and
3 deletions
.gitignore
+
1
−
0
View file @
9313f2ed
...
@@ -72,6 +72,7 @@ tests/testParser.sh
...
@@ -72,6 +72,7 @@ tests/testParser.sh
tests/testReading.sh
tests/testReading.sh
tests/testAdiabaticIndex
tests/testAdiabaticIndex
tests/testRiemannExact
tests/testRiemannExact
tests/testRiemannTRRS
theory/latex/swift.pdf
theory/latex/swift.pdf
theory/kernel/kernels.pdf
theory/kernel/kernels.pdf
...
...
...
...
This diff is collapsed.
Click to expand it.
tests/Makefile.am
+
4
−
2
View file @
9313f2ed
...
@@ -24,13 +24,13 @@ AM_LDFLAGS = ../src/.libs/libswiftsim.a $(HDF5_LDFLAGS) $(HDF5_LIBS) $(FFTW_LIBS
...
@@ -24,13 +24,13 @@ AM_LDFLAGS = ../src/.libs/libswiftsim.a $(HDF5_LDFLAGS) $(HDF5_LIBS) $(FFTW_LIBS
TESTS
=
testGreetings testMaths testReading.sh testSingle testKernel testSymmetry
\
TESTS
=
testGreetings testMaths testReading.sh testSingle testKernel testSymmetry
\
testPair.sh testPairPerturbed.sh test27cells.sh test27cellsPerturbed.sh
\
testPair.sh testPairPerturbed.sh test27cells.sh test27cellsPerturbed.sh
\
testParser.sh testSPHStep test125cells.sh testKernelGrav testFFT
\
testParser.sh testSPHStep test125cells.sh testKernelGrav testFFT
\
testAdiabaticIndex testRiemannExact
testAdiabaticIndex testRiemannExact
testRiemannTRRS
# List of test programs to compile
# List of test programs to compile
check_PROGRAMS
=
testGreetings testReading testSingle testTimeIntegration
\
check_PROGRAMS
=
testGreetings testReading testSingle testTimeIntegration
\
testSPHStep testPair test27cells test125cells testParser
\
testSPHStep testPair test27cells test125cells testParser
\
testKernel testKernelGrav testFFT testInteractions testMaths testSymmetry
\
testKernel testKernelGrav testFFT testInteractions testMaths testSymmetry
\
testAdiabaticIndex testRiemannExact
testAdiabaticIndex testRiemannExact
testRiemannTRRS
# Sources for the individual programs
# Sources for the individual programs
testGreetings_SOURCES
=
testGreetings.c
testGreetings_SOURCES
=
testGreetings.c
...
@@ -67,6 +67,8 @@ testAdiabaticIndex_SOURCES = testAdiabaticIndex.c
...
@@ -67,6 +67,8 @@ testAdiabaticIndex_SOURCES = testAdiabaticIndex.c
testRiemannExact_SOURCES
=
testRiemannExact.c
testRiemannExact_SOURCES
=
testRiemannExact.c
testRiemannTRRS_SOURCES
=
testRiemannTRRS.c
# Files necessary for distribution
# Files necessary for distribution
EXTRA_DIST
=
testReading.sh makeInput.py testPair.sh testPairPerturbed.sh
\
EXTRA_DIST
=
testReading.sh makeInput.py testPair.sh testPairPerturbed.sh
\
test27cells.sh test27cellsPerturbed.sh tolerance.dat testParser.sh
\
test27cells.sh test27cellsPerturbed.sh tolerance.dat testParser.sh
\
...
...
...
...
This diff is collapsed.
Click to expand it.
tests/testRiemannExact.c
+
1
−
1
View file @
9313f2ed
...
@@ -212,7 +212,7 @@ void check_riemann_exact() {
...
@@ -212,7 +212,7 @@ void check_riemann_exact() {
}
}
/**
/**
* @brief Check
adiabatic index constants and the various
Riemann solver
s
* @brief Check
the exact
Riemann solver
*/
*/
int
main
()
{
int
main
()
{
...
...
...
...
This diff is collapsed.
Click to expand it.
tests/testRiemannTRRS.c
0 → 100644
+
223
−
0
View file @
9313f2ed
/*******************************************************************************
* This file is part of SWIFT.
* Copyright (C) 2016 Bert Vandenbroucke (bert.vandenbroucke@gmail.com).
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published
* by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
******************************************************************************/
#include
"error.h"
#include
"riemann/riemann_trrs.h"
/**
* @brief Check that a and b are consistent (up to some error)
*
* @param a First value
* @param b Second value
* @param s String used to identify this check in messages
*/
void
check_value
(
float
a
,
float
b
,
const
char
*
s
)
{
if
(
fabsf
(
a
-
b
)
/
fabsf
(
a
+
b
)
>
1.e-5
f
&&
fabsf
(
a
-
b
)
>
1.e-5
f
)
{
error
(
"Values are inconsistent: %g %g (%s)!"
,
a
,
b
,
s
);
}
else
{
message
(
"Values are consistent: %g %g (%s)."
,
a
,
b
,
s
);
}
}
struct
riemann_statevector
{
/*! @brief Density */
float
rho
;
/*! @brief Fluid velocity */
float
v
;
/*! @brief Pressure */
float
P
;
};
/**
* @brief Check that the solution to the Riemann problem with given left and
* right state is consistent with the given expected solution
*
* @param WL Left state
* @param WR Right state
* @param Whalf Expected solution
* @param s String used to identify this check in messages
*/
void
check_riemann_solution
(
struct
riemann_statevector
*
WL
,
struct
riemann_statevector
*
WR
,
struct
riemann_statevector
*
Whalf
,
const
char
*
s
)
{
float
WLarr
[
5
],
WRarr
[
5
],
Whalfarr
[
5
],
n_unit
[
3
];
n_unit
[
0
]
=
1
.
0
f
;
n_unit
[
1
]
=
0
.
0
f
;
n_unit
[
2
]
=
0
.
0
f
;
WLarr
[
0
]
=
WL
->
rho
;
WLarr
[
1
]
=
WL
->
v
;
WLarr
[
2
]
=
0
.
0
f
;
WLarr
[
3
]
=
0
.
0
f
;
WLarr
[
4
]
=
WL
->
P
;
WRarr
[
0
]
=
WR
->
rho
;
WRarr
[
1
]
=
WR
->
v
;
WRarr
[
2
]
=
0
.
0
f
;
WRarr
[
3
]
=
0
.
0
f
;
WRarr
[
4
]
=
WR
->
P
;
riemann_solver_solve
(
WLarr
,
WRarr
,
Whalfarr
,
n_unit
);
message
(
"Checking %s..."
,
s
);
check_value
(
Whalfarr
[
0
],
Whalf
->
rho
,
"rho"
);
check_value
(
Whalfarr
[
1
],
Whalf
->
v
,
"v"
);
check_value
(
Whalfarr
[
4
],
Whalf
->
P
,
"P"
);
}
/**
* @brief Check the TRRS Riemann solver on the Toro test problems
*/
void
check_riemann_trrs
()
{
struct
riemann_statevector
WL
,
WR
,
Whalf
;
/* Test 1 */
WL
.
rho
=
1
.
0
f
;
WL
.
v
=
0
.
0
f
;
WL
.
P
=
1
.
0
f
;
WR
.
rho
=
0
.
125
f
;
WR
.
v
=
0
.
0
f
;
WR
.
P
=
0
.
1
f
;
#if defined(HYDRO_GAMMA_5_3)
Whalf
.
rho
=
0
.
481167
f
;
Whalf
.
v
=
0
.
838085
f
;
Whalf
.
P
=
0
.
295456
f
;
#elif defined(HYDRO_GAMMA_4_3)
Whalf
.
rho
=
0
.
41586
f
;
Whalf
.
v
=
0
.
942546
f
;
Whalf
.
P
=
0
.
310406
f
;
#elif defined(HYDRO_GAMMA_2_1)
Whalf
.
rho
=
0
.
53478
f
;
Whalf
.
v
=
0
.
760037
f
;
Whalf
.
P
=
0
.
285989
f
;
#else
#error "Unsupported adiabatic index!"
#endif
check_riemann_solution
(
&
WL
,
&
WR
,
&
Whalf
,
"Test 1"
);
/* Test 2 */
WL
.
rho
=
1
.
0
f
;
WL
.
v
=
-
2
.
0
f
;
WL
.
P
=
0
.
4
f
;
WR
.
rho
=
1
.
0
f
;
WR
.
v
=
2
.
0
f
;
WR
.
P
=
0
.
4
f
;
#if defined(HYDRO_GAMMA_5_3)
Whalf
.
rho
=
0
.
00617
903
f
;
Whalf
.
v
=
0
.
0
f
;
Whalf
.
P
=
8.32249e-5
f
;
#elif defined(HYDRO_GAMMA_4_3)
Whalf
.
rho
=
0
.
0257
933
f
;
Whalf
.
v
=
0
.
0
f
;
Whalf
.
P
=
0
.
00304
838
f
;
#elif defined(HYDRO_GAMMA_2_1)
Whalf
.
rho
=
0
.
013
932
f
;
Whalf
.
v
=
0
.
0
f
;
Whalf
.
P
=
7.76405e-5
f
;
#else
#error "Unsupported adiabatic index!"
#endif
check_riemann_solution
(
&
WL
,
&
WR
,
&
Whalf
,
"Test 2"
);
/* Test 3 */
WL
.
rho
=
1
.
0
f
;
WL
.
v
=
0
.
0
f
;
WL
.
P
=
1000
.
0
f
;
WR
.
rho
=
1
.
0
f
;
WR
.
v
=
0
.
0
f
;
WR
.
P
=
0
.
01
f
;
#if defined(HYDRO_GAMMA_5_3)
Whalf
.
rho
=
0
.
919498
f
;
Whalf
.
v
=
3
.
37884
f
;
Whalf
.
P
=
869
.
464
f
;
#elif defined(HYDRO_GAMMA_4_3)
Whalf
.
rho
=
0
.
941258
f
;
Whalf
.
v
=
2
.
19945
f
;
Whalf
.
P
=
922
.
454
f
;
#elif defined(HYDRO_GAMMA_2_1)
Whalf
.
rho
=
0
.
902032
f
;
Whalf
.
v
=
4
.
49417
f
;
Whalf
.
P
=
813
.
662
f
;
#else
#error "Unsupported adiabatic index!"
#endif
check_riemann_solution
(
&
WL
,
&
WR
,
&
Whalf
,
"Test 3"
);
/* Test 4 */
WL
.
rho
=
1
.
0
f
;
WL
.
v
=
0
.
0
f
;
WL
.
P
=
0
.
01
f
;
WR
.
rho
=
1
.
0
f
;
WR
.
v
=
0
.
0
f
;
WR
.
P
=
100
.
0
f
;
#if defined(HYDRO_GAMMA_5_3)
Whalf
.
rho
=
0
.
857525
f
;
Whalf
.
v
=
-
1
.
93434
f
;
Whalf
.
P
=
77
.
4007
f
;
#elif defined(HYDRO_GAMMA_4_3)
Whalf
.
rho
=
0
.
880649
f
;
Whalf
.
v
=
-
1
.
45215
f
;
Whalf
.
P
=
84
.
4119
f
;
#elif defined(HYDRO_GAMMA_2_1)
Whalf
.
rho
=
0
.
843058
f
;
Whalf
.
v
=
-
2
.
31417
f
;
Whalf
.
P
=
71
.
0747
f
;
#else
#error "Unsupported adiabatic index!"
#endif
check_riemann_solution
(
&
WL
,
&
WR
,
&
Whalf
,
"Test 4"
);
/* Test 5 */
WL
.
rho
=
5
.
99924
f
;
WL
.
v
=
19
.
5975
f
;
WL
.
P
=
460
.
894
f
;
WR
.
rho
=
5
.
99242
f
;
WR
.
v
=
-
6
.
19633
f
;
WR
.
P
=
46
.
0950
f
;
#if defined(HYDRO_GAMMA_5_3)
Whalf
.
rho
=
5
.
99924
f
;
Whalf
.
v
=
19
.
5975
f
;
Whalf
.
P
=
460
.
894
f
;
#elif defined(HYDRO_GAMMA_4_3)
Whalf
.
rho
=
5
.
99924
f
;
Whalf
.
v
=
19
.
5975
f
;
Whalf
.
P
=
460
.
894
f
;
#elif defined(HYDRO_GAMMA_2_1)
Whalf
.
rho
=
5
.
99924
f
;
Whalf
.
v
=
19
.
5975
f
;
Whalf
.
P
=
460
.
894
f
;
#else
#error "Unsupported adiabatic index!"
#endif
check_riemann_solution
(
&
WL
,
&
WR
,
&
Whalf
,
"Test 5"
);
}
/**
* @brief Check the TRRS Riemann solver
*/
int
main
()
{
/* check the TRRS Riemann solver */
check_riemann_trrs
();
return
0
;
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
sign in
to comment