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
da36252f
Commit
da36252f
authored
7 years ago
by
Matthieu Schaller
Browse files
Options
Downloads
Patches
Plain Diff
Updated the unit tests with the new function signature.
parent
f9ad06f3
Branches
Branches containing commit
Tags
Tags containing commit
1 merge request
!509
Cosmological time integration
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
tests/test27cells.c
+8
-4
8 additions, 4 deletions
tests/test27cells.c
tests/testActivePair.c
+10
-6
10 additions, 6 deletions
tests/testActivePair.c
tests/testPeriodicBC.c
+8
-4
8 additions, 4 deletions
tests/testPeriodicBC.c
tests/testSymmetry.c
+10
-6
10 additions, 6 deletions
tests/testSymmetry.c
with
36 additions
and
20 deletions
tests/test27cells.c
+
8
−
4
View file @
da36252f
...
...
@@ -225,9 +225,9 @@ void zero_particle_fields(struct cell *c) {
/**
* @brief Ends the loop by adding the appropriate coefficients
*/
void
end_calculation
(
struct
cell
*
c
)
{
void
end_calculation
(
struct
cell
*
c
,
const
struct
cosmology
*
cosmo
)
{
for
(
int
pid
=
0
;
pid
<
c
->
count
;
pid
++
)
{
hydro_end_density
(
&
c
->
parts
[
pid
]);
hydro_end_density
(
&
c
->
parts
[
pid
]
,
cosmo
);
/* Recover the common "Neighbour number" definition */
c
->
parts
[
pid
].
density
.
wcount
*=
pow_dimension
(
c
->
parts
[
pid
].
h
);
...
...
@@ -447,6 +447,10 @@ int main(int argc, char *argv[]) {
engine
.
hydro_properties
=
&
hp
;
engine
.
nodeID
=
NODE_ID
;
struct
cosmology
cosmo
;
cosmology_init_no_cosmo
(
&
cosmo
);
engine
.
cosmology
=
&
cosmo
;
struct
runner
runner
;
runner
.
e
=
&
engine
;
...
...
@@ -536,7 +540,7 @@ int main(int argc, char *argv[]) {
time
+=
toc
-
tic
;
/* Let's get physical ! */
end_calculation
(
main_cell
);
end_calculation
(
main_cell
,
&
cosmo
);
/* Dump if necessary */
if
(
i
%
50
==
0
)
{
...
...
@@ -584,7 +588,7 @@ int main(int argc, char *argv[]) {
const
ticks
toc
=
getticks
();
/* Let's get physical ! */
end_calculation
(
main_cell
);
end_calculation
(
main_cell
,
&
cosmo
);
/* Dump */
sprintf
(
outputFileName
,
"brute_force_27_%s.dat"
,
outputFileNameExtension
);
...
...
This diff is collapsed.
Click to expand it.
tests/testActivePair.c
+
10
−
6
View file @
da36252f
...
...
@@ -179,9 +179,9 @@ void zero_particle_fields(struct cell *c) {
/**
* @brief Ends the loop by adding the appropriate coefficients
*/
void
end_calculation
(
struct
cell
*
c
)
{
void
end_calculation
(
struct
cell
*
c
,
const
struct
cosmology
*
cosmo
)
{
for
(
int
pid
=
0
;
pid
<
c
->
count
;
pid
++
)
{
hydro_end_density
(
&
c
->
parts
[
pid
]);
hydro_end_density
(
&
c
->
parts
[
pid
]
,
cosmo
);
/* Recover the common "Neighbour number" definition */
c
->
parts
[
pid
].
density
.
wcount
*=
pow_dimension
(
c
->
parts
[
pid
].
h
);
...
...
@@ -246,8 +246,8 @@ void test_pair_interactions(struct runner *runner, struct cell **ci,
vec_interaction
(
runner
,
*
ci
,
*
cj
);
/* Let's get physical ! */
end_calculation
(
*
ci
);
end_calculation
(
*
cj
);
end_calculation
(
*
ci
,
runner
->
e
->
cosmology
);
end_calculation
(
*
cj
,
runner
->
e
->
cosmology
);
/* Dump if necessary */
dump_particle_fields
(
swiftOutputFileName
,
*
ci
,
*
cj
);
...
...
@@ -262,8 +262,8 @@ void test_pair_interactions(struct runner *runner, struct cell **ci,
serial_interaction
(
runner
,
*
ci
,
*
cj
);
/* Let's get physical ! */
end_calculation
(
*
ci
);
end_calculation
(
*
cj
);
end_calculation
(
*
ci
,
runner
->
e
->
cosmology
);
end_calculation
(
*
cj
,
runner
->
e
->
cosmology
);
dump_particle_fields
(
bruteForceOutputFileName
,
*
ci
,
*
cj
);
}
...
...
@@ -425,6 +425,7 @@ int main(int argc, char *argv[]) {
double
perturbation
=
0
.
1
,
h_pert
=
1
.
1
;
struct
space
space
;
struct
engine
engine
;
struct
cosmology
cosmo
;
struct
runner
*
runner
;
char
c
;
static
long
long
partId
=
0
;
...
...
@@ -507,6 +508,9 @@ int main(int argc, char *argv[]) {
engine
.
max_active_bin
=
num_time_bins
;
engine
.
nodeID
=
NODE_ID
;
cosmology_init_no_cosmo
(
&
cosmo
);
engine
.
cosmology
=
&
cosmo
;
if
(
posix_memalign
((
void
**
)
&
runner
,
SWIFT_STRUCT_ALIGNMENT
,
sizeof
(
struct
runner
))
!=
0
)
{
error
(
"couldn't allocate runner"
);
...
...
This diff is collapsed.
Click to expand it.
tests/testPeriodicBC.c
+
8
−
4
View file @
da36252f
...
...
@@ -204,9 +204,9 @@ void zero_particle_fields(struct cell *c) {
/**
* @brief Ends the loop by adding the appropriate coefficients
*/
void
end_calculation
(
struct
cell
*
c
)
{
void
end_calculation
(
struct
cell
*
c
,
const
struct
cosmology
*
cosmo
)
{
for
(
int
pid
=
0
;
pid
<
c
->
count
;
pid
++
)
{
hydro_end_density
(
&
c
->
parts
[
pid
]);
hydro_end_density
(
&
c
->
parts
[
pid
]
,
cosmo
);
}
}
...
...
@@ -332,7 +332,7 @@ void test_boundary_conditions(struct cell **cells, struct runner runner,
#endif
/* Let's get physical ! */
end_calculation
(
main_cell
);
end_calculation
(
main_cell
,
runner
.
e
->
cosmology
);
/* Dump particles from the main cell. */
dump_particle_fields
(
swiftOutputFileName
,
main_cell
,
loc_i
,
loc_j
,
loc_k
);
...
...
@@ -370,7 +370,7 @@ void test_boundary_conditions(struct cell **cells, struct runner runner,
#endif
/* Let's get physical ! */
end_calculation
(
main_cell
);
end_calculation
(
main_cell
,
runner
.
e
->
cosmology
);
/* Dump */
dump_particle_fields
(
bruteForceOutputFileName
,
main_cell
,
loc_i
,
loc_j
,
...
...
@@ -493,6 +493,10 @@ int main(int argc, char *argv[]) {
struct
runner
runner
;
runner
.
e
=
&
engine
;
struct
cosmology
cosmo
;
cosmology_init_no_cosmo
(
&
cosmo
);
engine
.
cosmology
=
&
cosmo
;
/* Construct some cells */
struct
cell
*
cells
[
dim
*
dim
*
dim
];
static
long
long
partId
=
0
;
...
...
This diff is collapsed.
Click to expand it.
tests/testSymmetry.c
+
10
−
6
View file @
da36252f
...
...
@@ -40,6 +40,10 @@ int main(int argc, char *argv[]) {
/* voronoi_set_box(box_anchor, box_side);*/
#endif
/* Start with some values for the cosmological paramters */
const
float
a
=
(
float
)
random_uniform
(
0
.
8
,
1
.);
const
float
H
=
0
.
f
;
/* Create two random particles (don't do this at home !) */
struct
part
pi
,
pj
;
for
(
size_t
i
=
0
;
i
<
sizeof
(
struct
part
)
/
sizeof
(
float
);
++
i
)
{
...
...
@@ -136,14 +140,14 @@ int main(int argc, char *argv[]) {
/* --- Test the density loop --- */
/* Call the symmetric version */
runner_iact_density
(
r2
,
dx
,
pi
.
h
,
pj
.
h
,
&
pi
,
&
pj
);
runner_iact_density
(
r2
,
dx
,
pi
.
h
,
pj
.
h
,
&
pi
,
&
pj
,
a
,
H
);
/* Call the non-symmetric version */
runner_iact_nonsym_density
(
r2
,
dx
,
pi2
.
h
,
pj2
.
h
,
&
pi2
,
&
pj2
);
runner_iact_nonsym_density
(
r2
,
dx
,
pi2
.
h
,
pj2
.
h
,
&
pi2
,
&
pj2
,
a
,
H
);
dx
[
0
]
=
-
dx
[
0
];
dx
[
1
]
=
-
dx
[
1
];
dx
[
2
]
=
-
dx
[
2
];
runner_iact_nonsym_density
(
r2
,
dx
,
pj2
.
h
,
pi2
.
h
,
&
pj2
,
&
pi2
);
runner_iact_nonsym_density
(
r2
,
dx
,
pj2
.
h
,
pi2
.
h
,
&
pj2
,
&
pi2
,
a
,
H
);
/* Check that the particles are the same */
i_ok
=
memcmp
(
&
pi
,
&
pi2
,
sizeof
(
struct
part
));
...
...
@@ -155,14 +159,14 @@ int main(int argc, char *argv[]) {
/* --- Test the force loop --- */
/* Call the symmetric version */
runner_iact_force
(
r2
,
dx
,
pi
.
h
,
pj
.
h
,
&
pi
,
&
pj
);
runner_iact_force
(
r2
,
dx
,
pi
.
h
,
pj
.
h
,
&
pi
,
&
pj
,
a
,
H
);
/* Call the non-symmetric version */
runner_iact_nonsym_force
(
r2
,
dx
,
pi2
.
h
,
pj2
.
h
,
&
pi2
,
&
pj2
);
runner_iact_nonsym_force
(
r2
,
dx
,
pi2
.
h
,
pj2
.
h
,
&
pi2
,
&
pj2
,
a
,
H
);
dx
[
0
]
=
-
dx
[
0
];
dx
[
1
]
=
-
dx
[
1
];
dx
[
2
]
=
-
dx
[
2
];
runner_iact_nonsym_force
(
r2
,
dx
,
pj2
.
h
,
pi2
.
h
,
&
pj2
,
&
pi2
);
runner_iact_nonsym_force
(
r2
,
dx
,
pj2
.
h
,
pi2
.
h
,
&
pj2
,
&
pi2
,
a
,
H
);
/* Check that the particles are the same */
#if defined(GIZMO_SPH)
...
...
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