Skip to content
GitLab
Menu
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
322529eb
Commit
322529eb
authored
May 22, 2018
by
Matthieu Schaller
Browse files
Code formatting
parent
49f09458
Changes
6
Hide whitespace changes
Inline
Side-by-side
src/hydro/PressureEnergy/hydro.h
View file @
322529eb
...
...
@@ -27,7 +27,7 @@
*
* The thermal variable is the internal energy (u). A simple constant
* viscosity term with a Balsara switch is implemented.
*
*
* No thermal conduction term is implemented.
*
* This implementation corresponds to the one presented in the SWIFT
...
...
@@ -156,7 +156,6 @@ hydro_get_comoving_soundspeed(const struct part *restrict p) {
const
float
square_rooted
=
sqrtf
(
hydro_gamma
*
p
->
pressure_bar
/
p
->
rho
);
return
square_rooted
;
}
/**
...
...
@@ -288,9 +287,8 @@ __attribute__((always_inline)) INLINE static float hydro_compute_timestep(
const
float
dt_cfl
=
2
.
f
*
kernel_gamma
*
CFL_condition
*
cosmo
->
a
*
p
->
h
/
(
cosmo
->
a_factor_sound_speed
*
p
->
force
.
v_sig
);
const
float
dt_u_change
=
(
p
->
u_dt
!=
0
.
0
f
)
?
fabsf
(
const_max_u_change
*
p
->
u
/
p
->
u_dt
)
:
FLT_MAX
;
const
float
dt_u_change
=
(
p
->
u_dt
!=
0
.
0
f
)
?
fabsf
(
const_max_u_change
*
p
->
u
/
p
->
u_dt
)
:
FLT_MAX
;
return
fminf
(
dt_cfl
,
dt_u_change
);
}
...
...
@@ -453,10 +451,9 @@ __attribute__((always_inline)) INLINE static void hydro_prepare_force(
/* Compute the "grad h" term */
const
float
common_factor
=
p
->
h
/
(
hydro_dimension
*
p
->
density
.
wcount
);
const
float
grad_h_term
=
(
p
->
density
.
pressure_bar_dh
*
common_factor
*
hydro_one_over_gamma_minus_one
)
/
(
1
.
f
+
common_factor
*
p
->
density
.
wcount_dh
);
const
float
grad_h_term
=
(
p
->
density
.
pressure_bar_dh
*
common_factor
*
hydro_one_over_gamma_minus_one
)
/
(
1
.
f
+
common_factor
*
p
->
density
.
wcount_dh
);
/* Update variables. */
p
->
force
.
f
=
grad_h_term
;
...
...
@@ -535,7 +532,8 @@ __attribute__((always_inline)) INLINE static void hydro_predict_extra(
/* Predict density and weighted pressure */
const
float
w2
=
-
hydro_dimension
*
w1
;
if
(
fabsf
(
w2
)
<
0
.
2
f
)
{
const
float
expf_approx
=
approx_expf
(
w2
);
/* 4th order expansion of exp(w) */
const
float
expf_approx
=
approx_expf
(
w2
);
/* 4th order expansion of exp(w) */
p
->
rho
*=
expf_approx
;
p
->
pressure_bar
*=
expf_approx
;
}
else
{
...
...
@@ -611,7 +609,7 @@ __attribute__((always_inline)) INLINE static void hydro_kick_extra(
*/
__attribute__
((
always_inline
))
INLINE
static
void
hydro_convert_quantities
(
struct
part
*
restrict
p
,
struct
xpart
*
restrict
xp
,
const
struct
cosmology
*
cosmo
)
{
}
const
struct
cosmology
*
cosmo
)
{}
/**
* @brief Initialises the particles for the first time
...
...
@@ -645,20 +643,28 @@ __attribute__((always_inline)) INLINE static void hydro_first_init_part(
}
if
(
p
->
u
<
-
0
.
0001
)
printf
(
"Particle %lld has negative u=%.3e "
"(hydro_first_init_part)
\n
"
,
p
->
id
,
p
->
u
);
printf
(
"Particle %lld has negative u=%.3e "
"(hydro_first_init_part)
\n
"
,
p
->
id
,
p
->
u
);
if
(
p
->
pressure_bar
<
-
0
.
0001
)
printf
(
"Particle %lld has negative P_bar=%.3e "
"(hydro_first_init_part)
\n
"
,
p
->
id
,
p
->
pressure_bar
);
printf
(
"Particle %lld has negative P_bar=%.3e "
"(hydro_first_init_part)
\n
"
,
p
->
id
,
p
->
pressure_bar
);
if
(
p
->
rho
<
-
0
.
0001
)
printf
(
"Particle %lld has negative rho=%.3e "
"(hydro_first_init_part)
\n
"
,
p
->
id
,
p
->
rho
);
printf
(
"Particle %lld has negative rho=%.3e "
"(hydro_first_init_part)
\n
"
,
p
->
id
,
p
->
rho
);
if
(
p
->
mass
<
-
0
.
0001
)
printf
(
"Particle %lld has negative m=%.3e "
"(hydro_first_init_part)
\n
"
,
p
->
id
,
p
->
mass
);
printf
(
"Particle %lld has negative m=%.3e "
"(hydro_first_init_part)
\n
"
,
p
->
id
,
p
->
mass
);
#endif
}
...
...
src/hydro/PressureEnergy/hydro_iact.h
View file @
322529eb
...
...
@@ -129,11 +129,9 @@ __attribute__((always_inline)) INLINE static void runner_iact_density(
if
(
pi
->
rho
<
-
FLT_MIN
)
error
(
"Particle %lld has negative rho=%.3e
\n
"
,
pi
->
id
,
pi
->
rho
);
if
(
mj
<
-
FLT_MIN
)
error
(
"Particle %lld has negative m=%.3e
\n
"
,
pj
->
id
,
mj
);
if
(
mj
<
-
FLT_MIN
)
error
(
"Particle %lld has negative m=%.3e
\n
"
,
pj
->
id
,
mj
);
if
(
wi
<
-
FLT_MIN
)
error
(
"Particle %lld has negative rho=%.3e
\n
"
,
pi
->
id
,
wi
);
if
(
wi
<
-
FLT_MIN
)
error
(
"Particle %lld has negative rho=%.3e
\n
"
,
pi
->
id
,
wi
);
#endif
}
...
...
@@ -206,11 +204,9 @@ __attribute__((always_inline)) INLINE static void runner_iact_nonsym_density(
if
(
pi
->
rho
<
-
FLT_MIN
)
error
(
"Particle %lld has negative rho=%.3e
\n
"
,
pi
->
id
,
pi
->
rho
);
if
(
mj
<
-
FLT_MIN
)
error
(
"Particle %lld has negative m=%.3e
\n
"
,
pj
->
id
,
mj
);
if
(
mj
<
-
FLT_MIN
)
error
(
"Particle %lld has negative m=%.3e
\n
"
,
pj
->
id
,
mj
);
if
(
wi
<
-
FLT_MIN
)
error
(
"Particle %lld has negative rho=%.3e
\n
"
,
pi
->
id
,
wi
);
if
(
wi
<
-
FLT_MIN
)
error
(
"Particle %lld has negative rho=%.3e
\n
"
,
pi
->
id
,
wi
);
#endif
}
...
...
@@ -287,7 +283,7 @@ __attribute__((always_inline)) INLINE static void runner_iact_force(
/* Construct the full viscosity term */
const
float
rho_ij
=
0
.
5
f
*
(
rhoi
+
rhoj
);
const
float
visc
=
-
0
.
25
f
*
const_viscosity_alpha
*
v_sig
*
mu_ij
*
(
balsara_i
+
balsara_j
)
/
rho_ij
;
(
balsara_i
+
balsara_j
)
/
rho_ij
;
/* Convolve with the kernel */
const
float
visc_acc_term
=
0
.
5
f
*
visc
*
(
wi_dr
+
wj_dr
)
*
r_inv
;
...
...
@@ -412,7 +408,7 @@ __attribute__((always_inline)) INLINE static void runner_iact_nonsym_force(
/* Construct the full viscosity term */
const
float
rho_ij
=
0
.
5
f
*
(
rhoi
+
rhoj
);
const
float
visc
=
-
0
.
25
f
*
const_viscosity_alpha
*
v_sig
*
mu_ij
*
(
balsara_i
+
balsara_j
)
/
rho_ij
;
(
balsara_i
+
balsara_j
)
/
rho_ij
;
/* Convolve with the kernel */
const
float
visc_acc_term
=
0
.
5
f
*
visc
*
(
wi_dr
+
wj_dr
)
*
r_inv
;
...
...
src/hydro/PressureEnergy/hydro_io.h
View file @
322529eb
...
...
@@ -74,8 +74,8 @@ void convert_u(const struct engine* e, const struct part* p,
}
void
convert_S
(
const
struct
engine
*
e
,
const
struct
part
*
p
,
const
struct
xpart
*
xp
,
float
*
ret
)
{
const
struct
xpart
*
xp
,
float
*
ret
)
{
ret
[
0
]
=
hydro_get_comoving_entropy
(
p
);
}
...
...
tests/test125cells.c
View file @
322529eb
...
...
@@ -406,7 +406,8 @@ void dump_particle_fields(char *fileName, struct cell *main_cell,
main_cell
->
parts
[
pid
].
v
[
2
],
main_cell
->
parts
[
pid
].
h
,
hydro_get_comoving_density
(
&
main_cell
->
parts
[
pid
]),
#if defined(MINIMAL_SPH) || defined(MINIMAL_MULTI_MAT_SPH) || \
defined(GIZMO_MFV_SPH) || defined(SHADOWFAX_SPH) || defined(HOPKINS_PU_SPH)
defined(GIZMO_MFV_SPH) || defined(SHADOWFAX_SPH) || \
defined(HOPKINS_PU_SPH)
0
.
f
,
#else
main_cell
->
parts
[
pid
].
density
.
div_v
,
...
...
@@ -795,15 +796,15 @@ int main(int argc, char *argv[]) {
const
ticks
tic
=
getticks
();
/* Kick the central cell */
// runner_do_kick1(&runner, main_cell, 0);
/* Kick the central cell */
// runner_do_kick1(&runner, main_cell, 0);
/* And drift it */
// runner_do_drift_particles(&runner, main_cell, 0);
/* And drift it */
// runner_do_drift_particles(&runner, main_cell, 0);
/* Initialise the particles */
// for (int j = 0; j < 125; ++j) runner_do_drift_particles(&runner, cells[j],
// 0);
/* Initialise the particles */
// for (int j = 0; j < 125; ++j) runner_do_drift_particles(&runner, cells[j],
// 0);
/* Do the density calculation */
#if !(defined(MINIMAL_SPH) && defined(WITH_VECTORIZATION))
...
...
tests/test27cells.c
View file @
322529eb
...
...
@@ -270,7 +270,8 @@ void dump_particle_fields(char *fileName, struct cell *main_cell,
#endif
main_cell
->
parts
[
pid
].
density
.
wcount
,
main_cell
->
parts
[
pid
].
density
.
wcount_dh
,
#if defined(GADGET2_SPH) || defined(DEFAULT_SPH) || defined(HOPKINS_PE_SPH) || defined(HOPKINS_PU_SPH)
#if defined(GADGET2_SPH) || defined(DEFAULT_SPH) || defined(HOPKINS_PE_SPH) || \
defined(HOPKINS_PU_SPH)
main_cell
->
parts
[
pid
].
density
.
div_v
,
main_cell
->
parts
[
pid
].
density
.
rot_v
[
0
],
main_cell
->
parts
[
pid
].
density
.
rot_v
[
1
],
...
...
@@ -278,7 +279,7 @@ void dump_particle_fields(char *fileName, struct cell *main_cell,
#else
0
.,
0
.,
0
.,
0
.
#endif
);
);
}
/* Write all other cells */
...
...
@@ -312,7 +313,7 @@ void dump_particle_fields(char *fileName, struct cell *main_cell,
#else
0
.,
0
.,
0
.,
0
.
#endif
);
);
}
}
}
...
...
tests/testInteractions.c
View file @
322529eb
...
...
@@ -27,7 +27,7 @@
/* Other schemes need to be added here if they are not vectorized, otherwise
* this test will simply not compile. */
#if defined(GADGET2_SPH) && defined(WITH_VECTORIZATION)
#if defined(GADGET2_SPH) && defined(WITH_VECTORIZATION)
#define array_align sizeof(float) * VEC_SIZE
#define ACC_THRESHOLD 1e-5
...
...
@@ -107,7 +107,7 @@ struct part *make_particles(size_t count, double *offset, double spacing,
*/
void
prepare_force
(
struct
part
*
parts
,
size_t
count
)
{
#if !defined(GIZMO_MFV_SPH) && !defined(SHADOWFAX_SPH) && \
#if !defined(GIZMO_MFV_SPH) && !defined(SHADOWFAX_SPH) &&
\
!defined(MINIMAL_SPH) && !defined(MINIMAL_MULTI_MAT_SPH) && \
!defined(HOPKINS_PU_SPH)
struct
part
*
p
;
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a 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