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
2d03f5ad
Commit
2d03f5ad
authored
8 years ago
by
Matthieu Schaller
Browse files
Options
Downloads
Patches
Plain Diff
Don't recurse in cell_drift if not necessary
parent
fe4019ec
No related branches found
No related tags found
1 merge request
!292
Drift on demand
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/cell.c
+18
-16
18 additions, 16 deletions
src/cell.c
src/cell.h
+1
-1
1 addition, 1 deletion
src/cell.h
with
19 additions
and
17 deletions
src/cell.c
+
18
−
16
View file @
2d03f5ad
...
...
@@ -880,8 +880,8 @@ int cell_unskip_tasks(struct cell *c, struct scheduler *s) {
}
/* Activate the drift on both sides */
if
(
ci
==
c
&&
cj
!=
NULL
)
scheduler_activate
(
s
,
cj
->
drift
);
if
(
cj
==
c
&&
ci
!=
NULL
)
scheduler_activate
(
s
,
ci
->
drift
);
if
(
ci
==
c
&&
cj
!=
NULL
&&
cj
->
drift
!=
NULL
)
scheduler_activate
(
s
,
cj
->
drift
);
if
(
cj
==
c
&&
ci
!=
NULL
&&
ci
->
drift
!=
NULL
)
scheduler_activate
(
s
,
ci
->
drift
);
/* Check whether there was too much particle motion */
if
(
t
->
type
==
task_type_pair
||
t
->
type
==
task_type_sub_pair
)
{
...
...
@@ -987,7 +987,7 @@ void cell_set_super(struct cell *c, struct cell *super) {
if
(
c
->
progeny
[
k
]
!=
NULL
)
cell_set_super
(
c
->
progeny
[
k
],
super
);
}
void
cell_drift
(
struct
cell
*
c
,
struct
engine
*
e
)
{
void
cell_drift
(
struct
cell
*
c
,
const
struct
engine
*
e
)
{
const
double
timeBase
=
e
->
timeBase
;
const
int
ti_old
=
c
->
ti_old
;
...
...
@@ -999,41 +999,41 @@ void cell_drift(struct cell *c, struct engine *e) {
/* Drift from the last time the cell was drifted to the current time */
const
double
dt
=
(
ti_current
-
ti_old
)
*
timeBase
;
float
dx_max
=
0
.
f
,
dx2_max
=
0
.
f
,
h_max
=
0
.
f
;
/* Check that we are actually going to move forward. */
if
(
ti_current
<=
ti_old
)
return
;
/* Are we in a leaf ? */
/* Are we
not
in a leaf ? */
if
(
c
->
split
)
{
/* Loop over the progeny and collect their data. */
for
(
int
k
=
0
;
k
<
8
;
k
++
)
if
(
c
->
progeny
[
k
]
!=
NULL
)
{
struct
cell
*
cp
=
c
->
progeny
[
k
];
cell_drift
(
cp
,
e
);
dx_max
=
max
(
dx_max
,
cp
->
dx_max
);
cell_drift
(
cp
,
e
);
dx_max
=
max
(
dx_max
,
cp
->
dx_max
);
h_max
=
max
(
h_max
,
cp
->
h_max
);
}
}
else
{
/* Loop over all the g-particles in the cell */
const
size_t
nr_gparts
=
c
->
gcount
;
for
(
size_t
k
=
0
;
k
<
nr_gparts
;
k
++
)
{
/* Get a handle on the gpart. */
struct
gpart
*
const
gp
=
&
gparts
[
k
];
/* Drift... */
drift_gpart
(
gp
,
dt
,
timeBase
,
ti_old
,
ti_current
);
/* Compute (square of) motion since last cell construction */
const
float
dx2
=
gp
->
x_diff
[
0
]
*
gp
->
x_diff
[
0
]
+
gp
->
x_diff
[
1
]
*
gp
->
x_diff
[
1
]
+
gp
->
x_diff
[
2
]
*
gp
->
x_diff
[
2
];
gp
->
x_diff
[
1
]
*
gp
->
x_diff
[
1
]
+
gp
->
x_diff
[
2
]
*
gp
->
x_diff
[
2
];
dx2_max
=
(
dx2_max
>
dx2
)
?
dx2_max
:
dx2
;
}
/* Loop over all the particles in the cell */
const
size_t
nr_parts
=
c
->
count
;
for
(
size_t
k
=
0
;
k
<
nr_parts
;
k
++
)
{
...
...
@@ -1045,6 +1045,8 @@ void cell_drift(struct cell *c, struct engine *e) {
/* Drift... */
drift_part
(
p
,
xp
,
dt
,
timeBase
,
ti_old
,
ti_current
);
p
->
ti_old
=
ti_current
;
/* Compute (square of) motion since last cell construction */
const
float
dx2
=
xp
->
x_diff
[
0
]
*
xp
->
x_diff
[
0
]
+
xp
->
x_diff
[
1
]
*
xp
->
x_diff
[
1
]
+
...
...
@@ -1059,7 +1061,7 @@ void cell_drift(struct cell *c, struct engine *e) {
dx_max
=
sqrtf
(
dx2_max
);
/* Set ti_old on the sub-cells */
cell_set_ti_old
(
c
,
e
->
ti_current
);
//
cell_set_ti_old(c, e->ti_current);
}
/* Check that we are actually going to move forward. */
...
...
This diff is collapsed.
Click to expand it.
src/cell.h
+
1
−
1
View file @
2d03f5ad
...
...
@@ -298,6 +298,6 @@ void cell_check_drift_point(struct cell *c, void *data);
int
cell_is_drift_needed
(
struct
cell
*
c
,
const
struct
engine
*
e
);
int
cell_unskip_tasks
(
struct
cell
*
c
,
struct
scheduler
*
s
);
void
cell_set_super
(
struct
cell
*
c
,
struct
cell
*
super
);
void
cell_drift
(
struct
cell
*
c
,
struct
engine
*
e
);
void
cell_drift
(
struct
cell
*
c
,
const
struct
engine
*
e
);
void
cell_set_ti_old
(
struct
cell
*
c
,
int
ti_current
);
#endif
/* SWIFT_CELL_H */
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