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
e4766c19
Commit
e4766c19
authored
9 years ago
by
Matthieu Schaller
Browse files
Options
Downloads
Patches
Plain Diff
Cleaned-up more engine.c
parent
a90e19dc
Branches
Branches containing commit
Tags
Tags containing commit
2 merge requests
!136
Master
,
!79
First version of the multiple time-stepping
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/engine.c
+14
-0
14 additions, 0 deletions
src/engine.c
src/tools.c
+120
-5
120 additions, 5 deletions
src/tools.c
with
134 additions
and
5 deletions
src/engine.c
+
14
−
0
View file @
e4766c19
...
@@ -628,6 +628,7 @@ void engine_repartition(struct engine *e) {
...
@@ -628,6 +628,7 @@ void engine_repartition(struct engine *e) {
void
engine_addtasks_send
(
struct
engine
*
e
,
struct
cell
*
ci
,
struct
cell
*
cj
)
{
void
engine_addtasks_send
(
struct
engine
*
e
,
struct
cell
*
ci
,
struct
cell
*
cj
)
{
#ifdef WITH_MPI
int
k
;
int
k
;
struct
link
*
l
=
NULL
;
struct
link
*
l
=
NULL
;
struct
scheduler
*
s
=
&
e
->
sched
;
struct
scheduler
*
s
=
&
e
->
sched
;
...
@@ -664,6 +665,11 @@ void engine_addtasks_send(struct engine *e, struct cell *ci, struct cell *cj) {
...
@@ -664,6 +665,11 @@ void engine_addtasks_send(struct engine *e, struct cell *ci, struct cell *cj) {
else
if
(
ci
->
split
)
else
if
(
ci
->
split
)
for
(
k
=
0
;
k
<
8
;
k
++
)
for
(
k
=
0
;
k
<
8
;
k
++
)
if
(
ci
->
progeny
[
k
]
!=
NULL
)
engine_addtasks_send
(
e
,
ci
->
progeny
[
k
],
cj
);
if
(
ci
->
progeny
[
k
]
!=
NULL
)
engine_addtasks_send
(
e
,
ci
->
progeny
[
k
],
cj
);
#else
error
(
"SWIFT was not compiled with MPI support."
);
#endif
}
}
/**
/**
...
@@ -678,6 +684,7 @@ void engine_addtasks_send(struct engine *e, struct cell *ci, struct cell *cj) {
...
@@ -678,6 +684,7 @@ void engine_addtasks_send(struct engine *e, struct cell *ci, struct cell *cj) {
void
engine_addtasks_recv
(
struct
engine
*
e
,
struct
cell
*
c
,
struct
task
*
t_xv
,
void
engine_addtasks_recv
(
struct
engine
*
e
,
struct
cell
*
c
,
struct
task
*
t_xv
,
struct
task
*
t_rho
)
{
struct
task
*
t_rho
)
{
#ifdef WITH_MPI
int
k
;
int
k
;
struct
scheduler
*
s
=
&
e
->
sched
;
struct
scheduler
*
s
=
&
e
->
sched
;
...
@@ -707,6 +714,11 @@ void engine_addtasks_recv(struct engine *e, struct cell *c, struct task *t_xv,
...
@@ -707,6 +714,11 @@ void engine_addtasks_recv(struct engine *e, struct cell *c, struct task *t_xv,
for
(
k
=
0
;
k
<
8
;
k
++
)
for
(
k
=
0
;
k
<
8
;
k
++
)
if
(
c
->
progeny
[
k
]
!=
NULL
)
if
(
c
->
progeny
[
k
]
!=
NULL
)
engine_addtasks_recv
(
e
,
c
->
progeny
[
k
],
t_xv
,
t_rho
);
engine_addtasks_recv
(
e
,
c
->
progeny
[
k
],
t_xv
,
t_rho
);
#else
error
(
"SWIFT was not compiled with MPI support."
);
#endif
}
}
/**
/**
...
@@ -1418,6 +1430,8 @@ void engine_print(struct engine *e) {
...
@@ -1418,6 +1430,8 @@ void engine_print(struct engine *e) {
void
engine_rebuild
(
struct
engine
*
e
)
{
void
engine_rebuild
(
struct
engine
*
e
)
{
message
(
"REBUILD !!!"
);
/* Clear the forcerebuild flag, whatever it was. */
/* Clear the forcerebuild flag, whatever it was. */
e
->
forcerebuild
=
0
;
e
->
forcerebuild
=
0
;
...
...
This diff is collapsed.
Click to expand it.
src/tools.c
+
120
−
5
View file @
e4766c19
...
@@ -37,7 +37,7 @@ void factor(int value, int *f1, int *f2) {
...
@@ -37,7 +37,7 @@ void factor(int value, int *f1, int *f2) {
int
j
;
int
j
;
int
i
;
int
i
;
j
=
(
int
)
sqrt
(
value
);
j
=
(
int
)
sqrt
(
value
);
for
(
i
=
j
;
i
>
0
;
i
--
)
{
for
(
i
=
j
;
i
>
0
;
i
--
)
{
if
((
value
%
i
)
==
0
)
{
if
((
value
%
i
)
==
0
)
{
*
f1
=
i
;
*
f1
=
i
;
...
@@ -110,7 +110,7 @@ void pairs_n2(double *dim, struct part *__restrict__ parts, int N,
...
@@ -110,7 +110,7 @@ void pairs_n2(double *dim, struct part *__restrict__ parts, int N,
/* Dump the result. */
/* Dump the result. */
printf
(
"pairs_n2: avg. density per part is %.3f (nr. pairs %.3f).
\n
"
,
printf
(
"pairs_n2: avg. density per part is %.3f (nr. pairs %.3f).
\n
"
,
rho
/
N
+
32
.
0
/
3
,
((
double
)
count
)
/
N
);
rho
/
N
+
32
.
0
/
3
,
((
double
)
count
)
/
N
);
printf
(
"pairs_n2: densities are in [ %e , %e ].
\n
"
,
rho_min
/
N
+
32
.
0
/
3
,
printf
(
"pairs_n2: densities are in [ %e , %e ].
\n
"
,
rho_min
/
N
+
32
.
0
/
3
,
rho_max
/
N
+
32
.
0
/
3
);
rho_max
/
N
+
32
.
0
/
3
);
/* printf( "pairs_n2: maximum ratio between parts %i [%e,%e,%e] and %i
/* printf( "pairs_n2: maximum ratio between parts %i [%e,%e,%e] and %i
...
@@ -183,7 +183,7 @@ void pairs_single_grav(double *dim, long long int pid,
...
@@ -183,7 +183,7 @@ void pairs_single_grav(double *dim, long long int pid,
// int mj, mk;
// int mj, mk;
// double maxratio = 1.0;
// double maxratio = 1.0;
double
r2
,
dx
[
3
];
double
r2
,
dx
[
3
];
float
fdx
[
3
],
a
[
3
]
=
{
0
.
0
,
0
.
0
,
0
.
0
},
aabs
[
3
]
=
{
0
.
0
,
0
.
0
,
0
.
0
};
float
fdx
[
3
],
a
[
3
]
=
{
0
.
0
,
0
.
0
,
0
.
0
},
aabs
[
3
]
=
{
0
.
0
,
0
.
0
,
0
.
0
};
struct
gpart
pi
,
pj
;
struct
gpart
pi
,
pj
;
// double ih = 12.0/6.25;
// double ih = 12.0/6.25;
...
@@ -239,7 +239,7 @@ void pairs_single_grav(double *dim, long long int pid,
...
@@ -239,7 +239,7 @@ void pairs_single_grav(double *dim, long long int pid,
void
density_dump
(
int
N
)
{
void
density_dump
(
int
N
)
{
int
k
;
int
k
;
float
r2
[
4
]
=
{
0
.
0
f
,
0
.
0
f
,
0
.
0
f
,
0
.
0
f
},
hi
[
4
],
hj
[
4
];
float
r2
[
4
]
=
{
0
.
0
f
,
0
.
0
f
,
0
.
0
f
,
0
.
0
f
},
hi
[
4
],
hj
[
4
];
struct
part
*
pi
[
4
],
*
pj
[
4
],
Pi
[
4
],
Pj
[
4
];
struct
part
*
pi
[
4
],
*
pj
[
4
],
Pi
[
4
],
Pj
[
4
];
/* Init the interaction parameters. */
/* Init the interaction parameters. */
...
@@ -260,7 +260,7 @@ void density_dump(int N) {
...
@@ -260,7 +260,7 @@ void density_dump(int N) {
r2
[
3
]
=
r2
[
2
];
r2
[
3
]
=
r2
[
2
];
r2
[
2
]
=
r2
[
1
];
r2
[
2
]
=
r2
[
1
];
r2
[
1
]
=
r2
[
0
];
r2
[
1
]
=
r2
[
0
];
r2
[
0
]
=
((
float
)
k
)
/
N
;
r2
[
0
]
=
((
float
)
k
)
/
N
;
Pi
[
0
].
density
.
wcount
=
0
;
Pi
[
0
].
density
.
wcount
=
0
;
Pj
[
0
].
density
.
wcount
=
0
;
Pj
[
0
].
density
.
wcount
=
0
;
runner_iact_density
(
r2
[
0
],
NULL
,
hi
[
0
],
hj
[
0
],
&
Pi
[
0
],
&
Pj
[
0
]);
runner_iact_density
(
r2
[
0
],
NULL
,
hi
[
0
],
hj
[
0
],
&
Pi
[
0
],
&
Pj
[
0
]);
...
@@ -278,3 +278,118 @@ void density_dump(int N) {
...
@@ -278,3 +278,118 @@ void density_dump(int N) {
Pi
[
2
].
density
.
wcount
,
Pi
[
3
].
density
.
wcount
);
Pi
[
2
].
density
.
wcount
,
Pi
[
3
].
density
.
wcount
);
}
}
}
}
/**
* @brief Compute the force on a single particle brute-force.
*/
void
engine_single_density
(
double
*
dim
,
long
long
int
pid
,
struct
part
*
__restrict__
parts
,
int
N
,
int
periodic
)
{
int
i
,
k
;
double
r2
,
dx
[
3
];
float
fdx
[
3
],
ih
;
struct
part
p
;
/* Find "our" part. */
for
(
k
=
0
;
k
<
N
&&
parts
[
k
].
id
!=
pid
;
k
++
)
;
if
(
k
==
N
)
error
(
"Part not found."
);
p
=
parts
[
k
];
/* Clear accumulators. */
ih
=
1
.
0
f
/
p
.
h
;
p
.
rho
=
0
.
0
f
;
p
.
rho_dh
=
0
.
0
f
;
p
.
density
.
wcount
=
0
.
0
f
;
p
.
density
.
wcount_dh
=
0
.
0
f
;
p
.
density
.
div_v
=
0
.
0
;
for
(
k
=
0
;
k
<
3
;
k
++
)
p
.
density
.
curl_v
[
k
]
=
0
.
0
;
/* Loop over all particle pairs (force). */
for
(
k
=
0
;
k
<
N
;
k
++
)
{
if
(
parts
[
k
].
id
==
p
.
id
)
continue
;
for
(
i
=
0
;
i
<
3
;
i
++
)
{
dx
[
i
]
=
p
.
x
[
i
]
-
parts
[
k
].
x
[
i
];
if
(
periodic
)
{
if
(
dx
[
i
]
<
-
dim
[
i
]
/
2
)
dx
[
i
]
+=
dim
[
i
];
else
if
(
dx
[
i
]
>
dim
[
i
]
/
2
)
dx
[
i
]
-=
dim
[
i
];
}
fdx
[
i
]
=
dx
[
i
];
}
r2
=
fdx
[
0
]
*
fdx
[
0
]
+
fdx
[
1
]
*
fdx
[
1
]
+
fdx
[
2
]
*
fdx
[
2
];
if
(
r2
<
p
.
h
*
p
.
h
*
kernel_gamma2
)
{
runner_iact_nonsym_density
(
r2
,
fdx
,
p
.
h
,
parts
[
k
].
h
,
&
p
,
&
parts
[
k
]);
}
}
/* Dump the result. */
p
.
rho
=
ih
*
ih
*
ih
*
(
p
.
rho
+
p
.
mass
*
kernel_root
);
p
.
rho_dh
=
p
.
rho_dh
*
ih
*
ih
*
ih
*
ih
;
p
.
density
.
wcount
=
(
p
.
density
.
wcount
+
kernel_root
)
*
(
4
.
0
f
/
3
.
0
*
M_PI
*
kernel_gamma3
);
message
(
"part %lli (h=%e) has wcount=%e, rho=%e, rho_dh=%e."
,
p
.
id
,
p
.
h
,
p
.
density
.
wcount
,
p
.
rho
,
p
.
rho_dh
);
fflush
(
stdout
);
}
void
engine_single_force
(
double
*
dim
,
long
long
int
pid
,
struct
part
*
__restrict__
parts
,
int
N
,
int
periodic
)
{
int
i
,
k
;
double
r2
,
dx
[
3
];
float
fdx
[
3
];
struct
part
p
;
/* Find "our" part. */
for
(
k
=
0
;
k
<
N
&&
parts
[
k
].
id
!=
pid
;
k
++
)
;
if
(
k
==
N
)
error
(
"Part not found."
);
p
=
parts
[
k
];
/* Clear accumulators. */
p
.
a
[
0
]
=
0
.
0
f
;
p
.
a
[
1
]
=
0
.
0
f
;
p
.
a
[
2
]
=
0
.
0
f
;
p
.
force
.
u_dt
=
0
.
0
f
;
p
.
force
.
h_dt
=
0
.
0
f
;
p
.
force
.
v_sig
=
0
.
0
f
;
/* Loop over all particle pairs (force). */
for
(
k
=
0
;
k
<
N
;
k
++
)
{
// for ( k = N-1 ; k >= 0 ; k-- ) {
if
(
parts
[
k
].
id
==
p
.
id
)
continue
;
for
(
i
=
0
;
i
<
3
;
i
++
)
{
dx
[
i
]
=
p
.
x
[
i
]
-
parts
[
k
].
x
[
i
];
if
(
periodic
)
{
if
(
dx
[
i
]
<
-
dim
[
i
]
/
2
)
dx
[
i
]
+=
dim
[
i
];
else
if
(
dx
[
i
]
>
dim
[
i
]
/
2
)
dx
[
i
]
-=
dim
[
i
];
}
fdx
[
i
]
=
dx
[
i
];
}
r2
=
fdx
[
0
]
*
fdx
[
0
]
+
fdx
[
1
]
*
fdx
[
1
]
+
fdx
[
2
]
*
fdx
[
2
];
if
(
r2
<
p
.
h
*
p
.
h
*
kernel_gamma2
||
r2
<
parts
[
k
].
h
*
parts
[
k
].
h
*
kernel_gamma2
)
{
p
.
a
[
0
]
=
0
.
0
f
;
p
.
a
[
1
]
=
0
.
0
f
;
p
.
a
[
2
]
=
0
.
0
f
;
p
.
force
.
u_dt
=
0
.
0
f
;
p
.
force
.
h_dt
=
0
.
0
f
;
p
.
force
.
v_sig
=
0
.
0
f
;
runner_iact_nonsym_force
(
r2
,
fdx
,
p
.
h
,
parts
[
k
].
h
,
&
p
,
&
parts
[
k
]);
}
}
/* Dump the result. */
message
(
"part %lli (h=%e) has a=[%.3e,%.3e,%.3e], udt=%e."
,
p
.
id
,
p
.
h
,
p
.
a
[
0
]
,
p
.
a
[
1
]
,
p
.
a
[
2
]
,
p
.
force
.
u_dt
);
fflush
(
stdout
);
}
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