Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
SWIFT
SWIFTsim
Commits
cf565695
Commit
cf565695
authored
Apr 08, 2016
by
Matthieu Schaller
Browse files
x_old is now a x_diff since the last tree build. It is also implemented for the gparts.
parent
ce5e778a
Changes
7
Hide whitespace changes
Inline
Side-by-side
src/cell.c
View file @
cf565695
...
...
@@ -114,7 +114,7 @@ int cell_unpack(struct pcell *pc, struct cell *c, struct space *s) {
if
(
k
&
1
)
temp
->
loc
[
2
]
+=
temp
->
h
[
2
];
temp
->
depth
=
c
->
depth
+
1
;
temp
->
split
=
0
;
temp
->
dx_max
=
0
.
0
;
temp
->
dx_max
=
0
.
f
;
temp
->
nodeID
=
c
->
nodeID
;
temp
->
parent
=
c
;
c
->
progeny
[
k
]
=
temp
;
...
...
src/gravity/Default/gravity_part.h
View file @
cf565695
...
...
@@ -25,6 +25,9 @@ struct gpart {
/* Particle position. */
double
x
[
3
];
/* Offset between current position and position at last tree rebuild. */
float
x_diff
[
3
];
/* Particle velocity. */
float
v_full
[
3
];
...
...
src/hydro/Default/hydro_part.h
View file @
cf565695
...
...
@@ -20,8 +20,8 @@
/* Extra particle data not needed during the SPH loops over neighbours. */
struct
xpart
{
/* O
l
d position
,
at last tree rebuild. */
double
x_old
[
3
];
/* O
ffset between current position an
d position at last tree rebuild. */
float
x_diff
[
3
];
/* Velocity at the last full step. */
float
v_full
[
3
];
...
...
src/hydro/Gadget2/hydro_part.h
View file @
cf565695
...
...
@@ -20,8 +20,8 @@
/* Extra particle data not needed during the SPH loops over neighbours. */
struct
xpart
{
/* O
l
d position
,
at last tree rebuild. */
double
x_old
[
3
];
/* O
ffset between current position an
d position at last tree rebuild. */
float
x_diff
[
3
];
/* Velocity at the last full step. */
float
v_full
[
3
];
...
...
src/hydro/Minimal/hydro_part.h
View file @
cf565695
...
...
@@ -26,7 +26,8 @@
*/
struct
xpart
{
double
x_old
[
3
];
/*!< Old position, at last tree rebuild. */
float
x_diff
[
3
];
/*!< Offset between current position and position at last
tree rebuild. */
float
v_full
[
3
];
/*!< Velocity at the last full step. */
...
...
src/runner.c
View file @
cf565695
...
...
@@ -697,6 +697,17 @@ void runner_dodrift(struct runner *r, struct cell *c, int timer) {
gp
->
x
[
0
]
+=
gp
->
v_full
[
0
]
*
dt
;
gp
->
x
[
1
]
+=
gp
->
v_full
[
1
]
*
dt
;
gp
->
x
[
2
]
+=
gp
->
v_full
[
2
]
*
dt
;
/* Compute offset since last cell construction */
gp
->
x_diff
[
0
]
-=
gp
->
v_full
[
0
]
*
dt
;
gp
->
x_diff
[
1
]
-=
gp
->
v_full
[
1
]
*
dt
;
gp
->
x_diff
[
2
]
-=
gp
->
v_full
[
2
]
*
dt
;
/* 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
];
dx2_max
=
fmaxf
(
dx2_max
,
dx2
);
}
/* Loop over all the particles in the cell (more work for these !) */
...
...
@@ -737,10 +748,15 @@ void runner_dodrift(struct runner *r, struct cell *c, int timer) {
/* Predict the values of the extra fields */
hydro_predict_extra
(
p
,
xp
,
ti_old
,
ti_current
,
timeBase
);
/* Compute offset since last cell construction */
xp
->
x_diff
[
0
]
-=
xp
->
v_full
[
0
]
*
dt
;
xp
->
x_diff
[
1
]
-=
xp
->
v_full
[
1
]
*
dt
;
xp
->
x_diff
[
2
]
-=
xp
->
v_full
[
2
]
*
dt
;
/* Compute (square of) motion since last cell construction */
const
float
dx2
=
(
p
->
x
[
0
]
-
xp
->
x_
old
[
0
]
)
*
(
p
->
x
[
0
]
-
xp
->
x_
old
[
0
]
)
+
(
p
->
x
[
1
]
-
xp
->
x_
old
[
1
]
)
*
(
p
->
x
[
1
]
-
xp
->
x_
old
[
1
]
)
+
(
p
->
x
[
2
]
-
xp
->
x_
old
[
2
]
)
*
(
p
->
x
[
2
]
-
xp
->
x_
old
[
2
]
)
;
const
float
dx2
=
xp
->
x_
diff
[
0
]
*
xp
->
x_
diff
[
0
]
+
xp
->
x_
diff
[
1
]
*
xp
->
x_
diff
[
1
]
+
xp
->
x_
diff
[
2
]
*
xp
->
x_
diff
[
2
];
dx2_max
=
fmaxf
(
dx2_max
,
dx2
);
/* Maximal smoothing length */
...
...
src/space.c
View file @
cf565695
...
...
@@ -200,9 +200,9 @@ void space_regrid(struct space *s, double cell_max, int verbose) {
"Must have at least 3 cells in each spatial dimension when periodicity "
"is switched on."
);
/* In MPI-Land, changing the top-level cell size requires that the
* global partition is recomputed and the particles redistributed.
* Be prepared to do that. */
/* In MPI-Land, changing the top-level cell size requires that the
* global partition is recomputed and the particles redistributed.
* Be prepared to do that. */
#ifdef WITH_MPI
double
oldh
[
3
];
double
oldcdim
[
3
];
...
...
@@ -296,10 +296,11 @@ void space_regrid(struct space *s, double cell_max, int verbose) {
* cells around the nodes. We repartition using the old space node
* positions as a grid to resample. */
if
(
s
->
e
->
nodeID
==
0
)
message
(
"basic cell dimensions have increased - recalculating the "
"global partition."
);
message
(
"basic cell dimensions have increased - recalculating the "
"global partition."
);
if
(
!
partition_space_to_space
(
oldh
,
oldcdim
,
oldnodeIDs
,
s
)
)
{
if
(
!
partition_space_to_space
(
oldh
,
oldcdim
,
oldnodeIDs
,
s
))
{
/* Failed, try another technique that requires no settings. */
message
(
"Failed to get a new partition, trying less optimal method"
);
...
...
@@ -1209,7 +1210,7 @@ void space_do_split(struct space *s, struct cell *c) {
temp
->
depth
=
c
->
depth
+
1
;
temp
->
split
=
0
;
temp
->
h_max
=
0
.
0
;
temp
->
dx_max
=
0
.
0
;
temp
->
dx_max
=
0
.
f
;
temp
->
nodeID
=
c
->
nodeID
;
temp
->
parent
=
c
;
c
->
progeny
[
k
]
=
temp
;
...
...
@@ -1254,16 +1255,19 @@ void space_do_split(struct space *s, struct cell *c) {
struct
xpart
*
xp
=
&
xparts
[
k
];
const
float
h
=
p
->
h
;
const
int
ti_end
=
p
->
ti_end
;
xp
->
x_
old
[
0
]
=
p
->
x
[
0
]
;
xp
->
x_
old
[
1
]
=
p
->
x
[
1
]
;
xp
->
x_
old
[
2
]
=
p
->
x
[
2
]
;
xp
->
x_
diff
[
0
]
=
0
.
f
;
xp
->
x_
diff
[
1
]
=
0
.
f
;
xp
->
x_
diff
[
2
]
=
0
.
f
;
if
(
h
>
h_max
)
h_max
=
h
;
if
(
ti_end
<
ti_end_min
)
ti_end_min
=
ti_end
;
if
(
ti_end
>
ti_end_max
)
ti_end_max
=
ti_end
;
}
for
(
int
k
=
0
;
k
<
gcount
;
k
++
)
{
struct
gpart
*
p
=
&
gparts
[
k
];
const
int
ti_end
=
p
->
ti_end
;
struct
gpart
*
gp
=
&
gparts
[
k
];
const
int
ti_end
=
gp
->
ti_end
;
gp
->
x_diff
[
0
]
=
0
.
f
;
gp
->
x_diff
[
1
]
=
0
.
f
;
gp
->
x_diff
[
2
]
=
0
.
f
;
if
(
ti_end
<
ti_end_min
)
ti_end_min
=
ti_end
;
if
(
ti_end
>
ti_end_max
)
ti_end_max
=
ti_end
;
}
...
...
@@ -1400,9 +1404,9 @@ void space_init(struct space *s, const struct swift_params *params,
space_maxsize
=
parser_get_param_int
(
params
,
"Scheduler:cell_max_size"
);
space_subsize
=
parser_get_param_int
(
params
,
"Scheduler:cell_sub_size"
);
space_splitsize
=
parser_get_param_int
(
params
,
"Scheduler:cell_split_size"
);
if
(
verbose
)
if
(
verbose
)
message
(
"max_size set to %d, sub_size set to %d, split_size set to %d"
,
space_maxsize
,
space_subsize
,
space_splitsize
);
space_maxsize
,
space_subsize
,
space_splitsize
);
/* Check that we have enough cells */
if
(
s
->
cell_min
*
3
>
dim
[
0
]
||
s
->
cell_min
*
3
>
dim
[
1
]
||
...
...
Write
Preview
Supports
Markdown
0%
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!
Cancel
Please
register
or
sign in
to comment