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
8fb8b69d
Commit
8fb8b69d
authored
9 years ago
by
James Willis
Browse files
Options
Downloads
Patches
Plain Diff
Created a 2 uniform cell test case to test the vectorisation of DOPAIR1
parent
5ffd38ac
Branches
Branches containing commit
Tags
Tags containing commit
1 merge request
!64
Agreed upon version of the density vectorization test
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
tests/testVectorize.c
+119
-0
119 additions, 0 deletions
tests/testVectorize.c
with
119 additions
and
0 deletions
tests/testVectorize.c
0 → 100644
+
119
−
0
View file @
8fb8b69d
#include
<fenv.h>
#include
<stdlib.h>
#include
<string.h>
#include
<stdio.h>
#include
<unistd.h>
#include
"swift.h"
/* n is both particles per axis and box size:
* particles are generated on a mesh with unit spacing
*/
struct
cell
*
make_cell
(
size_t
n
,
double
*
offset
,
double
h
,
unsigned
long
long
*
partId
)
{
size_t
count
=
n
*
n
*
n
;
struct
cell
*
cell
=
malloc
(
sizeof
*
cell
);
struct
part
*
part
;
size_t
x
,
y
,
z
,
i
,
size
;
size
=
count
*
sizeof
(
*
cell
->
parts
);
if
(
posix_memalign
((
void
**
)
&
cell
->
parts
,
32
,
size
)
!=
0
)
{
error
(
"couldn't allocate particles, no. of particles: %d"
,(
int
)
count
);
}
part
=
cell
->
parts
;
for
(
x
=
0
;
x
<
n
;
++
x
)
{
for
(
y
=
0
;
y
<
n
;
++
y
)
{
for
(
z
=
0
;
z
<
n
;
++
z
)
{
// Add .5 for symmetry: 0.5, 1.5, 2.5 vs. 0, 1, 2
part
->
x
[
0
]
=
x
+
offset
[
0
]
+
0
.
5
;
part
->
x
[
1
]
=
y
+
offset
[
1
]
+
0
.
5
;
part
->
x
[
2
]
=
z
+
offset
[
2
]
+
0
.
5
;
part
->
dt
=
0
.
01
;
part
->
h
=
h
;
part
->
id
=
++
(
*
partId
);
part
->
mass
=
1
.
0
f
;
++
part
;
}
}
}
cell
->
split
=
0
;
cell
->
h_max
=
h
;
cell
->
count
=
count
;
cell
->
sort
=
malloc
(
13
*
count
*
sizeof
*
cell
->
sort
);
runner_dosort
(
NULL
,
cell
,
0x1FFF
,
0
);
return
cell
;
}
void
runner_dopair1_density
(
struct
runner
*
r
,
struct
cell
*
ci
,
struct
cell
*
cj
);
int
main
(
int
argc
,
char
*
argv
[])
{
size_t
particles
=
0
,
runs
=
0
,
volume
,
type
=
0
;
double
offset
[
3
]
=
{
0
,
0
,
0
},
h
=
1
.
1255
;
// * DIM/PARTS_PER_AXIS == * 1
struct
cell
*
ci
,
*
cj
;
struct
space
space
;
struct
engine
engine
;
struct
runner
runner
;
char
c
;
static
unsigned
long
long
partId
=
0
;
while
((
c
=
getopt
(
argc
,
argv
,
"h:p:r:t:"
))
!=
-
1
)
{
switch
(
c
)
{
case
'h'
:
sscanf
(
optarg
,
"%lf"
,
&
h
);
break
;
case
'p'
:
sscanf
(
optarg
,
"%zu"
,
&
particles
);
break
;
case
'r'
:
sscanf
(
optarg
,
"%zu"
,
&
runs
);
break
;
case
't'
:
sscanf
(
optarg
,
"%zu"
,
&
type
);
break
;
}
}
if
(
h
<
0
||
particles
==
0
||
runs
==
0
||
type
>
2
)
{
printf
(
"
\n
Usage: %s -p PARTICLES_PER_AXIS -r NUMBER_OF_RUNS [OPTIONS...]
\n
"
"
\n
Generates a cell pair, filled with particles on a Cartesian grid."
"
\n
These are then interacted using runner_dopair1_density."
"
\n\n
Options:"
"
\n
-t TYPE=0 - cells share face (0), edge (1) or corner (2)"
"
\n
-h DISTANCE=1.1255 - smoothing length"
,
argv
[
0
]);
exit
(
1
);
}
volume
=
particles
*
particles
*
particles
;
message
(
"particles: %zu B
\n
positions: 0 B"
,
2
*
volume
*
sizeof
(
struct
part
));
ci
=
make_cell
(
particles
,
offset
,
h
,
&
partId
);
for
(
size_t
i
=
0
;
i
<
type
+
1
;
++
i
)
offset
[
i
]
=
particles
;
cj
=
make_cell
(
particles
,
offset
,
h
,
&
partId
);
for
(
int
i
=
0
;
i
<
3
;
++
i
)
{
space
.
h_max
=
h
;
space
.
dt_step
=
0
.
1
;
}
engine
.
s
=
&
space
;
engine
.
dt_step
=
0
.
1
;
runner
.
e
=
&
engine
;
printf
(
"#ID, rho, rho_dh, density.wcount, density.wcount_dh, div_v, curl_v:[x,y,z]
\n
"
);
for
(
size_t
i
=
0
;
i
<
runs
;
++
i
)
{
if
(
i
%
50
==
0
)
{
for
(
size_t
pid
=
0
;
pid
<
ci
->
count
;
pid
++
)
{
printf
(
"%lu,%f,%f,%f,%f,%f,[%f,%f,%f]
\n
"
,
ci
->
parts
[
pid
].
id
,
ci
->
parts
[
pid
].
rho
,
ci
->
parts
[
pid
].
rho_dh
,
ci
->
parts
[
pid
].
density
.
wcount
,
ci
->
parts
[
pid
].
density
.
wcount_dh
,
ci
->
parts
[
pid
].
density
.
div_v
,
ci
->
parts
[
pid
].
density
.
curl_v
[
0
],
ci
->
parts
[
pid
].
density
.
curl_v
[
1
],
ci
->
parts
[
pid
].
density
.
curl_v
[
2
]);
}
for
(
size_t
pid
=
0
;
pid
<
cj
->
count
;
pid
++
)
{
printf
(
"%lu,%f,%f,%f,%f,%f,[%f,%f,%f]
\n
"
,
cj
->
parts
[
pid
].
id
,
cj
->
parts
[
pid
].
rho
,
cj
->
parts
[
pid
].
rho_dh
,
cj
->
parts
[
pid
].
density
.
wcount
,
cj
->
parts
[
pid
].
density
.
wcount_dh
,
cj
->
parts
[
pid
].
density
.
div_v
,
cj
->
parts
[
pid
].
density
.
curl_v
[
0
],
cj
->
parts
[
pid
].
density
.
curl_v
[
1
],
cj
->
parts
[
pid
].
density
.
curl_v
[
2
]);
}
}
runner_dopair1_density
(
&
runner
,
ci
,
cj
);
}
}
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