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
9cd34399
Commit
9cd34399
authored
Apr 07, 2016
by
Matthieu Schaller
Browse files
Future-proof version of dokick that also gets time-step info from self-gravity.
parent
f7ec41dd
Changes
4
Hide whitespace changes
Inline
Side-by-side
examples/ExternalPointMass/externalPointMass.yml
View file @
9cd34399
...
...
@@ -28,7 +28,7 @@ SPH:
delta_neighbours
:
1.
# The tolerance for the targetted number of neighbours.
CFL_condition
:
0.1
# Courant-Friedrich-Levy condition for time integration.
max_ghost_iterations
:
30
# Maximal number of iterations allowed to converge towards the smoothing length.
max_smoothing_length
:
3.
# Maximal smoothing length allowed (in internal units).
max_smoothing_length
:
10.
# Maximal smoothing length allowed (in internal units).
# Parameters related to the initial conditions
InitialConditions
:
...
...
src/gravity/Default/gravity.h
View file @
9cd34399
...
...
@@ -22,7 +22,8 @@
#include
"potentials.h"
/**
* @brief Computes the gravity time-step of a given particle.
* @brief Computes the gravity time-step of a given particle due to an external
*potential.
*
* This function only branches towards the potential chosen by the user.
*
...
...
@@ -30,20 +31,40 @@
* @param phys_const The physical constants in internal units.
* @param gp Pointer to the g-particle data.
*/
__attribute__
((
always_inline
))
INLINE
static
float
gravity_compute_timestep
(
const
struct
external_potential
*
potential
,
const
struct
phys_const
*
const
phys_const
,
const
struct
gpart
*
const
gp
)
{
__attribute__
((
always_inline
))
INLINE
static
float
gravity_compute_timestep_external
(
const
struct
external_potential
*
potential
,
const
struct
phys_const
*
const
phys_const
,
const
struct
gpart
*
const
gp
)
{
float
dt
=
FLT_MAX
;
#ifdef EXTERNAL_POTENTIAL_POINTMASS
dt
=
fminf
(
dt
,
external_gravity_pointmass_timestep
(
potential
,
phys_const
,
gp
));
dt
=
fminf
(
dt
,
external_gravity_pointmass_timestep
(
potential
,
phys_const
,
gp
));
#endif
return
dt
;
}
/**
* @brief Computes the gravity time-step of a given particle due to self-gravity
*
* This function only branches towards the potential chosen by the user.
*
* @param phys_const The physical constants in internal units.
* @param gp Pointer to the g-particle data.
*/
__attribute__
((
always_inline
))
INLINE
static
float
gravity_compute_timestep_self
(
const
struct
phys_const
*
const
phys_const
,
const
struct
gpart
*
const
gp
)
{
float
dt
=
FLT_MAX
;
return
dt
;
}
/**
* @brief Initialises the g-particles for the first time
*
...
...
src/runner.c
View file @
9cd34399
...
...
@@ -111,6 +111,8 @@ void runner_dograv_external(struct runner *r, struct cell *c, int timer) {
struct
gpart
*
g
,
*
gparts
=
c
->
gparts
;
int
i
,
k
,
gcount
=
c
->
gcount
;
const
int
ti_current
=
r
->
e
->
ti_current
;
const
struct
external_potential
*
potential
=
r
->
e
->
potential
;
const
struct
phys_const
*
constants
=
r
->
e
->
physical_constants
;
TIMER_TIC
;
...
...
@@ -134,7 +136,7 @@ void runner_dograv_external(struct runner *r, struct cell *c, int timer) {
/* Is this part within the time step? */
if
(
g
->
ti_end
<=
ti_current
)
{
external_gravity
(
r
->
e
->
potential
,
r
->
e
->
physical_
constants
,
g
);
external_gravity
(
potential
,
constants
,
g
);
/* /\* check for energy and angular momentum conservation - begin by */
/* * synchronizing velocity*\/ */
...
...
@@ -900,6 +902,8 @@ void runner_dokick(struct runner *r, struct cell *c, int timer) {
struct
part
*
const
parts
=
c
->
parts
;
struct
xpart
*
const
xparts
=
c
->
xparts
;
struct
gpart
*
const
gparts
=
c
->
gparts
;
const
struct
external_potential
*
potential
=
r
->
e
->
potential
;
const
struct
phys_const
*
constants
=
r
->
e
->
physical_constants
;
const
int
is_fixdt
=
(
r
->
e
->
policy
&
engine_policy_fixdt
)
==
engine_policy_fixdt
;
...
...
@@ -941,8 +945,12 @@ void runner_dokick(struct runner *r, struct cell *c, int timer) {
}
else
{
/* Compute the next timestep (gravity condition) */
float
new_dt
=
gravity_compute_timestep
(
r
->
e
->
potential
,
r
->
e
->
physical_constants
,
gp
);
const
float
new_dt_external
=
gravity_compute_timestep_external
(
potential
,
constants
,
gp
);
const
float
new_dt_self
=
gravity_compute_timestep_self
(
constants
,
gp
);
float
new_dt
=
fminf
(
new_dt_external
,
new_dt_self
);
/* Limit timestep within the allowed range */
new_dt
=
fminf
(
new_dt
,
global_dt_max
);
...
...
@@ -1026,10 +1034,17 @@ void runner_dokick(struct runner *r, struct cell *c, int timer) {
/* Compute the next timestep (gravity condition) */
float
new_dt_grav
=
FLT_MAX
;
if
(
p
->
gpart
!=
NULL
)
new_dt_grav
=
gravity_compute_timestep
(
r
->
e
->
potential
,
r
->
e
->
physical_constants
,
p
->
gpart
);
if
(
p
->
gpart
!=
NULL
)
{
const
float
new_dt_external
=
gravity_compute_timestep_external
(
potential
,
constants
,
p
->
gpart
);
const
float
new_dt_self
=
gravity_compute_timestep_self
(
constants
,
p
->
gpart
);
new_dt_grav
=
fminf
(
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
);
/* Limit change in h */
...
...
src/space.c
View file @
9cd34399
...
...
@@ -177,10 +177,6 @@ void space_regrid(struct space *s, double cell_max, int verbose) {
}
s
->
h_max
=
h_max
;
}
}
else
{
/* It would be nice to replace this with something more physical or
* meaningful */
h_max
=
s
->
dim
[
0
]
/
16
.
f
;
}
/* If we are running in parallel, make sure everybody agrees on
...
...
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