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

Small stylistic improvements in the line-of-sight code

parent 2fbb4023
......@@ -4524,9 +4524,7 @@ void cell_drift_part(struct cell *c, const struct engine *e, int force) {
if (c->nodeID != engine_rank) error("Drifting a foreign cell is nope.");
/* Check that we are actually going to move forward. */
if (ti_current < ti_old_part)
error("Attempt to drift to the past ti_current=%lld < ti_old_part=%lld",
ti_current, ti_old_part);
if (ti_current < ti_old_part) error("Attempt to drift to the past");
#endif
/* Early abort? */
......
......@@ -2902,8 +2902,11 @@ void engine_check_for_dumps(struct engine *e) {
break;
case output_los:
/* Compute the LoS */
do_line_of_sight(e);
/* Move on */
engine_compute_next_los_time(e);
break;
......
This diff is collapsed.
......@@ -26,8 +26,8 @@
#include "engine.h"
#include "io_properties.h"
/*
* Maps the LOS axis geometry to the simulation axis geometry.
/**
* @brief Maps the LOS axis geometry to the simulation axis geometry.
*
* Sigtlines will always shoot down the los_direction_z,
* which can map to x,y or z of the simulation geometry.
......@@ -36,106 +36,87 @@
* the plane orthogonal to the LOS direction. The random
* sightline positions are created on this plane.
*/
enum los_direction {
simulation_x_axis = 0,
simulation_y_axis = 1,
simulation_z_axis = 2
};
enum los_direction { simulation_x_axis, simulation_y_axis, simulation_z_axis };
/**
* @brief Properties of a single line-of-sight
*/
struct line_of_sight {
/* Simulation axis the LOS shoots down. */
/*! Simulation axis the LOS shoots down. */
enum los_direction zaxis;
/* The two remaining axes defining the plane orthogonal to the sightline. */
/*! The two remaining axes defining the plane orthogonal to the sightline. */
enum los_direction xaxis, yaxis;
/* Sightline position along los_direction_x. */
/*! Sightline position along los_direction_x. */
double Xpos;
/* Sightline position along los_direction_y. */
/*! Sightline position along los_direction_y. */
double Ypos;
/* Number of parts in LOS. */
size_t particles_in_los_total;
/*! Number of parts in LOS. */
int particles_in_los_total;
/* Number of parts in LOS on this node. */
size_t particles_in_los_local;
/*! Number of parts in LOS on this node. */
int particles_in_los_local;
/* Is the simulation periodic? */
/*! Is the simulation periodic? */
int periodic;
/* Dimensions of the space. */
/*! Dimensions of the space. */
double dim[3];
/* How many top level cells does ths LOS intersect? */
/*! How many top level cells does ths LOS intersect? */
int num_intersecting_top_level_cells;
/* The min--max range to consider for parts in LOS. */
/*! The min--max range to consider for parts in LOS. */
double range_when_shooting_down_axis[2];
};
/**
* @brief Properties of the line-of-sight computation
*/
struct los_props {
/* Number of sightlines shooting down simulation z axis. */
/*! Number of sightlines shooting down simulation z axis. */
int num_along_z;
/* Number of sightlines shooting down simulation x axis. */
/*! Number of sightlines shooting down simulation x axis. */
int num_along_x;
/* Number of sightlines shooting down simulation y axis. */
/*! Number of sightlines shooting down simulation y axis. */
int num_along_y;
/* Total number of sightlines. */
/*! Total number of sightlines. */
int num_tot;
/* The min--max range along the simulation x axis random sightlines are
/*! The min--max range along the simulation x axis random sightlines are
* allowed. */
double allowed_losrange_x[2];
/* The min--max range along the simulation y axis random sightlines are
/*! The min--max range along the simulation y axis random sightlines are
* allowed. */
double allowed_losrange_y[2];
/* The min--max range along the simulation z axis random sightlines are
/*! The min--max range along the simulation z axis random sightlines are
* allowed. */
double allowed_losrange_z[2];
/* The min--max range to consider when LOS is shooting down each
* simulation axis. */
/*! 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. */
/*! Base name for line of sight HDF5 files. */
char basename[200];
};
double los_periodic(double x, double dim);
void generate_sightlines(struct line_of_sight *Los,
const struct los_props *params, const int periodic,
const double dim[3]);
void print_los_info(const struct line_of_sight *Los, const int i);
void do_line_of_sight(struct engine *e);
void los_init(double dim[3], struct los_props *los_params,
void los_init(const double dim[3], struct los_props *los_params,
struct swift_params *params);
void write_los_hdf5_datasets(hid_t grp, int j, size_t N,
const struct part *parts, struct engine *e,
const struct xpart *xparts);
void write_los_hdf5_dataset(const struct io_props p, size_t N, int j,
struct engine *e, hid_t grp);
void write_hdf5_header(hid_t h_file, const struct engine *e,
const struct los_props *LOS_params,
const size_t total_num_parts_in_los);
void create_sightline(const double Xpos, const double Ypos,
enum los_direction xaxis, enum los_direction yaxis,
enum los_direction zaxis, const int periodic,
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_restore(const struct los_props *internal_los, FILE *stream);
int does_los_intersect(const struct cell *c, const struct line_of_sight *los);
void find_intersecting_top_level_cells(const struct engine *e,
struct line_of_sight *los,
int *los_cells_top,
const struct cell *cells,
const int *local_cells_with_particles,
const int nr_local_cells_with_particles);
#endif /* SWIFT_LOS_H */
......@@ -31,7 +31,6 @@
/* Local headers */
#include "error.h"
#include "hydro.h"
#include "line_of_sight.h"
#include "threadpool.h"
/**
......
......@@ -29,6 +29,7 @@
struct engine;
struct unit_system;
struct io_props;
void read_ic_single(const char* fileName,
const struct unit_system* internal_units, double dim[3],
......@@ -47,13 +48,12 @@ void write_output_single(struct engine* e,
#endif /* HAVE_HDF5 && !WITH_MPI */
#ifdef HAVE_HDF5
#include "io_properties.h"
void write_array_single(const struct engine* e, hid_t grp, char* fileName,
FILE* xmfFile, char* partTypeGroupName,
const struct io_props props, size_t N,
const struct unit_system* internal_units,
const struct unit_system* snapshot_units);
#endif
#endif /* HAVE_HDF5 */
#endif /* SWIFT_SINGLE_IO_H */
Markdown is supported
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