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
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
SWIFT
SWIFTsim
Commits
4c662d6f
Commit
4c662d6f
authored
9 years ago
by
Matthieu Schaller
Browse files
Options
Downloads
Patches
Plain Diff
Unit test now verifies that all particle properties are correct.
parent
e66cca07
No related branches found
No related tags found
1 merge request
!46
Blue gene HDF5 i/o fixes
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/error.h
+3
-0
3 additions, 0 deletions
src/error.h
tests/makeInput.py
+1
-2
1 addition, 2 deletions
tests/makeInput.py
tests/testReading.c
+68
-5
68 additions, 5 deletions
tests/testReading.c
with
72 additions
and
7 deletions
src/error.h
+
3
−
0
View file @
4c662d6f
...
...
@@ -61,6 +61,8 @@ extern int engine_rank;
#define message(s, ...) printf("%s: " s "\n", __FUNCTION__, ##__VA_ARGS__)
#endif
/**
* @brief Assertion macro compatible with MPI
*
...
...
@@ -72,6 +74,7 @@ extern int engine_rank;
if (!(expr)) { \
fprintf(stderr, "[%03i] %s:%s():%i: FAILED ASSERTION: " #expr " \n", \
engine_rank, __FILE__, __FUNCTION__, __LINE__); \
fflush(stderr); \
MPI_Abort(MPI_COMM_WORLD, -1); \
} \
}
...
...
This diff is collapsed.
Click to expand it.
tests/makeInput.py
+
1
−
2
View file @
4c662d6f
###############################################################################
# This file is part of SWIFT.
# Coypright (c) 2013 Pedro Gonnet (pedro.gonnet@durham.ac.uk),
# Matthieu Schaller (matthieu.schaller@durham.ac.uk)
# Coypright (c) 2015 Matthieu Schaller (matthieu.schaller@durham.ac.uk)
#
# 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
...
...
This diff is collapsed.
Click to expand it.
tests/testReading.c
+
68
−
5
View file @
4c662d6f
...
...
@@ -18,15 +18,78 @@
******************************************************************************/
#include
"swift.h"
#include
<stdlib.h>
int
main
()
{
int
N
=
-
1
,
periodic
=
1
;
double
dim
[
3
]
=
{
1
.
0
,
1
.
0
,
1
.
0
};
int
N
=
-
1
,
periodic
=
-
1
;
int
i
,
j
,
k
,
n
;
double
dim
[
3
];
struct
part
*
parts
=
NULL
;
char
*
ICfileName
=
"input.hdf5"
;
read_ic_single
(
ICfileName
,
dim
,
&
parts
,
&
N
,
&
periodic
);
/* Properties of the ICs */
const
double
boxSize
=
1
.;
const
int
L
=
4
;
const
double
rho
=
2
.;
const
double
P
=
1
.;
const
double
gamma
=
5
.
/
3
.;
/* Read data */
read_ic_single
(
"input.hdf5"
,
dim
,
&
parts
,
&
N
,
&
periodic
);
/* Check global properties read are correct */
assert
(
dim
[
0
]
==
boxSize
);
assert
(
dim
[
1
]
==
boxSize
);
assert
(
dim
[
2
]
==
boxSize
);
assert
(
N
==
L
*
L
*
L
);
assert
(
periodic
==
1
);
/* Check particles */
for
(
n
=
0
;
n
<
N
;
++
n
)
{
/* Check that indices are in a reasonable range */
unsigned
long
long
index
=
parts
[
n
].
id
;
assert
(
index
<
N
);
/* Check masses */
float
mass
=
parts
[
n
].
mass
;
float
correct_mass
=
boxSize
*
boxSize
*
boxSize
*
rho
/
N
;
assert
(
mass
==
correct_mass
);
/* Check smoothing length */
float
h
=
parts
[
n
].
h
;
float
correct_h
=
2
.
251
*
boxSize
/
L
;
assert
(
h
==
correct_h
);
/* Check internal energy */
float
u
=
parts
[
n
].
u
;
float
correct_u
=
P
/
((
gamma
-
1
.)
*
rho
);
assert
(
u
==
correct_u
);
/* Check velocity */
assert
(
parts
[
n
].
v
[
0
]
==
0
.);
assert
(
parts
[
n
].
v
[
1
]
==
0
.);
assert
(
parts
[
n
].
v
[
2
]
==
0
.);
/* Check positions */
k
=
index
%
4
;
j
=
((
index
-
k
)
/
4
)
%
4
;
i
=
(
index
-
k
-
4
*
j
)
/
16
;
double
correct_x
=
i
*
boxSize
/
L
+
boxSize
/
(
2
*
L
);
double
correct_y
=
j
*
boxSize
/
L
+
boxSize
/
(
2
*
L
);
double
correct_z
=
k
*
boxSize
/
L
+
boxSize
/
(
2
*
L
);
assert
(
parts
[
n
].
x
[
0
]
==
correct_x
);
assert
(
parts
[
n
].
x
[
1
]
==
correct_y
);
assert
(
parts
[
n
].
x
[
2
]
==
correct_z
);
/* Check accelerations */
assert
(
parts
[
n
].
a
[
0
]
==
0
.);
assert
(
parts
[
n
].
a
[
1
]
==
0
.);
assert
(
parts
[
n
].
a
[
2
]
==
0
.);
}
/* Clean-up */
free
(
parts
);
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
register
or
sign in
to comment