Skip to content
Snippets Groups Projects
Commit a16f2e3e authored by rttw52's avatar rttw52
Browse files

Can now restrict the range of LOS down the los z-axis (if you dont want it to be 0->boxsize)

parent c7262ad3
No related branches found
No related tags found
1 merge request!1050Line-of-sight output along the z-axis
...@@ -81,6 +81,21 @@ void los_init(double dim[3], struct los_props *los_params, ...@@ -81,6 +81,21 @@ void los_init(double dim[3], struct los_props *los_params,
/* Where are we saving them? */ /* Where are we saving them? */
parser_get_param_string(params, "LineOfSight:basename", los_params->basename); parser_get_param_string(params, "LineOfSight:basename", los_params->basename);
/* Min/max range allowed when sightline is shooting down x,y and z
* (simulation axes). */
los_params->range_when_shooting_down_axis[0][0] = 0.;
los_params->range_when_shooting_down_axis[0][1] = dim[0];
parser_get_opt_param_double_array(params, "LineOfSight:range_when_shooting_down_x",
2, los_params->range_when_shooting_down_axis[0]);
los_params->range_when_shooting_down_axis[1][0] = 0.;
los_params->range_when_shooting_down_axis[1][1] = dim[1];
parser_get_opt_param_double_array(params, "LineOfSight:range_when_shooting_down_y",
2, los_params->range_when_shooting_down_axis[1]);
los_params->range_when_shooting_down_axis[2][0] = 0.;
los_params->range_when_shooting_down_axis[2][1] = dim[2];
parser_get_opt_param_double_array(params, "LineOfSight:range_when_shooting_down_z",
2, los_params->range_when_shooting_down_axis[2]);
} }
/** /**
...@@ -107,7 +122,8 @@ void generate_sightlines(struct line_of_sight *Los, ...@@ -107,7 +122,8 @@ void generate_sightlines(struct line_of_sight *Los,
Ypos = ((float)rand() / (float)(RAND_MAX) * (params->allowed_losrange_y[1] - params->allowed_losrange_y[0])) + Ypos = ((float)rand() / (float)(RAND_MAX) * (params->allowed_losrange_y[1] - params->allowed_losrange_y[0])) +
params->allowed_losrange_y[0]; params->allowed_losrange_y[0];
create_sightline(Xpos, Ypos, simulation_x_axis, simulation_y_axis, create_sightline(Xpos, Ypos, simulation_x_axis, simulation_y_axis,
simulation_z_axis, periodic, dim, &Los[count]); simulation_z_axis, periodic, dim, &Los[count],
params->range_when_shooting_down_axis[simulation_z_axis]);
count += 1; count += 1;
} }
...@@ -118,7 +134,8 @@ void generate_sightlines(struct line_of_sight *Los, ...@@ -118,7 +134,8 @@ void generate_sightlines(struct line_of_sight *Los,
Ypos = ((float)rand() / (float)(RAND_MAX) * (params->allowed_losrange_z[1] - params->allowed_losrange_z[0])) + Ypos = ((float)rand() / (float)(RAND_MAX) * (params->allowed_losrange_z[1] - params->allowed_losrange_z[0])) +
params->allowed_losrange_z[0]; params->allowed_losrange_z[0];
create_sightline(Xpos, Ypos, simulation_y_axis, simulation_z_axis, create_sightline(Xpos, Ypos, simulation_y_axis, simulation_z_axis,
simulation_x_axis, periodic, dim, &Los[count]); simulation_x_axis, periodic, dim, &Los[count],
params->range_when_shooting_down_axis[simulation_x_axis]);
count += 1; count += 1;
} }
...@@ -129,7 +146,8 @@ void generate_sightlines(struct line_of_sight *Los, ...@@ -129,7 +146,8 @@ void generate_sightlines(struct line_of_sight *Los,
Ypos = ((float)rand() / (float)(RAND_MAX) * (params->allowed_losrange_z[1] - params->allowed_losrange_z[0])) + Ypos = ((float)rand() / (float)(RAND_MAX) * (params->allowed_losrange_z[1] - params->allowed_losrange_z[0])) +
params->allowed_losrange_z[0]; params->allowed_losrange_z[0];
create_sightline(Xpos, Ypos, simulation_x_axis, simulation_z_axis, create_sightline(Xpos, Ypos, simulation_x_axis, simulation_z_axis,
simulation_y_axis, periodic, dim, &Los[count]); simulation_y_axis, periodic, dim, &Los[count],
params->range_when_shooting_down_axis[simulation_y_axis]);
count += 1; count += 1;
} }
...@@ -141,7 +159,8 @@ void generate_sightlines(struct line_of_sight *Los, ...@@ -141,7 +159,8 @@ void generate_sightlines(struct line_of_sight *Los,
void create_sightline(const double Xpos, const double Ypos, void create_sightline(const double Xpos, const double Ypos,
enum los_direction xaxis, enum los_direction yaxis, enum los_direction xaxis, enum los_direction yaxis,
enum los_direction zaxis, const int periodic, enum los_direction zaxis, const int periodic,
const double dim[3], struct line_of_sight *los) { const double dim[3], struct line_of_sight *los,
const double range_when_shooting_down_axis[2]) {
los->Xpos = Xpos; los->Xpos = Xpos;
los->Ypos = Ypos; los->Ypos = Ypos;
los->particles_in_los_local = 0; los->particles_in_los_local = 0;
...@@ -154,6 +173,8 @@ void create_sightline(const double Xpos, const double Ypos, ...@@ -154,6 +173,8 @@ void create_sightline(const double Xpos, const double Ypos,
los->dim[1] = dim[1]; los->dim[1] = dim[1];
los->dim[2] = dim[2]; los->dim[2] = dim[2];
los->num_intersecting_top_level_cells = 0; los->num_intersecting_top_level_cells = 0;
los->range_when_shooting_down_axis[0] = range_when_shooting_down_axis[0];
los->range_when_shooting_down_axis[1] = range_when_shooting_down_axis[1];
} }
/** /**
...@@ -191,6 +212,11 @@ void los_first_loop_mapper(void *restrict map_data, int count, ...@@ -191,6 +212,11 @@ void los_first_loop_mapper(void *restrict map_data, int count,
/* Don't consider inhibited parts. */ /* Don't consider inhibited parts. */
if (parts[i].time_bin == time_bin_inhibited) continue; if (parts[i].time_bin == time_bin_inhibited) continue;
/* Don't consider part if outwith allowed z-range. */
if (parts[i].x[LOS_list->zaxis] < LOS_list->range_when_shooting_down_axis[0] ||
parts[i].x[LOS_list->zaxis] > LOS_list->range_when_shooting_down_axis[1])
continue;
/* Distance from this part to LOS along x dim. */ /* Distance from this part to LOS along x dim. */
dx = parts[i].x[LOS_list->xaxis] - LOS_list->Xpos; dx = parts[i].x[LOS_list->xaxis] - LOS_list->Xpos;
...@@ -515,6 +541,11 @@ void do_line_of_sight(struct engine *e) { ...@@ -515,6 +541,11 @@ void do_line_of_sight(struct engine *e) {
/* Don't consider inhibited parts. */ /* Don't consider inhibited parts. */
if (cell_parts[i].time_bin == time_bin_inhibited) continue; if (cell_parts[i].time_bin == time_bin_inhibited) continue;
/* Don't consider part if outwith allowed z-range. */
if (cell_parts[i].x[LOS_list[j].zaxis] < LOS_list[j].range_when_shooting_down_axis[0] ||
cell_parts[i].x[LOS_list[j].zaxis] > LOS_list[j].range_when_shooting_down_axis[1])
continue;
/* Distance from this part to LOS along x dim. */ /* Distance from this part to LOS along x dim. */
dx = cell_parts[i].x[LOS_list[j].xaxis] - LOS_list[j].Xpos; dx = cell_parts[i].x[LOS_list[j].xaxis] - LOS_list[j].Xpos;
......
...@@ -69,6 +69,9 @@ struct line_of_sight { ...@@ -69,6 +69,9 @@ struct line_of_sight {
/* How many top level cells does ths LOS intersect? */ /* How many top level cells does ths LOS intersect? */
int num_intersecting_top_level_cells; int num_intersecting_top_level_cells;
/* The min--max range to consider for parts in LOS. */
double range_when_shooting_down_axis[2];
}; };
struct los_props { struct los_props {
...@@ -96,6 +99,10 @@ struct los_props { ...@@ -96,6 +99,10 @@ struct los_props {
* allowed. */ * allowed. */
double allowed_losrange_z[2]; double allowed_losrange_z[2];
/* The min--max range to consider when LOS is shooting down each
* simulation axis. */
double range_when_shooting_down_axis[3][2];
/* Basename for line of sight HDF5 files. */ /* Basename for line of sight HDF5 files. */
char basename[200]; char basename[200];
}; };
...@@ -119,7 +126,8 @@ void write_hdf5_header(hid_t h_file, const struct engine *e, ...@@ -119,7 +126,8 @@ void write_hdf5_header(hid_t h_file, const struct engine *e,
void create_sightline(const double Xpos, const double Ypos, void create_sightline(const double Xpos, const double Ypos,
enum los_direction xaxis, enum los_direction yaxis, enum los_direction xaxis, enum los_direction yaxis,
enum los_direction zaxis, const int periodic, enum los_direction zaxis, const int periodic,
const double dim[3], struct line_of_sight *los); const double dim[3], struct line_of_sight *los,
const double range_when_shooting_down_axis[2]);
void los_struct_dump(const struct los_props *internal_los, FILE *stream); void los_struct_dump(const struct los_props *internal_los, FILE *stream);
void los_struct_restore(const struct los_props *internal_los, FILE *stream); void los_struct_restore(const struct los_props *internal_los, FILE *stream);
int does_los_intersect(const struct cell *c, const struct line_of_sight *los); int does_los_intersect(const struct cell *c, const struct line_of_sight *los);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment