Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
SWIFTsim
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
72
Issues
72
List
Boards
Labels
Milestones
Merge Requests
12
Merge Requests
12
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
SWIFT
SWIFTsim
Commits
80ec719d
Commit
80ec719d
authored
Apr 18, 2018
by
lhausamm
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Rebasing corrections
parent
f5d2a8bb
Changes
9
Show whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
69 additions
and
50 deletions
+69
-50
examples/main.c
examples/main.c
+1
-1
src/chemistry.c
src/chemistry.c
+4
-4
src/chemistry.h
src/chemistry.h
+2
-2
src/chemistry/gear/chemistry.h
src/chemistry/gear/chemistry.h
+5
-24
src/chemistry/gear/chemistry_io.h
src/chemistry/gear/chemistry_io.h
+25
-2
src/cooling/grackle/cooling.h
src/cooling/grackle/cooling.h
+25
-12
src/engine.c
src/engine.c
+2
-2
src/runner.c
src/runner.c
+1
-1
src/space.c
src/space.c
+4
-2
No files found.
examples/main.c
View file @
80ec719d
...
...
@@ -124,7 +124,7 @@ int main(int argc, char *argv[]) {
/* Structs used by the engine. Declare now to make sure these are always in
* scope. */
struct
chemistry_data
chemistry
;
struct
chemistry_
global_
data
chemistry
;
struct
cooling_function_data
cooling_func
;
struct
cosmology
cosmo
;
struct
external_potential
potential
;
...
...
src/chemistry.c
View file @
80ec719d
...
...
@@ -58,9 +58,9 @@ void chemistry_print(const struct chemistry_global_data* data) {
* @param chemistry the struct
* @param stream the file stream
*/
void
chemistry_struct_dump
(
const
struct
chemistry_data
*
chemistry
,
void
chemistry_struct_dump
(
const
struct
chemistry_
global_
data
*
chemistry
,
FILE
*
stream
)
{
restart_write_blocks
((
void
*
)
chemistry
,
sizeof
(
struct
chemistry_data
),
1
,
restart_write_blocks
((
void
*
)
chemistry
,
sizeof
(
struct
chemistry_
global_
data
),
1
,
stream
,
"chemistry"
,
"chemistry function"
);
}
...
...
@@ -71,8 +71,8 @@ void chemistry_struct_dump(const struct chemistry_data* chemistry,
* @param chemistry the struct
* @param stream the file stream
*/
void
chemistry_struct_restore
(
const
struct
chemistry_data
*
chemistry
,
void
chemistry_struct_restore
(
const
struct
chemistry_
global_
data
*
chemistry
,
FILE
*
stream
)
{
restart_read_blocks
((
void
*
)
chemistry
,
sizeof
(
struct
chemistry_data
),
1
,
restart_read_blocks
((
void
*
)
chemistry
,
sizeof
(
struct
chemistry_
global_
data
),
1
,
stream
,
NULL
,
"chemistry function"
);
}
src/chemistry.h
View file @
80ec719d
...
...
@@ -51,9 +51,9 @@ void chemistry_init(const struct swift_params* parameter_file,
void
chemistry_print
(
const
struct
chemistry_global_data
*
data
);
/* Dump/restore. */
void
chemistry_struct_dump
(
const
struct
chemistry_data
*
chemistry
,
void
chemistry_struct_dump
(
const
struct
chemistry_
global_
data
*
chemistry
,
FILE
*
stream
);
void
chemistry_struct_restore
(
const
struct
chemistry_data
*
chemistry
,
void
chemistry_struct_restore
(
const
struct
chemistry_
global_
data
*
chemistry
,
FILE
*
stream
);
#endif
/* SWIFT_CHEMISTRY_H */
src/chemistry/gear/chemistry.h
View file @
80ec719d
...
...
@@ -38,18 +38,6 @@
#include "physical_constants.h"
#include "units.h"
/**
* @brief Return a string containing the name of a given #chemistry_element.
*/
__attribute__
((
always_inline
))
INLINE
static
const
char
*
chemistry_get_element_name
(
enum
chemistry_element
elem
)
{
static
const
char
*
chemistry_element_names
[
chemistry_element_count
]
=
{
"Oxygen"
,
"Magnesium"
,
"Sulfur"
,
"Iron"
,
"Zinc"
,
"Strontium"
,
"Yttrium"
,
"Barium"
,
"Europium"
};
return
chemistry_element_names
[
elem
];
}
/**
* @brief Compute the metal mass fraction
...
...
@@ -81,16 +69,6 @@ static INLINE void chemistry_init_backend(
chemistry_read_parameters
(
parameter_file
,
us
,
phys_const
,
data
);
}
/**
* @brief Prints the properties of the chemistry model to stdout.
*
* @brief The #chemistry_global_data containing information about the current model.
*/
static
INLINE
void
chemistry_print_backend
(
const
struct
chemistry_global_data
*
data
)
{
message
(
"Chemistry function is 'Gear'."
);
}
/**
* @brief Prepares a particle for the smooth metal calculation.
*
...
...
@@ -155,8 +133,11 @@ __attribute__((always_inline)) INLINE static void chemistry_end_density(
* @param data The global chemistry information.
*/
__attribute__
((
always_inline
))
INLINE
static
void
chemistry_first_init_part
(
struct
part
*
restrict
p
,
struct
xpart
*
restrict
xp
,
const
struct
chemistry_global_data
*
data
)
{
const
struct
phys_const
*
restrict
phys_const
,
const
struct
unit_system
*
restrict
us
,
const
struct
cosmology
*
restrict
cosmo
,
const
struct
chemistry_global_data
*
data
,
struct
part
*
restrict
p
,
struct
xpart
*
restrict
xp
)
{
p
->
chemistry_data
.
Z
=
data
->
initial_metallicity
;
chemistry_init_part
(
p
,
data
);
...
...
src/chemistry/gear/chemistry_io.h
View file @
80ec719d
...
...
@@ -19,14 +19,37 @@
#ifndef SWIFT_CHEMISTRY_IO_GEAR_H
#define SWIFT_CHEMISTRY_IO_GEAR_H
#include "chemistry.h"
#include "chemistry_struct.h"
#include "error.h"
#include "io_properties.h"
#include "parser.h"
#include "part.h"
#include "physical_constants.h"
#include "units.h"
/**
* @brief Return a string containing the name of a given #chemistry_element.
*/
__attribute__
((
always_inline
))
INLINE
static
const
char
*
chemistry_get_element_name
(
enum
chemistry_element
elem
)
{
static
const
char
*
chemistry_element_names
[
chemistry_element_count
]
=
{
"Oxygen"
,
"Magnesium"
,
"Sulfur"
,
"Iron"
,
"Zinc"
,
"Strontium"
,
"Yttrium"
,
"Barium"
,
"Europium"
};
return
chemistry_element_names
[
elem
];
}
/**
* @brief Prints the properties of the chemistry model to stdout.
*
* @brief The #chemistry_global_data containing information about the current model.
*/
static
INLINE
void
chemistry_print_backend
(
const
struct
chemistry_global_data
*
data
)
{
message
(
"Chemistry function is 'Gear'."
);
}
/**
* @brief Specifies which particle fields to read from a dataset
*
...
...
@@ -91,7 +114,7 @@ __attribute__((always_inline)) INLINE static int chemistry_write_particles(
* @param h_grp The HDF5 group in which to write
*/
__attribute__
((
always_inline
))
INLINE
static
void
chemistry_write_flavour
(
hid_t
h_grp
sph
)
{
hid_t
h_grp
)
{
io_write_attribute_s
(
h_grp
,
"Chemistry Model"
,
"GEAR"
);
for
(
enum
chemistry_element
i
=
chemistry_element_O
;
...
...
src/cooling/grackle/cooling.h
View file @
80ec719d
...
...
@@ -47,12 +47,16 @@
/* prototypes */
static
gr_float
cooling_time
(
const
struct
phys_const
*
restrict
phys_const
,
const
struct
unit_system
*
restrict
us
,
const
struct
cosmology
*
restrict
cosmo
,
const
struct
cooling_function_data
*
restrict
cooling
,
const
struct
part
*
restrict
p
,
struct
xpart
*
restrict
xp
);
static
double
cooling_rate
(
const
struct
phys_const
*
restrict
phys_const
,
const
struct
unit_system
*
restrict
us
,
const
struct
cosmology
*
restrict
cosmo
,
const
struct
cooling_function_data
*
restrict
cooling
,
const
struct
part
*
restrict
p
,
struct
xpart
*
restrict
xp
,
double
dt
);
...
...
@@ -144,9 +148,12 @@ __attribute__((always_inline)) INLINE static int cooling_converged(
* @param cooling The properties of the cooling function.
*/
__attribute__
((
always_inline
))
INLINE
static
void
cooling_compute_equilibrium
(
const
struct
phys_const
*
restrict
phys_const
,
const
struct
unit_system
*
restrict
us
,
const
struct
cosmology
*
restrict
cosmo
,
const
struct
cooling_function_data
*
restrict
cooling
,
const
struct
part
*
restrict
p
,
struct
xpart
*
restrict
xp
,
const
struct
cooling_function_data
*
cooling
)
{
struct
xpart
*
restrict
xp
)
{
/* get temporary data */
struct
part
p_tmp
=
*
p
;
...
...
@@ -157,9 +164,9 @@ __attribute__((always_inline)) INLINE static void cooling_compute_equilibrium(
/* compute time step */
const
double
alpha
=
0
.
01
;
double
dt
=
fabs
(
cooling_time
(
&
cooling_tmp
,
&
p_tmp
,
xp
));
cooling_rate
(
NULL
,
NULL
,
&
cooling_tmp
,
&
p_tmp
,
xp
,
dt
);
dt
=
alpha
*
fabs
(
cooling_time
(
&
cooling_tmp
,
&
p_tmp
,
xp
));
double
dt
=
fabs
(
cooling_time
(
phys_const
,
us
,
cosmo
,
&
cooling_tmp
,
&
p_tmp
,
xp
));
cooling_rate
(
phys_const
,
us
,
cosmo
,
&
cooling_tmp
,
&
p_tmp
,
xp
,
dt
);
dt
=
alpha
*
fabs
(
cooling_time
(
phys_const
,
us
,
cosmo
,
&
cooling_tmp
,
&
p_tmp
,
xp
));
/* init simple variables */
int
step
=
0
;
...
...
@@ -173,7 +180,7 @@ __attribute__((always_inline)) INLINE static void cooling_compute_equilibrium(
old
=
*
xp
;
/* update chemistry */
cooling_rate
(
NULL
,
NULL
,
&
cooling_tmp
,
&
p_tmp
,
xp
,
dt
);
cooling_rate
(
phys_const
,
us
,
cosmo
,
&
cooling_tmp
,
&
p_tmp
,
xp
,
dt
);
}
while
(
step
<
max_step
&&
!
cooling_converged
(
xp
,
&
old
,
conv_limit
));
if
(
step
==
max_step
)
...
...
@@ -191,8 +198,11 @@ __attribute__((always_inline)) INLINE static void cooling_compute_equilibrium(
* @param cooling The properties of the cooling function.
*/
__attribute__
((
always_inline
))
INLINE
static
void
cooling_first_init_part
(
const
struct
part
*
restrict
p
,
struct
xpart
*
restrict
xp
,
const
struct
cooling_function_data
*
cooling
)
{
const
struct
phys_const
*
restrict
phys_const
,
const
struct
unit_system
*
restrict
us
,
const
struct
cosmology
*
restrict
cosmo
,
const
struct
cooling_function_data
*
cooling
,
const
struct
part
*
restrict
p
,
struct
xpart
*
restrict
xp
)
{
xp
->
cooling_data
.
radiated_energy
=
0
.
f
;
...
...
@@ -226,7 +236,7 @@ __attribute__((always_inline)) INLINE static void cooling_first_init_part(
#endif // MODE >= 3
#if COOLING_GRACKLE_MODE > 0
cooling_compute_equilibrium
(
p
,
xp
,
cooling
);
cooling_compute_equilibrium
(
p
hys_const
,
us
,
cosmo
,
p
,
xp
,
cooling
);
#endif
}
...
...
@@ -567,6 +577,9 @@ __attribute__((always_inline)) INLINE static gr_float cooling_rate(
* @return cooling time
*/
__attribute__
((
always_inline
))
INLINE
static
gr_float
cooling_time
(
const
struct
phys_const
*
restrict
phys_const
,
const
struct
unit_system
*
restrict
us
,
const
struct
cosmology
*
restrict
cosmo
,
const
struct
cooling_function_data
*
restrict
cooling
,
const
struct
part
*
restrict
p
,
struct
xpart
*
restrict
xp
)
{
...
...
@@ -592,8 +605,8 @@ __attribute__((always_inline)) INLINE static gr_float cooling_time(
data
.
grid_end
=
grid_end
;
/* general particle data */
const
gr_float
energy_before
=
hydro_get_
internal_energy
(
p
);
gr_float
density
=
hydro_get_
density
(
p
);
const
gr_float
energy_before
=
hydro_get_
physical_internal_energy
(
p
,
cosmo
);
gr_float
density
=
hydro_get_
physical_density
(
p
,
cosmo
);
gr_float
energy
=
energy_before
;
/* initialize density */
...
...
@@ -646,7 +659,7 @@ __attribute__((always_inline)) INLINE static void cooling_cool_part(
const
float
hydro_du_dt
=
hydro_get_internal_energy_dt
(
p
);
/* compute cooling rate */
const
float
du_dt
=
cooling_rate
(
phys_const
,
us
,
cosmo
,
cooling
,
p
,
dt
);
const
float
du_dt
=
cooling_rate
(
phys_const
,
us
,
cosmo
,
cooling
,
p
,
xp
,
dt
);
/* record energy lost */
xp
->
cooling_data
.
radiated_energy
+=
-
du_dt
*
dt
*
hydro_get_mass
(
p
);
...
...
src/engine.c
View file @
80ec719d
...
...
@@ -5965,8 +5965,8 @@ void engine_struct_restore(struct engine *e, FILE *stream) {
cooling_struct_restore
(
cooling_func
,
stream
);
e
->
cooling_func
=
cooling_func
;
struct
chemistry_data
*
chemistry
=
(
struct
chemistry_
data
*
)
malloc
(
sizeof
(
struct
chemistry
_data
));
struct
chemistry_
global_
data
*
chemistry
=
(
struct
chemistry_
global_data
*
)
malloc
(
sizeof
(
struct
chemistry_global
_data
));
chemistry_struct_restore
(
chemistry
,
stream
);
e
->
chemistry
=
chemistry
;
...
...
src/runner.c
View file @
80ec719d
...
...
@@ -656,7 +656,7 @@ void runner_do_ghost(struct runner *r, struct cell *c, int timer) {
const
struct
space
*
s
=
e
->
s
;
const
struct
hydro_space
*
hs
=
&
s
->
hs
;
const
struct
cosmology
*
cosmo
=
e
->
cosmology
;
const
struct
chemistry_data
*
chemistry
=
e
->
chemistry
;
const
struct
chemistry_
global_
data
*
chemistry
=
e
->
chemistry
;
const
float
hydro_h_max
=
e
->
hydro_properties
->
h_max
;
const
float
eps
=
e
->
hydro_properties
->
h_tolerance
;
const
float
hydro_eta_dim
=
...
...
src/space.c
View file @
80ec719d
...
...
@@ -2648,6 +2648,8 @@ void space_first_init_parts(struct space *s,
struct
xpart
*
restrict
xp
=
s
->
xparts
;
const
struct
cosmology
*
cosmo
=
s
->
e
->
cosmology
;
const
struct
phys_const
*
phys_const
=
s
->
e
->
physical_constants
;
const
struct
unit_system
*
us
=
s
->
e
->
internal_units
;
const
float
a_factor_vel
=
cosmo
->
a
*
cosmo
->
a
;
const
struct
hydro_props
*
hydro_props
=
s
->
e
->
hydro_properties
;
...
...
@@ -2678,10 +2680,10 @@ void space_first_init_parts(struct space *s,
if
(
u_min
>
0
.
f
)
hydro_set_init_internal_energy
(
&
p
[
i
],
u_min
);
/* Also initialise the chemistry */
chemistry_first_init_part
(
&
p
[
i
],
&
xp
[
i
],
chemistry
);
chemistry_first_init_part
(
phys_const
,
us
,
cosmo
,
chemistry
,
&
p
[
i
],
&
xp
[
i
]
);
/* And the cooling */
cooling_first_init_part
(
&
p
[
i
],
&
xp
[
i
],
cool_func
);
cooling_first_init_part
(
phys_const
,
us
,
cosmo
,
cool_func
,
&
p
[
i
],
&
xp
[
i
]
);
#ifdef SWIFT_DEBUG_CHECKS
p
[
i
].
ti_drift
=
0
;
...
...
Write
Preview
Markdown
is supported
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