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
bec5932c
Commit
bec5932c
authored
8 years ago
by
Matthieu Schaller
Browse files
Options
Downloads
Patches
Plain Diff
Statistics are now correct as well.
parent
4799b198
Branches
Branches containing commit
Tags
Tags containing commit
1 merge request
!301
New time line
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
examples/SedovBlast_3D/makeIC.py
+0
-1
0 additions, 1 deletion
examples/SedovBlast_3D/makeIC.py
src/statistics.c
+23
-12
23 additions, 12 deletions
src/statistics.c
src/timeline.h
+2
-2
2 additions, 2 deletions
src/timeline.h
src/timestep.h
+9
-8
9 additions, 8 deletions
src/timestep.h
with
34 additions
and
23 deletions
examples/SedovBlast_3D/makeIC.py
+
0
−
1
View file @
bec5932c
...
@@ -54,7 +54,6 @@ u[:] = P0 / (rho0 * (gamma - 1))
...
@@ -54,7 +54,6 @@ u[:] = P0 / (rho0 * (gamma - 1))
# Make the central particles detonate
# Make the central particles detonate
index
=
argsort
(
r
)
index
=
argsort
(
r
)
u
[
index
[
0
:
N_inject
]]
=
E0
/
(
N_inject
*
m
[
0
])
u
[
index
[
0
:
N_inject
]]
=
E0
/
(
N_inject
*
m
[
0
])
print
ids
[
index
[
0
:
N_inject
]]
#--------------------------------------------------
#--------------------------------------------------
...
...
This diff is collapsed.
Click to expand it.
src/statistics.c
+
23
−
12
View file @
bec5932c
...
@@ -104,8 +104,8 @@ void stats_collect_part_mapper(void *map_data, int nr_parts, void *extra_data) {
...
@@ -104,8 +104,8 @@ void stats_collect_part_mapper(void *map_data, int nr_parts, void *extra_data) {
const
struct
part
*
restrict
parts
=
(
struct
part
*
)
map_data
;
const
struct
part
*
restrict
parts
=
(
struct
part
*
)
map_data
;
const
struct
xpart
*
restrict
xparts
=
const
struct
xpart
*
restrict
xparts
=
s
->
xparts
+
(
ptrdiff_t
)(
parts
-
s
->
parts
);
s
->
xparts
+
(
ptrdiff_t
)(
parts
-
s
->
parts
);
const
int
ti_current
=
s
->
e
->
ti_current
;
//
const int
egertime_t
ti_current = s->e->ti_current;
const
double
timeBase
=
s
->
e
->
timeBase
;
//
const double timeBase = s->e->timeBase;
const
double
time
=
s
->
e
->
time
;
const
double
time
=
s
->
e
->
time
;
struct
statistics
*
const
global_stats
=
data
->
stats
;
struct
statistics
*
const
global_stats
=
data
->
stats
;
...
@@ -126,10 +126,13 @@ void stats_collect_part_mapper(void *map_data, int nr_parts, void *extra_data) {
...
@@ -126,10 +126,13 @@ void stats_collect_part_mapper(void *map_data, int nr_parts, void *extra_data) {
const
struct
gpart
*
gp
=
(
p
->
gpart
!=
NULL
)
?
gp
=
p
->
gpart
:
NULL
;
const
struct
gpart
*
gp
=
(
p
->
gpart
!=
NULL
)
?
gp
=
p
->
gpart
:
NULL
;
/* Get useful variables */
/* Get useful variables */
const
integertime_t
ti_begin
=
// const integertime_t ti_begin =
get_integer_time_begin
(
ti_current
,
p
->
time_bin
);
// get_integer_time_begin(ti_current, p->time_bin);
const
integertime_t
ti_end
=
get_integer_time_end
(
ti_current
,
p
->
time_bin
);
// const integertime_t ti_end = get_integer_time_end(ti_current,
const
float
dt
=
(
ti_current
-
(
ti_begin
+
ti_end
)
/
2
)
*
timeBase
;
// p->time_bin);
// const integertime_t dti = get_integer_timestep(p->time_bin);
const
float
dt
=
0
.
f
;
//(ti_current - (ti_begin + ti_end) / 2) * timeBase; //MATTHIEU
const
double
x
[
3
]
=
{
p
->
x
[
0
],
p
->
x
[
1
],
p
->
x
[
2
]};
const
double
x
[
3
]
=
{
p
->
x
[
0
],
p
->
x
[
1
],
p
->
x
[
2
]};
float
a_tot
[
3
]
=
{
p
->
a_hydro
[
0
],
p
->
a_hydro
[
1
],
p
->
a_hydro
[
2
]};
float
a_tot
[
3
]
=
{
p
->
a_hydro
[
0
],
p
->
a_hydro
[
1
],
p
->
a_hydro
[
2
]};
if
(
gp
!=
NULL
)
{
if
(
gp
!=
NULL
)
{
...
@@ -143,6 +146,12 @@ void stats_collect_part_mapper(void *map_data, int nr_parts, void *extra_data) {
...
@@ -143,6 +146,12 @@ void stats_collect_part_mapper(void *map_data, int nr_parts, void *extra_data) {
const
float
m
=
hydro_get_mass
(
p
);
const
float
m
=
hydro_get_mass
(
p
);
/* if (p->id == ICHECK) */
/* message("bin=%d dti=%lld ti_begin=%lld ti_end=%lld dt=%e v=[%e %e %e]",
*/
/* p->time_bin, dti, ti_begin, ti_end, */
/* dt, v[0], v[1], v[2]); */
/* Collect mass */
/* Collect mass */
stats
.
mass
+=
m
;
stats
.
mass
+=
m
;
...
@@ -188,8 +197,8 @@ void stats_collect_gpart_mapper(void *map_data, int nr_gparts,
...
@@ -188,8 +197,8 @@ void stats_collect_gpart_mapper(void *map_data, int nr_gparts,
const
struct
index_data
*
data
=
(
struct
index_data
*
)
extra_data
;
const
struct
index_data
*
data
=
(
struct
index_data
*
)
extra_data
;
const
struct
space
*
s
=
data
->
s
;
const
struct
space
*
s
=
data
->
s
;
const
struct
gpart
*
restrict
gparts
=
(
struct
gpart
*
)
map_data
;
const
struct
gpart
*
restrict
gparts
=
(
struct
gpart
*
)
map_data
;
const
int
ti_current
=
s
->
e
->
ti_current
;
//
const int
egertime_t
ti_current = s->e->ti_current;
const
double
timeBase
=
s
->
e
->
timeBase
;
//
const double timeBase = s->e->timeBase;
const
double
time
=
s
->
e
->
time
;
const
double
time
=
s
->
e
->
time
;
struct
statistics
*
const
global_stats
=
data
->
stats
;
struct
statistics
*
const
global_stats
=
data
->
stats
;
...
@@ -211,10 +220,12 @@ void stats_collect_gpart_mapper(void *map_data, int nr_gparts,
...
@@ -211,10 +220,12 @@ void stats_collect_gpart_mapper(void *map_data, int nr_gparts,
if
(
gp
->
id_or_neg_offset
<
0
)
continue
;
if
(
gp
->
id_or_neg_offset
<
0
)
continue
;
/* Get useful variables */
/* Get useful variables */
const
integertime_t
ti_begin
=
// const integertime_t ti_begin =
get_integer_time_begin
(
ti_current
,
gp
->
time_bin
);
// get_integer_time_begin(ti_current, gp->time_bin);
const
integertime_t
ti_end
=
get_integer_time_end
(
ti_current
,
gp
->
time_bin
);
// const integertime_t ti_end = get_integer_time_end(ti_current,
const
float
dt
=
(
ti_current
-
(
ti_begin
+
ti_end
)
/
2
)
*
timeBase
;
// gp->time_bin);
const
float
dt
=
0
.
f
;
//(ti_current - (ti_begin + ti_end) / 2) * timeBase; // MATTHIEU
const
double
x
[
3
]
=
{
gp
->
x
[
0
],
gp
->
x
[
1
],
gp
->
x
[
2
]};
const
double
x
[
3
]
=
{
gp
->
x
[
0
],
gp
->
x
[
1
],
gp
->
x
[
2
]};
const
float
v
[
3
]
=
{
gp
->
v_full
[
0
]
+
gp
->
a_grav
[
0
]
*
dt
,
const
float
v
[
3
]
=
{
gp
->
v_full
[
0
]
+
gp
->
a_grav
[
0
]
*
dt
,
gp
->
v_full
[
1
]
+
gp
->
a_grav
[
1
]
*
dt
,
gp
->
v_full
[
1
]
+
gp
->
a_grav
[
1
]
*
dt
,
...
...
This diff is collapsed.
Click to expand it.
src/timeline.h
+
2
−
2
View file @
bec5932c
...
@@ -44,7 +44,7 @@ typedef char timebin_t;
...
@@ -44,7 +44,7 @@ typedef char timebin_t;
*/
*/
static
INLINE
integertime_t
get_integer_timestep
(
timebin_t
bin
)
{
static
INLINE
integertime_t
get_integer_timestep
(
timebin_t
bin
)
{
if
(
bin
=
=
0
)
return
0
;
if
(
bin
<
=
0
)
return
0
;
return
1LL
<<
(
bin
+
1
);
return
1LL
<<
(
bin
+
1
);
}
}
...
@@ -101,7 +101,7 @@ static INLINE integertime_t get_integer_time_end(integertime_t ti_current,
...
@@ -101,7 +101,7 @@ static INLINE integertime_t get_integer_time_end(integertime_t ti_current,
if
(
dti
==
0
)
if
(
dti
==
0
)
return
0
;
return
0
;
else
else
return
dti
*
ceil
l
((
double
)
ti_current
/
(
double
)
dti
);
return
dti
*
ceil
((
double
)
ti_current
/
(
double
)
dti
);
}
}
/**
/**
...
...
This diff is collapsed.
Click to expand it.
src/timestep.h
+
9
−
8
View file @
bec5932c
...
@@ -42,15 +42,16 @@ make_integer_timestep(float new_dt, timebin_t old_bin, integertime_t ti_current,
...
@@ -42,15 +42,16 @@ make_integer_timestep(float new_dt, timebin_t old_bin, integertime_t ti_current,
/* Convert to integer time */
/* Convert to integer time */
integertime_t
new_dti
=
(
integertime_t
)(
new_dt
*
timeBase_inv
);
integertime_t
new_dti
=
(
integertime_t
)(
new_dt
*
timeBase_inv
);
if
(
verbose
)
message
(
"new_dti=%lld"
,
new_dti
);
/*
if (verbose) message("new_dti=%lld", new_dti);
*/
/* Current time-step */
/* Current time-step */
integertime_t
current_dti
=
get_integer_timestep
(
old_bin
);
integertime_t
current_dti
=
get_integer_timestep
(
old_bin
);
integertime_t
ti_end
=
get_integer_time_end
(
ti_current
,
old_bin
);
integertime_t
ti_end
=
get_integer_time_end
(
ti_current
,
old_bin
);
if
(
verbose
)
/* if (verbose) */
message
(
"current_dti=%lld old_bin=%d ti_end=%lld"
,
current_dti
,
old_bin
,
/* message("current_dti=%lld old_bin=%d ti_end=%lld", current_dti, old_bin,
ti_end
);
*/
/* ti_end); */
/* Limit timestep increase */
/* Limit timestep increase */
if
(
old_bin
>
0
)
new_dti
=
min
(
new_dti
,
2
*
current_dti
);
if
(
old_bin
>
0
)
new_dti
=
min
(
new_dti
,
2
*
current_dti
);
...
@@ -60,14 +61,14 @@ make_integer_timestep(float new_dt, timebin_t old_bin, integertime_t ti_current,
...
@@ -60,14 +61,14 @@ make_integer_timestep(float new_dt, timebin_t old_bin, integertime_t ti_current,
while
(
new_dti
<
dti_timeline
)
dti_timeline
/=
2LL
;
while
(
new_dti
<
dti_timeline
)
dti_timeline
/=
2LL
;
new_dti
=
dti_timeline
;
new_dti
=
dti_timeline
;
if
(
verbose
)
message
(
"new_dti=%lld"
,
new_dti
);
/*
if (verbose) message("new_dti=%lld", new_dti);
*/
/* Make sure we are allowed to increase the timestep size */
/* Make sure we are allowed to increase the timestep size */
if
(
new_dti
>
current_dti
)
{
if
(
new_dti
>
current_dti
)
{
if
((
max_nr_timesteps
-
ti_end
)
%
new_dti
>
0
)
new_dti
=
current_dti
;
if
((
max_nr_timesteps
-
ti_end
)
%
new_dti
>
0
)
new_dti
=
current_dti
;
}
}
if
(
verbose
)
message
(
"new_dti=%lld"
,
new_dti
);
/*
if (verbose) message("new_dti=%lld", new_dti);
*/
return
new_dti
;
return
new_dti
;
}
}
...
@@ -150,13 +151,13 @@ __attribute__((always_inline)) INLINE static integertime_t get_part_timestep(
...
@@ -150,13 +151,13 @@ __attribute__((always_inline)) INLINE static integertime_t get_part_timestep(
new_dt
=
min
(
new_dt
,
e
->
dt_max
);
new_dt
=
min
(
new_dt
,
e
->
dt_max
);
new_dt
=
max
(
new_dt
,
e
->
dt_min
);
new_dt
=
max
(
new_dt
,
e
->
dt_min
);
if
(
p
->
id
==
ICHECK
)
message
(
"new_dt=%e"
,
new_dt
);
/*
if (p->id == ICHECK) message("new_dt=%e", new_dt);
*/
/* Convert to integer time */
/* Convert to integer time */
const
integertime_t
new_dti
=
make_integer_timestep
(
const
integertime_t
new_dti
=
make_integer_timestep
(
new_dt
,
p
->
time_bin
,
e
->
ti_current
,
e
->
timeBase_inv
,
p
->
id
==
ICHECK
);
new_dt
,
p
->
time_bin
,
e
->
ti_current
,
e
->
timeBase_inv
,
p
->
id
==
ICHECK
);
if
(
p
->
id
==
ICHECK
)
message
(
"new_dti=%lld"
,
new_dti
);
/*
if (p->id == ICHECK) message("new_dti=%lld", new_dti);
*/
return
new_dti
;
return
new_dti
;
}
}
...
...
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