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
939cd77d
Commit
939cd77d
authored
Aug 17, 2016
by
Matthieu Schaller
Browse files
Removed calls to fminf and fmaxf in the critical sections of the code.
parent
8f88c063
Changes
3
Hide whitespace changes
Inline
Side-by-side
src/hydro/Gadget2/hydro_iact.h
View file @
939cd77d
...
...
@@ -432,7 +432,7 @@ __attribute__((always_inline)) INLINE static void runner_iact_force(
const
float
balsara_j
=
pj
->
force
.
balsara
;
/* Are the particles moving towards each others ? */
const
float
omega_ij
=
fminf
(
dvdr
,
0
.
f
);
const
float
omega_ij
=
(
dvdr
<
0
.
f
)
?
dvdr
:
0
.
f
;
const
float
mu_ij
=
fac_mu
*
r_inv
*
omega_ij
;
/* This is 0 or negative */
/* Signal velocity */
...
...
@@ -465,8 +465,8 @@ __attribute__((always_inline)) INLINE static void runner_iact_force(
pj
->
force
.
h_dt
-=
mi
*
dvdr
*
r_inv
/
rhoi
*
wj_dr
;
/* Update the signal velocity. */
pi
->
force
.
v_sig
=
fmaxf
(
pi
->
force
.
v_sig
,
v_sig
);
pj
->
force
.
v_sig
=
fmaxf
(
pj
->
force
.
v_sig
,
v_sig
);
pi
->
force
.
v_sig
=
(
pi
->
force
.
v_sig
>
v_sig
)
?
pi
->
force
.
v_sig
:
v_sig
;
pj
->
force
.
v_sig
=
(
pj
->
force
.
v_sig
>
v_sig
)
?
pj
->
force
.
v_sig
:
v_sig
;
/* Change in entropy */
pi
->
entropy_dt
+=
mj
*
visc_term
*
dvdr
;
...
...
@@ -707,7 +707,7 @@ __attribute__((always_inline)) INLINE static void runner_iact_nonsym_force(
const
float
balsara_j
=
pj
->
force
.
balsara
;
/* Are the particles moving towards each others ? */
const
float
omega_ij
=
fminf
(
dvdr
,
0
.
f
);
const
float
omega_ij
=
(
dvdr
<
0
.
f
)
?
dvdr
:
0
.
f
;
const
float
mu_ij
=
fac_mu
*
r_inv
*
omega_ij
;
/* This is 0 or negative */
/* Signal velocity */
...
...
@@ -735,7 +735,7 @@ __attribute__((always_inline)) INLINE static void runner_iact_nonsym_force(
pi
->
force
.
h_dt
-=
mj
*
dvdr
*
r_inv
/
rhoj
*
wi_dr
;
/* Update the signal velocity. */
pi
->
force
.
v_sig
=
fmaxf
(
pi
->
force
.
v_sig
,
v_sig
);
pi
->
force
.
v_sig
=
(
pi
->
force
.
v_sig
>
v_sig
)
?
pi
->
force
.
v_sig
:
v_sig
;
/* Change in entropy */
pi
->
entropy_dt
+=
mj
*
visc_term
*
dvdr
;
...
...
src/runner.c
View file @
939cd77d
...
...
@@ -487,8 +487,8 @@ void runner_do_ghost(struct runner *r, struct cell *c) {
h_corr
=
(
target_wcount
-
p
->
density
.
wcount
)
/
p
->
density
.
wcount_dh
;
/* Truncate to the range [ -p->h/2 , p->h ]. */
h_corr
=
fminf
(
h_corr
,
p
->
h
);
h_corr
=
fmaxf
(
h_corr
,
-
p
->
h
*
0
.
5
f
)
;
h_corr
=
(
h_corr
<
p
->
h
)
?
h_corr
:
p
->
h
;
h_corr
=
(
h_corr
>
-
0
.
5
f
*
p
->
h
)
?
h_corr
:
-
0
.
5
f
*
p
->
h
;
}
/* Did we get the right number density? */
...
...
@@ -622,7 +622,7 @@ static void runner_do_drift(struct cell *c, struct engine *e) {
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
)
;
dx2_max
=
(
dx2_max
>
dx2
)
?
dx2_max
:
dx2
;
}
/* Loop over all the particles in the cell (more work for these !) */
...
...
@@ -640,10 +640,10 @@ static void runner_do_drift(struct cell *c, struct engine *e) {
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
)
;
dx2_max
=
(
dx2_max
>
dx2
)
?
dx2_max
:
dx2
;
/* Maximal smoothing length */
h_max
=
fmaxf
(
p
->
h
,
h_max
)
;
h_max
=
(
h_max
>
p
->
h
)
?
h_max
:
p
->
h
;
/* Now collect quantities for statistics */
...
...
src/timestep.h
View file @
939cd77d
...
...
@@ -70,14 +70,15 @@ __attribute__((always_inline)) INLINE static int get_gpart_timestep(
const
float
new_dt_external
=
gravity_compute_timestep_external
(
e
->
external_potential
,
e
->
physical_constants
,
gp
);
const
float
new_dt_self
=
gravity_compute_timestep_self
(
e
->
physical_constants
,
gp
);
/* const float new_dt_self = */
/* gravity_compute_timestep_self(e->physical_constants, gp); */
const
float
new_dt_self
=
FLT_MAX
;
// MATTHIEU
float
new_dt
=
fminf
(
new_dt_external
,
new_dt_self
);
float
new_dt
=
(
new_dt_external
<
new_dt_self
)
?
new_dt_external
:
new_dt_self
;
/* Limit timestep within the allowed range */
new_dt
=
fminf
(
new_dt
,
e
->
dt_max
);
new_dt
=
fmaxf
(
new_dt
,
e
->
dt_min
);
new_dt
=
(
new_dt
<
e
->
dt_max
)
?
new_dt
:
e
->
dt_max
;
new_dt
=
(
new_dt
>
e
->
dt_min
)
?
new_dt
:
e
->
dt_min
;
/* Convert to integer time */
const
int
new_dti
=
...
...
@@ -110,11 +111,11 @@ __attribute__((always_inline)) INLINE static int get_part_timestep(
/* gravity_compute_timestep_self(e->physical_constants, p->gpart); */
const
float
new_dt_self
=
FLT_MAX
;
// MATTHIEU
new_dt_grav
=
fminf
(
new_dt_external
,
new_dt_self
);
new_dt_grav
=
(
new_dt_external
<
new_dt_self
)
?
new_dt_external
:
new_dt_self
;
}
/* Final time-step is minimum of hydro and gravity */
float
new_dt
=
fminf
(
new_dt_hydro
,
new_dt_grav
);
float
new_dt
=
(
new_dt_hydro
<
new_dt_grav
)
?
new_dt_hydro
:
new_dt_grav
;
/* Limit change in h */
const
float
dt_h_change
=
...
...
@@ -122,11 +123,11 @@ __attribute__((always_inline)) INLINE static int get_part_timestep(
?
fabsf
(
e
->
hydro_properties
->
log_max_h_change
*
p
->
h
/
p
->
force
.
h_dt
)
:
FLT_MAX
;
new_dt
=
fminf
(
new_dt
,
dt_h_change
);
new_dt
=
(
new_dt
<
dt_h_change
)
?
new_dt
:
dt_h_change
;
/* Limit timestep within the allowed range */
new_dt
=
fminf
(
new_dt
,
e
->
dt_max
);
new_dt
=
fmaxf
(
new_dt
,
e
->
dt_min
);
new_dt
=
(
new_dt
<
e
->
dt_max
)
?
new_dt
:
e
->
dt_max
;
new_dt
=
(
new_dt
>
e
->
dt_min
)
?
new_dt
:
e
->
dt_min
;
/* Convert to integer time */
const
int
new_dti
=
...
...
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