Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
SWIFTsim
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
SWIFT
SWIFTsim
Commits
edbe0071
Commit
edbe0071
authored
6 years ago
by
Matthieu Schaller
Browse files
Options
Downloads
Patches
Plain Diff
Only read the gravity mesh related quantites if we are running with periodic BCs.
parent
b1dd226e
No related branches found
No related tags found
1 merge request
!642
Read the periodicity flag from the YAML file
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
examples/main.c
+24
-23
24 additions, 23 deletions
examples/main.c
src/gravity_properties.c
+27
-19
27 additions, 19 deletions
src/gravity_properties.c
src/gravity_properties.h
+2
-1
2 additions, 1 deletion
src/gravity_properties.h
with
53 additions
and
43 deletions
examples/main.c
+
24
−
23
View file @
edbe0071
...
...
@@ -681,6 +681,28 @@ int main(int argc, char *argv[]) {
phys_const_print
(
&
prog_const
);
}
/* Read particles and space information from ICs */
char
ICfileName
[
200
]
=
""
;
parser_get_param_string
(
params
,
"InitialConditions:file_name"
,
ICfileName
);
const
int
periodic
=
parser_get_param_int
(
params
,
"InitialConditions:periodic"
);
const
int
replicate
=
parser_get_opt_param_int
(
params
,
"InitialConditions:replicate"
,
1
);
clean_smoothing_length_values
=
parser_get_opt_param_int
(
params
,
"InitialConditions:cleanup_smoothing_lengths"
,
0
);
const
int
cleanup_h
=
parser_get_opt_param_int
(
params
,
"InitialConditions:cleanup_h_factors"
,
0
);
const
int
cleanup_sqrt_a
=
parser_get_opt_param_int
(
params
,
"InitialConditions:cleanup_velocity_factors"
,
0
);
const
int
generate_gas_in_ics
=
parser_get_opt_param_int
(
params
,
"InitialConditions:generate_gas_in_ics"
,
0
);
/* Some checks that we are not doing something stupid */
if
(
generate_gas_in_ics
&&
flag_entropy_ICs
)
error
(
"Can't generate gas if the entropy flag is set in the ICs."
);
if
(
generate_gas_in_ics
&&
!
with_cosmology
)
error
(
"Can't generate gas if the run is not cosmological."
);
/* Initialise the cosmology */
if
(
with_cosmology
)
cosmology_init
(
params
,
&
us
,
&
prog_const
,
&
cosmo
);
...
...
@@ -709,32 +731,11 @@ int main(int argc, char *argv[]) {
/* Initialise the gravity properties */
if
(
with_self_gravity
)
gravity_props_init
(
&
gravity_properties
,
params
,
&
cosmo
,
with_cosmology
);
gravity_props_init
(
&
gravity_properties
,
params
,
&
cosmo
,
with_cosmology
,
periodic
);
else
bzero
(
&
gravity_properties
,
sizeof
(
struct
gravity_props
));
/* Read particles and space information from ICs */
char
ICfileName
[
200
]
=
""
;
parser_get_param_string
(
params
,
"InitialConditions:file_name"
,
ICfileName
);
const
int
periodic
=
parser_get_param_int
(
params
,
"InitialConditions:periodic"
);
const
int
replicate
=
parser_get_opt_param_int
(
params
,
"InitialConditions:replicate"
,
1
);
clean_smoothing_length_values
=
parser_get_opt_param_int
(
params
,
"InitialConditions:cleanup_smoothing_lengths"
,
0
);
const
int
cleanup_h
=
parser_get_opt_param_int
(
params
,
"InitialConditions:cleanup_h_factors"
,
0
);
const
int
cleanup_sqrt_a
=
parser_get_opt_param_int
(
params
,
"InitialConditions:cleanup_velocity_factors"
,
0
);
const
int
generate_gas_in_ics
=
parser_get_opt_param_int
(
params
,
"InitialConditions:generate_gas_in_ics"
,
0
);
/* Some checks that we are not doing something stupid */
if
(
generate_gas_in_ics
&&
flag_entropy_ICs
)
error
(
"Can't generate gas if the entropy flag is set in the ICs."
);
if
(
generate_gas_in_ics
&&
!
with_cosmology
)
error
(
"Can't generate gas if the run is not cosmological."
);
/* Be verbose about what happens next */
if
(
myrank
==
0
)
message
(
"Reading ICs from file '%s'"
,
ICfileName
);
if
(
myrank
==
0
&&
cleanup_h
)
...
...
This diff is collapsed.
Click to expand it.
src/gravity_properties.c
+
27
−
19
View file @
edbe0071
...
...
@@ -39,7 +39,8 @@
#define gravity_props_default_rebuild_frequency 0.01f
void
gravity_props_init
(
struct
gravity_props
*
p
,
struct
swift_params
*
params
,
const
struct
cosmology
*
cosmo
,
int
with_cosmology
)
{
const
struct
cosmology
*
cosmo
,
int
with_cosmology
,
int
periodic
)
{
/* Tree updates */
p
->
rebuild_frequency
=
...
...
@@ -50,24 +51,31 @@ void gravity_props_init(struct gravity_props *p, struct swift_params *params,
error
(
"Invalid tree rebuild frequency. Must be in [0., 1.]"
);
/* Tree-PM parameters */
p
->
mesh_size
=
parser_get_param_int
(
params
,
"Gravity:mesh_side_length"
);
p
->
a_smooth
=
parser_get_opt_param_float
(
params
,
"Gravity:a_smooth"
,
gravity_props_default_a_smooth
);
p
->
r_cut_max_ratio
=
parser_get_opt_param_float
(
params
,
"Gravity:r_cut_max"
,
gravity_props_default_r_cut_max
);
p
->
r_cut_min_ratio
=
parser_get_opt_param_float
(
params
,
"Gravity:r_cut_min"
,
gravity_props_default_r_cut_min
);
/* Some basic checks */
if
(
p
->
mesh_size
%
2
!=
0
)
error
(
"The mesh side-length must be an even number."
);
if
(
p
->
a_smooth
<=
0
.)
error
(
"The mesh smoothing scale 'a_smooth' must be > 0."
);
if
(
2
.
*
p
->
a_smooth
*
p
->
r_cut_max_ratio
>
p
->
mesh_size
)
error
(
"Mesh too small given r_cut_max. Should be at least %d cells wide."
,
(
int
)(
2
.
*
p
->
a_smooth
*
p
->
r_cut_max_ratio
)
+
1
);
if
(
periodic
)
{
p
->
mesh_size
=
parser_get_param_int
(
params
,
"Gravity:mesh_side_length"
);
p
->
a_smooth
=
parser_get_opt_param_float
(
params
,
"Gravity:a_smooth"
,
gravity_props_default_a_smooth
);
p
->
r_cut_max_ratio
=
parser_get_opt_param_float
(
params
,
"Gravity:r_cut_max"
,
gravity_props_default_r_cut_max
);
p
->
r_cut_min_ratio
=
parser_get_opt_param_float
(
params
,
"Gravity:r_cut_min"
,
gravity_props_default_r_cut_min
);
/* Some basic checks of what we read */
if
(
p
->
mesh_size
%
2
!=
0
)
error
(
"The mesh side-length must be an even number."
);
if
(
p
->
a_smooth
<=
0
.)
error
(
"The mesh smoothing scale 'a_smooth' must be > 0."
);
if
(
2
.
*
p
->
a_smooth
*
p
->
r_cut_max_ratio
>
p
->
mesh_size
)
error
(
"Mesh too small given r_cut_max. Should be at least %d cells wide."
,
(
int
)(
2
.
*
p
->
a_smooth
*
p
->
r_cut_max_ratio
)
+
1
);
}
else
{
p
->
mesh_size
=
0
;
p
->
a_smooth
=
0
.
f
;
p
->
r_cut_min_ratio
=
0
.
f
;
p
->
r_cut_max_ratio
=
0
.
f
;
}
/* Time integration */
p
->
eta
=
parser_get_param_float
(
params
,
"Gravity:eta"
);
...
...
This diff is collapsed.
Click to expand it.
src/gravity_properties.h
+
2
−
1
View file @
edbe0071
...
...
@@ -88,7 +88,8 @@ struct gravity_props {
void
gravity_props_print
(
const
struct
gravity_props
*
p
);
void
gravity_props_init
(
struct
gravity_props
*
p
,
struct
swift_params
*
params
,
const
struct
cosmology
*
cosmo
,
int
with_cosmology
);
const
struct
cosmology
*
cosmo
,
int
with_cosmology
,
int
periodic
);
void
gravity_update
(
struct
gravity_props
*
p
,
const
struct
cosmology
*
cosmo
);
#if defined(HAVE_HDF5)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
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!
Save comment
Cancel
Please
register
or
sign in
to comment