Commit 65bc14a7 authored by rttw52's avatar rttw52
Browse files

Line of sight now has an engine policy

parent a16f2e3e
......@@ -174,6 +174,7 @@ int main(int argc, char *argv[]) {
int with_qla = 0;
int with_eagle = 0;
int with_gear = 0;
int with_line_of_sight = 0;
int verbose = 0;
int nr_threads = 1;
int with_verbose_timers = 0;
......@@ -233,6 +234,8 @@ int main(int argc, char *argv[]) {
NULL, 0, 0),
OPT_BOOLEAN(0, "logger", &with_logger, "Run with the particle logger.",
NULL, 0, 0),
OPT_BOOLEAN(0, "line-of-sight", &with_line_of_sight,
"Run with line of sight.", NULL, 0, 0),
OPT_GROUP(" Simulation meta-options:\n"),
OPT_BOOLEAN(0, "quick-lyman-alpha", &with_qla,
......@@ -657,6 +660,18 @@ int main(int argc, char *argv[]) {
}
}
/* Check that we can write the line of sight files by testing if the
* output directory exists and is searchable and writable. */
if (with_line_of_sight) {
char losbasename[PARSER_MAX_LINE_SIZE];
parser_get_param_string(params, "LineOfSight:basename", losbasename);
const char *losdirp = dirname(losbasename);
if (access(losdirp, W_OK | X_OK) != 0) {
error("Cannot write line of sight in directory %s (%s)", losdirp,
strerror(errno));
}
}
/* Prepare the domain decomposition scheme */
struct repartition reparttype;
#ifdef WITH_MPI
......@@ -1065,7 +1080,7 @@ int main(int argc, char *argv[]) {
with_DM_background_particles, talking, dry_run, nr_nodes);
/* Initialise the line of sight properties. */
los_init(s.dim, &los_properties, params);
if (with_line_of_sight) los_init(s.dim, &los_properties, params);
if (myrank == 0) {
clocks_gettime(&toc);
......@@ -1190,6 +1205,8 @@ int main(int argc, char *argv[]) {
engine_policies |= engine_policy_structure_finding;
if (with_fof) engine_policies |= engine_policy_fof;
if (with_logger) engine_policies |= engine_policy_logger;
if (with_line_of_sight)
engine_policies |= engine_policy_line_of_sight;
/* Initialize the engine with the space and policies. */
if (myrank == 0) clocks_gettime(&tic);
......
......@@ -125,7 +125,8 @@ const char *engine_policy_names[] = {"none",
"fof search",
"time-step limiter",
"time-step sync",
"logger"};
"logger",
"line of sight"};
/** The rank of the engine as a global variable (for messages). */
int engine_rank;
......@@ -2760,6 +2761,7 @@ void engine_step(struct engine *e) {
void engine_check_for_dumps(struct engine *e) {
const int with_cosmology = (e->policy & engine_policy_cosmology);
const int with_stf = (e->policy & engine_policy_structure_finding);
const int with_los = (e->policy & engine_policy_line_of_sight);
/* What kind of output are we getting? */
enum output_type {
......@@ -2804,10 +2806,12 @@ void engine_check_for_dumps(struct engine *e) {
}
/* Do we want to write a line of sight file? */
if (e->ti_end_min > e->ti_next_los && e->ti_next_los > 0) {
if (e->ti_next_los < ti_output) {
ti_output = e->ti_next_los;
type = output_los;
if (with_los) {
if (e->ti_end_min > e->ti_next_los && e->ti_next_los > 0) {
if (e->ti_next_los < ti_output) {
ti_output = e->ti_next_los;
type = output_los;
}
}
}
......@@ -2941,10 +2945,12 @@ void engine_check_for_dumps(struct engine *e) {
}
/* Do line of sight ? */
if (e->ti_end_min > e->ti_next_los && e->ti_next_los > 0) {
if (e->ti_next_los < ti_output) {
ti_output = e->ti_next_los;
type = output_los;
if (with_los) {
if (e->ti_end_min > e->ti_next_los && e->ti_next_los > 0) {
if (e->ti_next_los < ti_output) {
ti_output = e->ti_next_los;
type = output_los;
}
}
}
......@@ -4007,6 +4013,16 @@ void engine_init(struct engine *e, struct space *s, struct swift_params *params,
parser_get_opt_param_double(params, "StructureFinding:delta_time", -1.);
}
/* Initialise line of sight output. */
if (e->policy & engine_policy_line_of_sight) {
e->time_first_los =
parser_get_opt_param_double(params, "LineOfSight:time_first", 0.);
e->a_first_los = parser_get_opt_param_double(
params, "LineOfSight:scale_factor_first", 0.1);
e->delta_time_los =
parser_get_opt_param_double(params, "LineOfSight:delta_time", -1.);
}
/* Initialise FoF calls frequency. */
if (e->policy & engine_policy_fof) {
......@@ -4489,7 +4505,9 @@ void engine_config(int restart, int fof, struct engine *e,
engine_compute_next_statistics_time(e);
/* Find the time of the first line of sight output */
engine_compute_next_los_time(e);
if (e->policy & engine_policy_line_of_sight) {
engine_compute_next_los_time(e);
}
/* Find the time of the first stf output */
if (e->policy & engine_policy_structure_finding) {
......@@ -5151,14 +5169,14 @@ void engine_init_output_lists(struct engine *e, struct swift_params *params) {
/* Deal with line of sight */
double los_time_first;
e->output_list_los = NULL;
output_list_init(&e->output_list_los, e, "LineOfSight", &e->delta_time_los,
&los_time_first);
output_list_init(&e->output_list_los, e, "LineOfSight",
&e->delta_time_los, &los_time_first);
if (e->output_list_los) {
if (e->policy & engine_policy_cosmology)
e->a_first_los = stf_time_first;
e->a_first_los = los_time_first;
else
e->time_first_los = stf_time_first;
e->time_first_los = los_time_first;
}
}
......
......@@ -79,8 +79,9 @@ enum engine_policy {
engine_policy_timestep_limiter = (1 << 21),
engine_policy_timestep_sync = (1 << 22),
engine_policy_logger = (1 << 23),
engine_policy_line_of_sight = (1 << 24),
};
#define engine_maxpolicy 24
#define engine_maxpolicy 25
extern const char *engine_policy_names[engine_maxpolicy + 1];
/**
......
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