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
2b238a59
Commit
2b238a59
authored
12 years ago
by
Pedro Gonnet
Browse files
Options
Downloads
Patches
Plain Diff
minor updates for new functionality.
Former-commit-id: 4e2881b7cb2927da4003cda6f78a688044b49f1f
parent
aae80764
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
examples/test.c
+32
-5
32 additions, 5 deletions
examples/test.c
with
32 additions
and
5 deletions
examples/test.c
+
32
−
5
View file @
2b238a59
...
...
@@ -160,11 +160,11 @@ void map_maxdepth ( struct cell *c , void *data ) {
void
map_count
(
struct
part
*
p
,
struct
cell
*
c
,
void
*
data
)
{
double
*
rho
=
(
double
*
)
data
;
double
*
wcount
=
(
double
*
)
data
;
// printf( "%i %e %e\n" , p->id , p->count , p->count_dh );
*
rho
+=
p
->
rho
;
*
wcount
+=
p
->
wcount
;
}
...
...
@@ -382,7 +382,7 @@ void read_dt ( char *fname , struct part *parts , int N ) {
for
(
k
=
0
;
k
<
N
;
k
++
)
{
if
(
gzgets
(
fd
,
buff
,
1024
)
==
NULL
)
error
(
"Error reading id file."
);
if
(
sscanf
(
buff
,
"%
ef
"
,
&
parts
[
k
].
dt
)
!=
1
)
if
(
sscanf
(
buff
,
"%
i
"
,
&
parts
[
k
].
dt
)
!=
1
)
error
(
"Error parsing dt file."
);
}
...
...
@@ -443,7 +443,7 @@ void pairs_n2 ( double *dim , struct part *__restrict__ parts , int N , int peri
}
r2
=
dx
[
0
]
*
dx
[
0
]
+
dx
[
1
]
*
dx
[
1
]
+
dx
[
2
]
*
dx
[
2
];
if
(
r2
<
parts
[
j
].
h
*
parts
[
j
].
h
||
r2
<
parts
[
k
].
h
*
parts
[
k
].
h
)
{
runner_iact_density
(
r2
,
parts
[
j
].
h
,
parts
[
k
].
h
,
&
parts
[
j
]
,
&
parts
[
k
]
);
runner_iact_density
(
r2
,
NULL
,
parts
[
j
].
h
,
parts
[
k
].
h
,
&
parts
[
j
]
,
&
parts
[
k
]
);
if
(
parts
[
j
].
h
/
parts
[
k
].
h
>
maxratio
)
#pragma omp critical
{
...
...
@@ -519,6 +519,26 @@ void pairs_single ( double *dim , struct part *__restrict__ parts , int N , int
}
}
/**
* @brief Test the kernel function by dumping it in the interval [0,1].
*
* @param N number of intervals in [0,1].
*/
void
kernel_dump
(
int
N
)
{
int
k
;
float
x
,
w
,
dw_dx
;
for
(
k
=
0
;
k
<=
N
;
k
++
)
{
x
=
((
float
)
k
)
/
N
*
kernel_igamma
;
kernel_deval
(
x
,
&
w
,
&
dw_dx
);
printf
(
" %e %e %e
\n
"
,
x
,
w
,
dw_dx
);
}
}
/**
...
...
@@ -555,6 +575,7 @@ int main ( int argc , char *argv[] ) {
parts
[
k
].
x
[
2
]
=
((
double
)
rand
())
/
RAND_MAX
*
dim
[
2
];
parts
[
k
].
id
=
k
;
parts
[
k
].
h
=
r_min
+
((
r_max
-
r_min
)
*
rand
())
/
RAND_MAX
;
parts
[
k
].
mass
=
1
.
0
;
}
printf
(
"main: allocated memory for %i parts.
\n
"
,
N
);
fflush
(
stdout
);
break
;
...
...
@@ -629,6 +650,12 @@ int main ( int argc , char *argv[] ) {
error
(
"Unknown option."
);
break
;
}
/* How large are the parts? */
printf
(
"main: sizeof(struct part) is %i bytes.
\n
"
,
sizeof
(
struct
part
)
);
/* Dump the kernel to make sure its ok. */
// kernel_dump( 100 );
/* Get the brute-force number of pairs. */
// pairs_n2( dim , parts , N , periodic );
...
...
@@ -744,7 +771,7 @@ int main ( int argc , char *argv[] ) {
/* Get the average interactions per particle. */
rho
=
0
;
space_map_parts
(
&
s
,
&
map_count
,
&
rho
);
printf
(
"main: average
interactions
per particle is %.3f.
\n
"
,
rho
/
s
.
nr_parts
/
runs
+
32
.
0
/
3
);
printf
(
"main: average
wcount
per particle is %.3f.
\n
"
,
rho
/
s
.
nr_parts
/
runs
+
32
.
0
/
3
);
/* Get the average interactions per particle. */
icount
=
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