Commit edbe0071 authored by Matthieu Schaller's avatar Matthieu Schaller
Browse files

Only read the gravity mesh related quantites if we are running with periodic BCs.

parent b1dd226e
......@@ -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)
......
......@@ -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");
......
......@@ -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)
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment