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
d41e1912
Commit
d41e1912
authored
8 years ago
by
James Willis
Browse files
Options
Downloads
Patches
Plain Diff
Added particle perturbation.
Conflicts: tests/test125cells.c
parent
33476206
No related branches found
No related tags found
1 merge request
!341
New addition to the test suite: A perturbed version of the 125 cells case
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
tests/test125cells.c
+41
-8
41 additions, 8 deletions
tests/test125cells.c
with
41 additions
and
8 deletions
tests/test125cells.c
+
41
−
8
View file @
d41e1912
...
...
@@ -30,6 +30,19 @@
/* Local headers. */
#include
"swift.h"
//#if defined(WITH_VECTORIZATION)
//#define DOSELF2 runner_doself2_force_vec
////#define DOPAIR2 runner_dopair2_force_vec
//#define DOSELF2_NAME "runner_doself2_force_vec"
//#define DOPAIR2_NAME "runner_dopair2_force"
//#endif
#ifndef DOSELF2
#define DOSELF2 runner_doself2_force
#define DOSELF2_NAME "runner_doself2_density"
#define DOPAIR2_NAME "runner_dopair2_force"
#endif
enum
velocity_field
{
velocity_zero
,
velocity_const
,
...
...
@@ -240,7 +253,7 @@ void reset_particles(struct cell *c, struct hydro_space *hs,
* @param press The type of pressure field.
*/
struct
cell
*
make_cell
(
size_t
n
,
const
double
offset
[
3
],
double
size
,
double
h
,
double
density
,
long
long
*
partId
,
double
density
,
long
long
*
partId
,
double
pert
,
enum
velocity_field
vel
,
enum
pressure_field
press
)
{
const
size_t
count
=
n
*
n
*
n
;
...
...
@@ -263,9 +276,15 @@ struct cell *make_cell(size_t n, const double offset[3], double size, double h,
for
(
size_t
x
=
0
;
x
<
n
;
++
x
)
{
for
(
size_t
y
=
0
;
y
<
n
;
++
y
)
{
for
(
size_t
z
=
0
;
z
<
n
;
++
z
)
{
part
->
x
[
0
]
=
offset
[
0
]
+
size
*
(
x
+
0
.
5
)
/
(
float
)
n
;
part
->
x
[
1
]
=
offset
[
1
]
+
size
*
(
y
+
0
.
5
)
/
(
float
)
n
;
part
->
x
[
2
]
=
offset
[
2
]
+
size
*
(
z
+
0
.
5
)
/
(
float
)
n
;
part
->
x
[
0
]
=
offset
[
0
]
+
size
*
(
x
+
0
.
5
+
random_uniform
(
-
0
.
5
,
0
.
5
)
*
pert
)
/
(
float
)
n
;
part
->
x
[
1
]
=
offset
[
1
]
+
size
*
(
y
+
0
.
5
+
random_uniform
(
-
0
.
5
,
0
.
5
)
*
pert
)
/
(
float
)
n
;
part
->
x
[
2
]
=
offset
[
2
]
+
size
*
(
z
+
0
.
5
+
random_uniform
(
-
0
.
5
,
0
.
5
)
*
pert
)
/
(
float
)
n
;
part
->
h
=
size
*
h
/
(
float
)
n
;
#if defined(GIZMO_SPH) || defined(SHADOWFAX_SPH)
...
...
@@ -354,8 +373,8 @@ void dump_particle_fields(char *fileName, struct cell *main_cell,
/* Write header */
fprintf
(
file
,
"# %4s %8s %8s %8s %8s %8s %8s %8s %8s %8s %8s %8s %8s %8s %
8
s %
8
s "
"%
8
s %8s %8s %8s %8s
\n
"
,
"# %4s %8s %8s %8s %8s %8s %8s %8s %8s %8s %8s %8s %8s %8s %
13
s %
13
s "
"%
13
s %8s %8s %8s %8s
\n
"
,
"ID"
,
"pos_x"
,
"pos_y"
,
"pos_z"
,
"v_x"
,
"v_y"
,
"v_z"
,
"h"
,
"rho"
,
"div_v"
,
"S"
,
"u"
,
"P"
,
"c"
,
"a_x"
,
"a_y"
,
"a_z"
,
"h_dt"
,
"v_sig"
,
"dS/dt"
,
"du/dt"
);
...
...
@@ -367,7 +386,7 @@ void dump_particle_fields(char *fileName, struct cell *main_cell,
fprintf
(
file
,
"%6llu %8.5f %8.5f %8.5f %8.5f %8.5f %8.5f %8.5f %8.5f %8.5f %8.5f "
"%8.5f "
"%8.5f %8.5f %
8.5f %8.5f %8.5f
%8.5f %8.5f %8.5f %8.5f
\n
"
,
"%8.5f %8.5f %
13e %13e %13e
%8.5f %8.5f %8.5f %8.5f
\n
"
,
main_cell
->
parts
[
pid
].
id
,
main_cell
->
parts
[
pid
].
x
[
0
],
main_cell
->
parts
[
pid
].
x
[
1
],
main_cell
->
parts
[
pid
].
x
[
2
],
main_cell
->
parts
[
pid
].
v
[
0
],
main_cell
->
parts
[
pid
].
v
[
1
],
...
...
@@ -432,6 +451,7 @@ int main(int argc, char *argv[]) {
size_t
runs
=
0
,
particles
=
0
;
double
h
=
1
.
23485
,
size
=
1
.,
rho
=
2
.
5
;
double
perturbation
=
0
.;
char
outputFileNameExtension
[
200
]
=
""
;
char
outputFileName
[
200
]
=
""
;
enum
velocity_field
vel
=
velocity_zero
;
...
...
@@ -462,6 +482,9 @@ int main(int argc, char *argv[]) {
case
'r'
:
sscanf
(
optarg
,
"%zu"
,
&
runs
);
break
;
case
'd'
:
sscanf
(
optarg
,
"%lf"
,
&
perturbation
);
break
;
case
'm'
:
sscanf
(
optarg
,
"%lf"
,
&
rho
);
break
;
...
...
@@ -491,6 +514,7 @@ int main(int argc, char *argv[]) {
"
\n
-h DISTANCE=1.2348 - Smoothing length in units of <x>"
"
\n
-m rho - Physical density in the cell"
"
\n
-s size - Physical size of the cell"
"
\n
-d pert - Perturbation to apply to the particles [0,1["
"
\n
-v type (0,1,2,3) - Velocity field: (zero, constant, divergent, "
"rotating)"
"
\n
-p type (0,1,2) - Pressure field: (constant, gradient divergent)"
...
...
@@ -566,7 +590,7 @@ int main(int argc, char *argv[]) {
/* Construct it */
cells
[
i
*
25
+
j
*
5
+
k
]
=
make_cell
(
particles
,
offset
,
size
,
h
,
rho
,
&
partId
,
vel
,
press
);
make_cell
(
particles
,
offset
,
size
,
h
,
rho
,
&
partId
,
perturbation
,
vel
,
press
);
/* Store the inner cells */
if
(
i
>
0
&&
i
<
4
&&
j
>
0
&&
j
<
4
&&
k
>
0
&&
k
<
4
)
{
...
...
@@ -672,6 +696,15 @@ int main(int argc, char *argv[]) {
}
}
//for (size_t n = 0; n < 100*runs; ++n) {
// ticks self_tic = getticks();
// DOSELF2(&runner, main_cell);
// self_force_time += getticks() - self_tic;
//
//}
/* Output timing */
message
(
"SWIFT calculation took : %15lli ticks."
,
time
/
runs
);
...
...
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