Commit bdb39745 authored by lhausamm's avatar lhausamm Committed by Loic Hausammann
Browse files

refactoring log part functions

parent 5038bb90
......@@ -753,7 +753,7 @@ __attribute__((always_inline)) INLINE static void hydro_first_init_part(
xp->entropy_full = p->entropy;
#ifdef WITH_LOGGER
logger_part_data_init(xp->logger_data);
logger_part_data_init(&xp->logger_data);
#endif
hydro_reset_acceleration(p);
......@@ -788,7 +788,7 @@ hydro_set_init_internal_energy(struct part *p, float u_init) {
__attribute__((always_inline)) INLINE static int xpart_should_write(
const struct xpart *xp, const struct engine *e) {
return (xp->logger.last_output > e->log->delta_step);
return (xp->logger_data.last_output > e->log->delta_step);
}
#endif
......
......@@ -211,7 +211,7 @@ __attribute__((always_inline)) INLINE static void hydro_write_index(
UNIT_CONV_NO_UNITS, parts, id);
list[1] = io_make_output_field("Offset", ULONGLONG, 1,
UNIT_CONV_NO_UNITS, xparts, logger.last_offset);
UNIT_CONV_NO_UNITS, xparts, logger_data.last_offset);
#else
error("Cannot write index without logger");
#endif
......
......@@ -187,8 +187,8 @@ void logger_log_all(struct logger *log, struct engine *e) {
logger_mask_consts;
for(long long i=0; i < e->total_nr_parts; i++) {
logger_log_part(&s->parts[i], mask, &s->xparts[i].logger_data.last_offset, log->dump);
xparts[i].logger_data.last_output = 0;
logger_log_part(log, &s->parts[i], mask, &s->xparts[i].logger_data.last_offset);
s->xparts[i].logger_data.last_output = 0;
}
if (e->total_nr_gparts > 0)
......@@ -199,13 +199,12 @@ void logger_log_all(struct logger *log, struct engine *e) {
/**
* @brief Dump a #part to the log.
*
* @param log The #logger
* @param p The #part to dump.
* @param mask The mask of the data to dump.
* @param offset Pointer to the offset of the previous log of this particle.
* @param dump The #dump in which to log the particle data.
*/
void logger_log_part(const struct part *p, const unsigned int mask, size_t *offset,
struct dump *dump) {
void logger_log_part(struct logger *log, const struct part *p, const unsigned int mask, size_t *offset) {
/* Make sure we're not writing a timestamp. */
if (mask & logger_mask_timestamp)
......@@ -216,7 +215,7 @@ void logger_log_part(const struct part *p, const unsigned int mask, size_t *offs
/* Allocate a chunk of memory in the dump of the right size. */
size_t offset_new;
char *buff = (char *)dump_get(dump, size, &offset_new);
char *buff = (char *)dump_get(log->dump, size, &offset_new);
/* Write the header. */
buff = logger_write_chunk_header(buff, &mask, offset, offset_new);
......@@ -276,13 +275,12 @@ void logger_log_part(const struct part *p, const unsigned int mask, size_t *offs
/**
* @brief Dump a #gpart to the log.
*
* @param log The #logger
* @param p The #gpart to dump.
* @param mask The mask of the data to dump.
* @param offset Pointer to the offset of the previous log of this particle.
* @param dump The #dump in which to log the particle data.
*/
void logger_log_gpart(const struct gpart *p, const unsigned int mask, size_t *offset,
struct dump *dump) {
void logger_log_gpart(struct logger *log, const struct gpart *p, const unsigned int mask, size_t *offset) {
/* Make sure we're not writing a timestamp. */
if (mask & logger_mask_timestamp)
......@@ -297,7 +295,7 @@ void logger_log_gpart(const struct gpart *p, const unsigned int mask, size_t *of
/* Allocate a chunk of memory in the dump of the right size. */
size_t offset_new;
char *buff = (char *)dump_get(dump, size, &offset_new);
char *buff = (char *)dump_get(log->dump, size, &offset_new);
/* Write the header. */
buff = logger_write_chunk_header(buff, &mask, offset, offset_new);
......
......@@ -123,22 +123,22 @@ extern const unsigned int logger_data_size[];
/* Function prototypes. */
int logger_compute_chunk_size(unsigned int mask);
void logger_log_all(struct logger *log, struct engine *e);
void logger_log_part(const struct part *p, const unsigned int mask, size_t *offset,
struct dump *dump);
void logger_log_gpart(const struct gpart *p, const unsigned int mask, size_t *offset,
struct dump *dump);
void logger_log_part(struct logger *log, const struct part *p, const unsigned int mask, size_t *offset);
void logger_log_gpart(struct logger *log, const struct gpart *p, const unsigned int mask, size_t *offset);
void logger_init(struct logger *log, const struct swift_params *params, const struct engine *e);
void logger_clean(struct logger *log);
void logger_log_timestamp(struct logger *log, integertime_t t, size_t *offset);
void logger_ensure_size(struct logger *log, size_t total_nr_parts,
size_t total_nr_gparts, size_t total_nr_sparts);
void logger_write_file_header(struct logger *log, const struct engine* e);
int logger_read_part(struct part *p, size_t *offset, const char *buff);
int logger_read_gpart(struct gpart *p, size_t *offset, const char *buff);
int logger_read_timestamp(unsigned long long int *t, size_t *offset,
const char *buff);
void logger_write_file_header(struct logger *log, const struct engine* e);
void logger_const_init(struct logger_const* log_const);
void logger_const_free(struct logger_const* log_const);
void logger_ensure_size(struct logger *log, size_t total_nr_parts,
size_t total_nr_gparts, size_t total_nr_sparts);
#endif /* WITH_LOGGER */
......
......@@ -53,9 +53,9 @@ struct logger_part_data {
};
__attribute__((always_inline)) INLINE static void logger_part_data_init(
struct logger_part_data) {
xp->logger.last_offset = 0;
xp->logger.last_output = SHRT_MAX;
struct logger_part_data *logger ) {
logger->last_offset = 0;
logger->last_output = SHRT_MAX;
}
#endif // WITH_LOGGER
......
......@@ -2735,10 +2735,10 @@ void runner_do_logger(struct runner *r, struct cell *c, int timer) {
if (xpart_should_write(xp, e))
{
/* Write particle */
logger_log_part(p, logger_mask_x | logger_mask_v | logger_mask_a |
logger_log_part(e->log, p, logger_mask_x | logger_mask_v | logger_mask_a |
logger_mask_u | logger_mask_h | logger_mask_rho |
logger_mask_consts,
&xp->logger_data.last_offset, e->log->dump);
&xp->logger_data.last_offset);
//message("Offset: %lu", p->last_offset);
/* Set counter back to zero */
xp->logger_data.last_output = 0;
......
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