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
d0a5620c
Commit
d0a5620c
authored
9 years ago
by
Tom Theuns
Browse files
Options
Downloads
Patches
Plain Diff
added gpart loop to dokick
parent
ba893def
Branches
Branches containing commit
Tags
Tags containing commit
1 merge request
!143
Gravity particles
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/runner.c
+59
-0
59 additions, 0 deletions
src/runner.c
with
59 additions
and
0 deletions
src/runner.c
+
59
−
0
View file @
d0a5620c
...
@@ -766,12 +766,14 @@ void runner_doghost(struct runner *r, struct cell *c) {
...
@@ -766,12 +766,14 @@ void runner_doghost(struct runner *r, struct cell *c) {
void
runner_dodrift
(
struct
runner
*
r
,
struct
cell
*
c
,
int
timer
)
{
void
runner_dodrift
(
struct
runner
*
r
,
struct
cell
*
c
,
int
timer
)
{
const
int
nr_parts
=
c
->
count
;
const
int
nr_parts
=
c
->
count
;
const
int
nr_gparts
=
c
->
gcount
;
const
double
timeBase
=
r
->
e
->
timeBase
;
const
double
timeBase
=
r
->
e
->
timeBase
;
const
double
dt
=
(
r
->
e
->
ti_current
-
r
->
e
->
ti_old
)
*
timeBase
;
const
double
dt
=
(
r
->
e
->
ti_current
-
r
->
e
->
ti_old
)
*
timeBase
;
const
float
ti_old
=
r
->
e
->
ti_old
;
const
float
ti_old
=
r
->
e
->
ti_old
;
const
float
ti_current
=
r
->
e
->
ti_current
;
const
float
ti_current
=
r
->
e
->
ti_current
;
struct
part
*
restrict
p
,
*
restrict
parts
=
c
->
parts
;
struct
part
*
restrict
p
,
*
restrict
parts
=
c
->
parts
;
struct
xpart
*
restrict
xp
,
*
restrict
xparts
=
c
->
xparts
;
struct
xpart
*
restrict
xp
,
*
restrict
xparts
=
c
->
xparts
;
struct
gpart
*
restrict
g
,
*
restrict
gparts
=
c
->
gparts
;
float
dx_max
=
0
.
f
,
h_max
=
0
.
f
;
float
dx_max
=
0
.
f
,
h_max
=
0
.
f
;
float
w
;
float
w
;
...
@@ -827,6 +829,16 @@ void runner_dodrift(struct runner *r, struct cell *c, int timer) {
...
@@ -827,6 +829,16 @@ void runner_dodrift(struct runner *r, struct cell *c, int timer) {
/* Maximal smoothing length */
/* Maximal smoothing length */
h_max
=
fmaxf
(
p
->
h
,
h_max
);
h_max
=
fmaxf
(
p
->
h
,
h_max
);
}
}
/* Loop over all gparts in the cell */
for
(
int
k
=
0
;
k
<
nr_gparts
;
k
++
)
{
g
=
&
gparts
[
k
];
g
->
x
[
0
]
+=
g
->
v
[
0
]
*
dt
;
g
->
x
[
1
]
+=
g
->
v
[
1
]
*
dt
;
g
->
x
[
2
]
+=
g
->
v
[
2
]
*
dt
;
}
}
}
/* Otherwise, aggregate data from children. */
/* Otherwise, aggregate data from children. */
...
@@ -874,6 +886,7 @@ void runner_dokick(struct runner *r, struct cell *c, int timer) {
...
@@ -874,6 +886,7 @@ void runner_dokick(struct runner *r, struct cell *c, int timer) {
const
double
timeBase
=
r
->
e
->
timeBase
;
const
double
timeBase
=
r
->
e
->
timeBase
;
const
double
timeBase_inv
=
1
.
0
/
r
->
e
->
timeBase
;
const
double
timeBase_inv
=
1
.
0
/
r
->
e
->
timeBase
;
const
int
count
=
c
->
count
;
const
int
count
=
c
->
count
;
const
int
gcount
=
c
->
gcount
;
const
int
is_fixdt
=
const
int
is_fixdt
=
(
r
->
e
->
policy
&
engine_policy_fixdt
)
==
engine_policy_fixdt
;
(
r
->
e
->
policy
&
engine_policy_fixdt
)
==
engine_policy_fixdt
;
...
@@ -888,6 +901,7 @@ void runner_dokick(struct runner *r, struct cell *c, int timer) {
...
@@ -888,6 +901,7 @@ void runner_dokick(struct runner *r, struct cell *c, int timer) {
float
x
[
3
],
v_full
[
3
];
float
x
[
3
],
v_full
[
3
];
struct
part
*
restrict
p
,
*
restrict
parts
=
c
->
parts
;
struct
part
*
restrict
p
,
*
restrict
parts
=
c
->
parts
;
struct
xpart
*
restrict
xp
,
*
restrict
xparts
=
c
->
xparts
;
struct
xpart
*
restrict
xp
,
*
restrict
xparts
=
c
->
xparts
;
struct
gpart
*
restrict
g
,
*
restrict
gparts
=
c
->
gparts
;
TIMER_TIC
TIMER_TIC
...
@@ -1013,6 +1027,51 @@ void runner_dokick(struct runner *r, struct cell *c, int timer) {
...
@@ -1013,6 +1027,51 @@ void runner_dokick(struct runner *r, struct cell *c, int timer) {
ti_end_min
=
min
(
p
->
ti_end
,
ti_end_min
);
ti_end_min
=
min
(
p
->
ti_end
,
ti_end_min
);
ti_end_max
=
max
(
p
->
ti_end
,
ti_end_max
);
ti_end_max
=
max
(
p
->
ti_end
,
ti_end_max
);
}
}
/* For the moment we loop of gpart particles comppletely independently - this should be changed */
for
(
int
k
=
0
;
k
<
gcount
;
k
++
)
{
g
=
&
gparts
[
k
];
x
[
0
]
=
g
->
x
[
0
];
x
[
1
]
=
g
->
x
[
1
];
x
[
2
]
=
g
->
x
[
2
];
/* If particle needs to be kicked */
if
(
is_fixdt
||
p
->
ti_end
<=
ti_current
)
{
if
(
is_fixdt
)
{
/* Now we have a time step, proceed with the kick */
new_dti
=
global_dt_max
*
timeBase_inv
;
}
else
{
/* need to calculate gravity step - todo */
error
(
" gravity time step not implemented yet "
);
}
/* Compute the time step for this kick */
const
int
ti_start
=
(
g
->
ti_begin
+
g
->
ti_end
)
/
2
;
const
int
ti_end
=
g
->
ti_end
+
new_dti
/
2
;
const
float
dt
=
(
ti_end
-
ti_start
)
*
timeBase
;
const
float
half_dt
=
(
ti_end
-
g
->
ti_end
)
*
timeBase
;
/* Move particle forward in time */
g
->
ti_begin
=
g
->
ti_end
;
g
->
ti_end
=
g
->
ti_begin
+
new_dti
;
/* Kick particles in momentum space */
g
->
v
[
0
]
+=
g
->
a_grav_external
[
0
]
*
dt
;
g
->
v
[
1
]
+=
g
->
a_grav_external
[
1
]
*
dt
;
g
->
v
[
2
]
+=
g
->
a_grav_external
[
2
]
*
dt
;
/* Number of updated particles */
updated
++
;
}
}
}
}
...
...
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