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
d8d71581
Commit
d8d71581
authored
Aug 04, 2018
by
Matthieu Schaller
Browse files
Code formatting
parent
4ad965ea
Changes
11
Hide whitespace changes
Inline
Side-by-side
src/cell.c
View file @
d8d71581
...
...
@@ -1453,7 +1453,7 @@ void cell_activate_drift_gpart(struct cell *c, struct scheduler *s) {
if
(
parent
->
drift_gpart
==
NULL
)
error
(
"Trying to activate un-existing parent->drift_gpart"
);
#endif
scheduler_activate
(
s
,
parent
->
drift_gpart
);
scheduler_activate
(
s
,
parent
->
drift_gpart
);
break
;
}
}
...
...
@@ -2706,8 +2706,7 @@ void cell_drift_all_multipoles(struct cell *c, const struct engine *e) {
dt_drift
=
(
ti_current
-
ti_old_multipole
)
*
e
->
time_base
;
/* Drift the multipole */
if
(
ti_current
>
ti_old_multipole
)
gravity_drift
(
c
->
multipole
,
dt_drift
);
if
(
ti_current
>
ti_old_multipole
)
gravity_drift
(
c
->
multipole
,
dt_drift
);
/* Are we not in a leaf ? */
if
(
c
->
split
)
{
...
...
@@ -2748,8 +2747,7 @@ void cell_drift_multipole(struct cell *c, const struct engine *e) {
else
dt_drift
=
(
ti_current
-
ti_old_multipole
)
*
e
->
time_base
;
if
(
ti_current
>
ti_old_multipole
)
gravity_drift
(
c
->
multipole
,
dt_drift
);
if
(
ti_current
>
ti_old_multipole
)
gravity_drift
(
c
->
multipole
,
dt_drift
);
/* Update the time of the last drift */
c
->
ti_old_multipole
=
ti_current
;
...
...
src/engine.c
View file @
d8d71581
...
...
@@ -2378,8 +2378,8 @@ void engine_make_self_gravity_tasks_mapper(void *map_data, int num_elements,
int
delta_p
=
delta
;
/* Special case where every cell is in range of every other one */
if
(
delta
>=
cdim
[
0
]
/
2
)
{
if
(
cdim
[
0
]
%
2
==
0
)
{
if
(
delta
>=
cdim
[
0
]
/
2
)
{
if
(
cdim
[
0
]
%
2
==
0
)
{
delta_m
=
cdim
[
0
]
/
2
;
delta_p
=
cdim
[
0
]
/
2
-
1
;
}
else
{
...
...
@@ -6029,7 +6029,7 @@ void engine_config(int restart, struct engine *e, struct swift_params *params,
if
(
!
(
e
->
policy
&
engine_policy_cosmology
))
if
(
e
->
dt_max
>
(
e
->
time_end
-
e
->
time_begin
)
&&
e
->
nodeID
==
0
)
error
(
"Maximal time-step size larger than the simulation run time t=%e"
,
e
->
time_end
-
e
->
time_begin
);
e
->
time_end
-
e
->
time_begin
);
/* Deal with outputs */
if
(
e
->
policy
&
engine_policy_cosmology
)
{
...
...
@@ -6082,7 +6082,8 @@ void engine_config(int restart, struct engine *e, struct swift_params *params,
/* Reduce the total mass */
#ifdef WITH_MPI
MPI_Allreduce
(
MPI_IN_PLACE
,
&
e
->
total_mass
,
1
,
MPI_DOUBLE
,
MPI_SUM
,
MPI_COMM_WORLD
);
MPI_Allreduce
(
MPI_IN_PLACE
,
&
e
->
total_mass
,
1
,
MPI_DOUBLE
,
MPI_SUM
,
MPI_COMM_WORLD
);
#endif
/* Find the time of the first snapshot output */
...
...
src/gravity/Potential/gravity.h
View file @
d8d71581
...
...
@@ -169,8 +169,7 @@ __attribute__((always_inline)) INLINE static void gravity_end_force(
const
int
periodic
)
{
/* Apply the periodic correction to the peculiar potential */
if
(
periodic
)
gp
->
potential
+=
potential_normalisation
;
if
(
periodic
)
gp
->
potential
+=
potential_normalisation
;
/* Let's get physical... */
gp
->
a_grav
[
0
]
*=
const_G
;
...
...
src/gravity/Potential/gravity_debug.h
View file @
d8d71581
...
...
@@ -23,9 +23,11 @@ __attribute__((always_inline)) INLINE static void gravity_debug_particle(
const
struct
gpart
*
p
)
{
printf
(
"mass=%.3e time_bin=%d
\n
"
"x=[%.5e,%.5e,%.5e], v_full=[%.5e,%.5e,%.5e], a=[%.5e,%.5e,%.5e] pot=%.5e
\n
"
,
"x=[%.5e,%.5e,%.5e], v_full=[%.5e,%.5e,%.5e], a=[%.5e,%.5e,%.5e] "
"pot=%.5e
\n
"
,
p
->
mass
,
p
->
time_bin
,
p
->
x
[
0
],
p
->
x
[
1
],
p
->
x
[
2
],
p
->
v_full
[
0
],
p
->
v_full
[
1
],
p
->
v_full
[
2
],
p
->
a_grav
[
0
],
p
->
a_grav
[
1
],
p
->
a_grav
[
2
],
p
->
potential
);
p
->
v_full
[
1
],
p
->
v_full
[
2
],
p
->
a_grav
[
0
],
p
->
a_grav
[
1
],
p
->
a_grav
[
2
],
p
->
potential
);
#ifdef SWIFT_DEBUG_CHECKS
printf
(
"num_interacted=%lld ti_drift=%lld ti_kick=%lld
\n
"
,
p
->
num_interacted
,
p
->
ti_drift
,
p
->
ti_kick
);
...
...
src/gravity_iact.h
View file @
d8d71581
...
...
@@ -36,5 +36,4 @@
#error "Invalid choice of gravity variant"
#endif
#endif
src/mesh_gravity.c
View file @
d8d71581
...
...
@@ -282,7 +282,7 @@ void mesh_to_gparts_CIC(struct gpart* gp, const double* pot, int N, double fac,
* @param verbose Are we talkative?
*/
void
pm_mesh_compute_potential
(
struct
pm_mesh
*
mesh
,
const
struct
space
*
s
,
int
verbose
)
{
int
verbose
)
{
#ifdef HAVE_FFTW
...
...
@@ -323,9 +323,9 @@ void pm_mesh_compute_potential(struct pm_mesh* mesh, const struct space* s,
for
(
size_t
i
=
0
;
i
<
s
->
nr_gparts
;
++
i
)
gpart_to_mesh_CIC
(
&
s
->
gparts
[
i
],
rho
,
N
,
cell_fac
,
dim
);
if
(
verbose
)
message
(
"gpart assignment took %.3f %s."
,
clocks_from_ticks
(
getticks
()
-
tic
),
clocks_getunit
());
if
(
verbose
)
message
(
"gpart assignment took %.3f %s."
,
clocks_from_ticks
(
getticks
()
-
tic
),
clocks_getunit
());
/* message("\n\n\n DENSITY"); */
/* print_array(rho, N); */
...
...
@@ -407,9 +407,9 @@ void pm_mesh_compute_potential(struct pm_mesh* mesh, const struct space* s,
/* Let's store it in the structure */
mesh
->
potential
=
rho
;
if
(
verbose
)
message
(
"Fourier-space PM took %.3f %s."
,
clocks_from_ticks
(
getticks
()
-
tic2
),
clocks_getunit
());
if
(
verbose
)
message
(
"Fourier-space PM took %.3f %s."
,
clocks_from_ticks
(
getticks
()
-
tic2
),
clocks_getunit
());
/* message("\n\n\n POTENTIAL"); */
/* print_array(potential, N); */
...
...
src/mesh_gravity.h
View file @
d8d71581
...
...
@@ -67,7 +67,7 @@ void pm_mesh_init(struct pm_mesh *mesh, const struct gravity_props *props,
double
dim
[
3
]);
void
pm_mesh_init_no_mesh
(
struct
pm_mesh
*
mesh
,
double
dim
[
3
]);
void
pm_mesh_compute_potential
(
struct
pm_mesh
*
mesh
,
const
struct
space
*
s
,
int
verbose
);
int
verbose
);
void
pm_mesh_interpolate_forces
(
const
struct
pm_mesh
*
mesh
,
const
struct
engine
*
e
,
struct
gpart
*
gparts
,
int
gcount
);
...
...
src/multipole.h
View file @
d8d71581
...
...
@@ -240,30 +240,31 @@ INLINE static void gravity_drift(struct gravity_tensors *m, double dt) {
m
->
CoM
[
2
]
+=
dz
;
#ifdef SWIFT_DEBUG_CHECKS
if
(
m
->
m_pole
.
vel
[
0
]
>
m
->
m_pole
.
max_delta_vel
[
0
])
if
(
m
->
m_pole
.
vel
[
0
]
>
m
->
m_pole
.
max_delta_vel
[
0
])
error
(
"Invalid maximal velocity"
);
if
(
m
->
m_pole
.
vel
[
0
]
<
m
->
m_pole
.
min_delta_vel
[
0
])
if
(
m
->
m_pole
.
vel
[
0
]
<
m
->
m_pole
.
min_delta_vel
[
0
])
error
(
"Invalid minimal velocity"
);
if
(
m
->
m_pole
.
vel
[
1
]
>
m
->
m_pole
.
max_delta_vel
[
1
])
if
(
m
->
m_pole
.
vel
[
1
]
>
m
->
m_pole
.
max_delta_vel
[
1
])
error
(
"Invalid maximal velocity"
);
if
(
m
->
m_pole
.
vel
[
1
]
<
m
->
m_pole
.
min_delta_vel
[
1
])
if
(
m
->
m_pole
.
vel
[
1
]
<
m
->
m_pole
.
min_delta_vel
[
1
])
error
(
"Invalid minimal velocity"
);
if
(
m
->
m_pole
.
vel
[
2
]
>
m
->
m_pole
.
max_delta_vel
[
2
])
if
(
m
->
m_pole
.
vel
[
2
]
>
m
->
m_pole
.
max_delta_vel
[
2
])
error
(
"Invalid maximal velocity"
);
if
(
m
->
m_pole
.
vel
[
2
]
<
m
->
m_pole
.
min_delta_vel
[
2
])
if
(
m
->
m_pole
.
vel
[
2
]
<
m
->
m_pole
.
min_delta_vel
[
2
])
error
(
"Invalid minimal velocity"
);
#endif
/* Maximal distance covered by any particle */
float
dv
[
3
];
dv
[
0
]
=
max
(
m
->
m_pole
.
max_delta_vel
[
0
]
-
m
->
m_pole
.
vel
[
0
],
m
->
m_pole
.
vel
[
0
]
-
m
->
m_pole
.
min_delta_vel
[
0
]);
m
->
m_pole
.
vel
[
0
]
-
m
->
m_pole
.
min_delta_vel
[
0
]);
dv
[
1
]
=
max
(
m
->
m_pole
.
max_delta_vel
[
1
]
-
m
->
m_pole
.
vel
[
1
],
m
->
m_pole
.
vel
[
1
]
-
m
->
m_pole
.
min_delta_vel
[
1
]);
m
->
m_pole
.
vel
[
1
]
-
m
->
m_pole
.
min_delta_vel
[
1
]);
dv
[
2
]
=
max
(
m
->
m_pole
.
max_delta_vel
[
2
]
-
m
->
m_pole
.
vel
[
2
],
m
->
m_pole
.
vel
[
2
]
-
m
->
m_pole
.
min_delta_vel
[
2
]);
m
->
m_pole
.
vel
[
2
]
-
m
->
m_pole
.
min_delta_vel
[
2
]);
const
float
max_delta_vel
=
sqrt
(
dv
[
0
]
*
dv
[
0
]
+
dv
[
1
]
*
dv
[
1
]
+
dv
[
2
]
*
dv
[
2
]);
const
float
max_delta_vel
=
sqrt
(
dv
[
0
]
*
dv
[
0
]
+
dv
[
1
]
*
dv
[
1
]
+
dv
[
2
]
*
dv
[
2
]);
const
float
x_diff
=
max_delta_vel
*
dt
;
/* Conservative change in maximal radius containing all gpart */
...
...
src/runner.c
View file @
d8d71581
...
...
@@ -1666,7 +1666,8 @@ void runner_do_end_force(struct runner *r, struct cell *c, int timer) {
const
float
G_newton
=
e
->
physical_constants
->
const_newton_G
;
const
double
r_s
=
e
->
mesh
->
r_s
;
const
double
volume
=
s
->
dim
[
0
]
*
s
->
dim
[
1
]
*
s
->
dim
[
2
];
const
float
potential_normalisation
=
4
.
*
M_PI
*
e
->
total_mass
*
r_s
*
r_s
/
volume
;
const
float
potential_normalisation
=
4
.
*
M_PI
*
e
->
total_mass
*
r_s
*
r_s
/
volume
;
TIMER_TIC
;
...
...
src/runner_doiact_grav.h
View file @
d8d71581
...
...
@@ -24,8 +24,8 @@
#include
"active.h"
#include
"cell.h"
#include
"gravity.h"
#include
"gravity_iact.h"
#include
"gravity_cache.h"
#include
"gravity_iact.h"
#include
"inline.h"
#include
"part.h"
#include
"space_getsid.h"
...
...
src/space.c
View file @
d8d71581
...
...
@@ -1903,17 +1903,17 @@ void space_split_recursive(struct space *s, struct cell *c,
CoM
[
1
]
+=
m
->
CoM
[
1
]
*
m
->
m_pole
.
M_000
;
CoM
[
2
]
+=
m
->
CoM
[
2
]
*
m
->
m_pole
.
M_000
;
vel
[
0
]
+=
m
->
m_pole
.
vel
[
0
]
*
m
->
m_pole
.
M_000
;
vel
[
1
]
+=
m
->
m_pole
.
vel
[
1
]
*
m
->
m_pole
.
M_000
;
vel
[
2
]
+=
m
->
m_pole
.
vel
[
2
]
*
m
->
m_pole
.
M_000
;
vel
[
0
]
+=
m
->
m_pole
.
vel
[
0
]
*
m
->
m_pole
.
M_000
;
vel
[
1
]
+=
m
->
m_pole
.
vel
[
1
]
*
m
->
m_pole
.
M_000
;
vel
[
2
]
+=
m
->
m_pole
.
vel
[
2
]
*
m
->
m_pole
.
M_000
;
max_delta_vel
[
0
]
=
max
(
m
->
m_pole
.
max_delta_vel
[
0
],
max_delta_vel
[
0
]);
max_delta_vel
[
1
]
=
max
(
m
->
m_pole
.
max_delta_vel
[
1
],
max_delta_vel
[
1
]);
max_delta_vel
[
2
]
=
max
(
m
->
m_pole
.
max_delta_vel
[
2
],
max_delta_vel
[
2
]);
max_delta_vel
[
0
]
=
max
(
m
->
m_pole
.
max_delta_vel
[
0
],
max_delta_vel
[
0
]);
max_delta_vel
[
1
]
=
max
(
m
->
m_pole
.
max_delta_vel
[
1
],
max_delta_vel
[
1
]);
max_delta_vel
[
2
]
=
max
(
m
->
m_pole
.
max_delta_vel
[
2
],
max_delta_vel
[
2
]);
min_delta_vel
[
0
]
=
min
(
m
->
m_pole
.
min_delta_vel
[
0
],
min_delta_vel
[
0
]);
min_delta_vel
[
1
]
=
min
(
m
->
m_pole
.
min_delta_vel
[
1
],
min_delta_vel
[
1
]);
min_delta_vel
[
2
]
=
min
(
m
->
m_pole
.
min_delta_vel
[
2
],
min_delta_vel
[
2
]);
min_delta_vel
[
0
]
=
min
(
m
->
m_pole
.
min_delta_vel
[
0
],
min_delta_vel
[
0
]);
min_delta_vel
[
1
]
=
min
(
m
->
m_pole
.
min_delta_vel
[
1
],
min_delta_vel
[
1
]);
min_delta_vel
[
2
]
=
min
(
m
->
m_pole
.
min_delta_vel
[
2
],
min_delta_vel
[
2
]);
}
}
...
...
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