diff --git a/src/align.h b/src/align.h index 54435c4c9baa1ce9dc511e2903b7e2be2d6655de..35b7f0848f4901b65f5580adf2f14bb6dc13e387 100644 --- a/src/align.h +++ b/src/align.h @@ -49,11 +49,11 @@ * @param alignment The alignment in bytes of the array. */ #if defined(__ICC) -#define swift_align_information(array, alignment) \ +#define swift_align_information(type, array, alignment) \ __assume_aligned(array, alignment); #elif defined(__GNUC__) -#define swift_align_information(array, alignment) \ - array = __builtin_assume_aligned(array, alignment); +#define swift_align_information(type, array, alignment) \ + array = (type *)__builtin_assume_aligned(array, alignment); #else #define swift_align_information(array, alignment) ; #endif @@ -72,7 +72,7 @@ */ #define swift_declare_aligned_ptr(type, array, ptr, alignment) \ type *restrict array = ptr; \ - swift_align_information(array, alignment); + swift_align_information(type, array, alignment); /** * @brief Macro to tell the compiler that a given number is 0 modulo a given diff --git a/src/clocks.c b/src/clocks.c index 4b8b269143bb3dba606c77a00eaf12b3b614eb8f..fbaa83f15fafda23751d5d6c34d40750132287b5 100644 --- a/src/clocks.c +++ b/src/clocks.c @@ -45,7 +45,7 @@ static unsigned long long clocks_cpufreq = 0; static ticks clocks_start = 0; /* The units of any returned times. */ -static char *clocks_units[] = {"ms", "~ms"}; +static const char *clocks_units[] = {"ms", "~ms"}; static int clocks_units_index = 0; static double clocks_units_scale = 1000.0; diff --git a/src/common_io.c b/src/common_io.c index 78bbba804ca8a2bf445bdf44180945d84d253aad..77bb403d19db0e911540124bb109f2c853028756 100644 --- a/src/common_io.c +++ b/src/common_io.c @@ -142,7 +142,7 @@ int io_is_double_precision(enum IO_DATA_TYPE type) { * * Calls #error() if an error occurs. */ -void io_read_attribute(hid_t grp, char* name, enum IO_DATA_TYPE type, +void io_read_attribute(hid_t grp, const char* name, enum IO_DATA_TYPE type, void* data) { hid_t h_attr = 0, h_err = 0; @@ -173,7 +173,7 @@ void io_read_attribute(hid_t grp, char* name, enum IO_DATA_TYPE type, void io_write_attribute(hid_t grp, const char* name, enum IO_DATA_TYPE type, void* data, int num) { hid_t h_space = 0, h_attr = 0, h_err = 0; - hsize_t dim[1] = {num}; + hsize_t dim[1] = {(hsize_t)num}; h_space = H5Screate(H5S_SIMPLE); if (h_space < 0) { diff --git a/src/common_io.h b/src/common_io.h index d37b52a13a1420fb325b054de13a62bbc4ad17aa..c317238160e45a9d141619d313e47c715adf8537 100644 --- a/src/common_io.h +++ b/src/common_io.h @@ -60,7 +60,7 @@ hid_t io_hdf5_type(enum IO_DATA_TYPE type); size_t io_sizeof_type(enum IO_DATA_TYPE type); int io_is_double_precision(enum IO_DATA_TYPE type); -void io_read_attribute(hid_t grp, char* name, enum IO_DATA_TYPE type, +void io_read_attribute(hid_t grp, const char* name, enum IO_DATA_TYPE type, void* data); void io_write_attribute(hid_t grp, const char* name, enum IO_DATA_TYPE type, diff --git a/src/engine.c b/src/engine.c index 7c1a695c7d6e7361a1a04464e0c3848761df62c3..52f5b8f9e4a972d24fd2d60c5b0b09ccec3012ba 100644 --- a/src/engine.c +++ b/src/engine.c @@ -3489,7 +3489,7 @@ int engine_marktasks(struct engine *e) { int rebuild_space = 0; /* Run through the tasks and mark as skip or not. */ - size_t extra_data[3] = {(size_t)e, rebuild_space, (size_t)&e->sched}; + size_t extra_data[3] = {(size_t)e, (size_t)rebuild_space, (size_t)&e->sched}; threadpool_map(&e->threadpool, engine_marktasks_mapper, s->tasks, s->nr_tasks, sizeof(struct task), 0, extra_data); rebuild_space = extra_data[1]; @@ -5434,7 +5434,7 @@ void engine_config(int restart, struct engine *e, if (e->nodeID == 0) { /* When restarting append to these files. */ - char *mode; + const char *mode; if (restart) mode = "a"; else diff --git a/src/gravity_cache.h b/src/gravity_cache.h index 097e4e1cb36e74ddb548fb3ab74196dd66512e6e..d46dc3cb1f307aee0b5c7352ea3c5b27b640cfdc 100644 --- a/src/gravity_cache.h +++ b/src/gravity_cache.h @@ -187,8 +187,9 @@ __attribute__((always_inline)) INLINE static void gravity_cache_populate( /* Particles used for padding should get impossible positions * that have a reasonable magnitude. We use the cell width for this */ - const float pos_padded[3] = {-2. * cell->width[0], -2. * cell->width[1], - -2. * cell->width[2]}; + const float pos_padded[3] = {-2.f * (float)cell->width[0], + -2.f * (float)cell->width[1], + -2.f * (float)cell->width[2]}; const float eps_padded = epsilon[0]; /* Pad the caches */ @@ -247,8 +248,9 @@ gravity_cache_populate_no_mpole(timebin_t max_active_bin, /* Particles used for padding should get impossible positions * that have a reasonable magnitude. We use the cell width for this */ - const float pos_padded[3] = {-2. * cell->width[0], -2. * cell->width[1], - -2. * cell->width[2]}; + const float pos_padded[3] = {-2.f * (float)cell->width[0], + -2.f * (float)cell->width[1], + -2.f * (float)cell->width[2]}; const float eps_padded = epsilon[0]; /* Pad the caches */ diff --git a/src/io_properties.h b/src/io_properties.h index 7afd22a7dc5cb81571e098e7d1b4a1b1efc30682..17db123ba8325ede0c7af4e4b005e359cace7a7f 100644 --- a/src/io_properties.h +++ b/src/io_properties.h @@ -113,7 +113,7 @@ struct io_props { * Do not call this function directly. Use the macro defined above. */ INLINE static struct io_props io_make_input_field_( - char name[FIELD_BUFFER_SIZE], enum IO_DATA_TYPE type, int dimension, + const char name[FIELD_BUFFER_SIZE], enum IO_DATA_TYPE type, int dimension, enum DATA_IMPORTANCE importance, enum unit_conversion_factor units, char* field, size_t partSize) { struct io_props r; @@ -155,7 +155,7 @@ INLINE static struct io_props io_make_input_field_( * Do not call this function directly. Use the macro defined above. */ INLINE static struct io_props io_make_output_field_( - char name[FIELD_BUFFER_SIZE], enum IO_DATA_TYPE type, int dimension, + const char name[FIELD_BUFFER_SIZE], enum IO_DATA_TYPE type, int dimension, enum unit_conversion_factor units, char* field, size_t partSize) { struct io_props r; strcpy(r.name, name); @@ -198,7 +198,7 @@ INLINE static struct io_props io_make_output_field_( * Do not call this function directly. Use the macro defined above. */ INLINE static struct io_props io_make_output_field_convert_part_FLOAT( - char name[FIELD_BUFFER_SIZE], enum IO_DATA_TYPE type, int dimension, + const char name[FIELD_BUFFER_SIZE], enum IO_DATA_TYPE type, int dimension, enum unit_conversion_factor units, size_t partSize, const struct part* parts, conversion_func_part_float functionPtr) { @@ -235,7 +235,7 @@ INLINE static struct io_props io_make_output_field_convert_part_FLOAT( * Do not call this function directly. Use the macro defined above. */ INLINE static struct io_props io_make_output_field_convert_part_DOUBLE( - char name[FIELD_BUFFER_SIZE], enum IO_DATA_TYPE type, int dimension, + const char name[FIELD_BUFFER_SIZE], enum IO_DATA_TYPE type, int dimension, enum unit_conversion_factor units, size_t partSize, const struct part* parts, conversion_func_part_double functionPtr) { @@ -280,7 +280,7 @@ INLINE static struct io_props io_make_output_field_convert_part_DOUBLE( * Do not call this function directly. Use the macro defined above. */ INLINE static struct io_props io_make_output_field_convert_gpart_FLOAT( - char name[FIELD_BUFFER_SIZE], enum IO_DATA_TYPE type, int dimension, + const char name[FIELD_BUFFER_SIZE], enum IO_DATA_TYPE type, int dimension, enum unit_conversion_factor units, size_t gpartSize, const struct gpart* gparts, conversion_func_gpart_float functionPtr) { @@ -317,7 +317,7 @@ INLINE static struct io_props io_make_output_field_convert_gpart_FLOAT( * Do not call this function directly. Use the macro defined above. */ INLINE static struct io_props io_make_output_field_convert_gpart_DOUBLE( - char name[FIELD_BUFFER_SIZE], enum IO_DATA_TYPE type, int dimension, + const char name[FIELD_BUFFER_SIZE], enum IO_DATA_TYPE type, int dimension, enum unit_conversion_factor units, size_t gpartSize, const struct gpart* gparts, conversion_func_gpart_double functionPtr) { diff --git a/src/runner_doiact.h b/src/runner_doiact.h index 2897aca0012ddab2dff0fc54eb0a2e50f3fcdbd8..0dfaba10bf2369d011f015d94ba1a778447ceda8 100644 --- a/src/runner_doiact.h +++ b/src/runner_doiact.h @@ -166,9 +166,9 @@ void DOPAIR1_NAIVE(struct runner *r, struct cell *restrict ci, const int pi_active = part_is_active(pi, e); const float hi = pi->h; const float hig2 = hi * hi * kernel_gamma2; - const float pix[3] = {pi->x[0] - (cj->loc[0] + shift[0]), - pi->x[1] - (cj->loc[1] + shift[1]), - pi->x[2] - (cj->loc[2] + shift[2])}; + const float pix[3] = {(float)(pi->x[0] - (cj->loc[0] + shift[0])), + (float)(pi->x[1] - (cj->loc[1] + shift[1])), + (float)(pi->x[2] - (cj->loc[2] + shift[2]))}; /* Loop over the parts in cj. */ for (int pjd = 0; pjd < count_j; pjd++) { @@ -180,8 +180,9 @@ void DOPAIR1_NAIVE(struct runner *r, struct cell *restrict ci, const int pj_active = part_is_active(pj, e); /* Compute the pairwise distance. */ - const float pjx[3] = {pj->x[0] - cj->loc[0], pj->x[1] - cj->loc[1], - pj->x[2] - cj->loc[2]}; + const float pjx[3] = {(float)(pj->x[0] - cj->loc[0]), + (float)(pj->x[1] - cj->loc[1]), + (float)(pj->x[2] - cj->loc[2])}; float dx[3] = {pix[0] - pjx[0], pix[1] - pjx[1], pix[2] - pjx[2]}; const float r2 = dx[0] * dx[0] + dx[1] * dx[1] + dx[2] * dx[2]; @@ -254,9 +255,9 @@ void DOPAIR2_NAIVE(struct runner *r, struct cell *restrict ci, const int pi_active = part_is_active(pi, e); const float hi = pi->h; const float hig2 = hi * hi * kernel_gamma2; - const float pix[3] = {pi->x[0] - (cj->loc[0] + shift[0]), - pi->x[1] - (cj->loc[1] + shift[1]), - pi->x[2] - (cj->loc[2] + shift[2])}; + const float pix[3] = {(float)(pi->x[0] - (cj->loc[0] + shift[0])), + (float)(pi->x[1] - (cj->loc[1] + shift[1])), + (float)(pi->x[2] - (cj->loc[2] + shift[2]))}; /* Loop over the parts in cj. */ for (int pjd = 0; pjd < count_j; pjd++) { @@ -268,8 +269,9 @@ void DOPAIR2_NAIVE(struct runner *r, struct cell *restrict ci, const float hjg2 = hj * hj * kernel_gamma2; /* Compute the pairwise distance. */ - const float pjx[3] = {pj->x[0] - cj->loc[0], pj->x[1] - cj->loc[1], - pj->x[2] - cj->loc[2]}; + const float pjx[3] = {(float)(pj->x[0] - cj->loc[0]), + (float)(pj->x[1] - cj->loc[1]), + (float)(pj->x[2] - cj->loc[2])}; float dx[3] = {pix[0] - pjx[0], pix[1] - pjx[1], pix[2] - pjx[2]}; const float r2 = dx[0] * dx[0] + dx[1] * dx[1] + dx[2] * dx[2]; @@ -333,8 +335,9 @@ void DOSELF1_NAIVE(struct runner *r, struct cell *restrict c) { const int pi_active = part_is_active(pi, e); const float hi = pi->h; const float hig2 = hi * hi * kernel_gamma2; - const float pix[3] = {pi->x[0] - c->loc[0], pi->x[1] - c->loc[1], - pi->x[2] - c->loc[2]}; + const float pix[3] = {(float)(pi->x[0] - c->loc[0]), + (float)(pi->x[1] - c->loc[1]), + (float)(pi->x[2] - c->loc[2])}; /* Loop over the parts in cj. */ for (int pjd = pid + 1; pjd < count; pjd++) { @@ -346,8 +349,9 @@ void DOSELF1_NAIVE(struct runner *r, struct cell *restrict c) { const int pj_active = part_is_active(pj, e); /* Compute the pairwise distance. */ - const float pjx[3] = {pj->x[0] - c->loc[0], pj->x[1] - c->loc[1], - pj->x[2] - c->loc[2]}; + const float pjx[3] = {(float)(pj->x[0] - c->loc[0]), + (float)(pj->x[1] - c->loc[1]), + (float)(pj->x[2] - c->loc[2])}; float dx[3] = {pix[0] - pjx[0], pix[1] - pjx[1], pix[2] - pjx[2]}; const float r2 = dx[0] * dx[0] + dx[1] * dx[1] + dx[2] * dx[2]; @@ -411,8 +415,9 @@ void DOSELF2_NAIVE(struct runner *r, struct cell *restrict c) { const int pi_active = part_is_active(pi, e); const float hi = pi->h; const float hig2 = hi * hi * kernel_gamma2; - const float pix[3] = {pi->x[0] - c->loc[0], pi->x[1] - c->loc[1], - pi->x[2] - c->loc[2]}; + const float pix[3] = {(float)(pi->x[0] - c->loc[0]), + (float)(pi->x[1] - c->loc[1]), + (float)(pi->x[2] - c->loc[2])}; /* Loop over the parts in cj. */ for (int pjd = pid + 1; pjd < count; pjd++) { @@ -424,8 +429,9 @@ void DOSELF2_NAIVE(struct runner *r, struct cell *restrict c) { const int pj_active = part_is_active(pj, e); /* Compute the pairwise distance. */ - const float pjx[3] = {pj->x[0] - c->loc[0], pj->x[1] - c->loc[1], - pj->x[2] - c->loc[2]}; + const float pjx[3] = {(float)(pj->x[0] - c->loc[0]), + (float)(pj->x[1] - c->loc[1]), + (float)(pj->x[2] - c->loc[2])}; float dx[3] = {pix[0] - pjx[0], pix[1] - pjx[1], pix[2] - pjx[2]}; const float r2 = dx[0] * dx[0] + dx[1] * dx[1] + dx[2] * dx[2]; @@ -589,7 +595,8 @@ void DOPAIR_SUBSET(struct runner *r, struct cell *restrict ci, const double pjz = pj->x[2]; /* Compute the pairwise distance. */ - float dx[3] = {pix - pjx, piy - pjy, piz - pjz}; + float dx[3] = {(float)(pix - pjx), (float)(piy - pjy), + (float)(piz - pjz)}; const float r2 = dx[0] * dx[0] + dx[1] * dx[1] + dx[2] * dx[2]; #ifdef SWIFT_DEBUG_CHECKS @@ -637,7 +644,8 @@ void DOPAIR_SUBSET(struct runner *r, struct cell *restrict ci, const double pjz = pj->x[2]; /* Compute the pairwise distance. */ - float dx[3] = {pix - pjx, piy - pjy, piz - pjz}; + float dx[3] = {(float)(pix - pjx), (float)(piy - pjy), + (float)(piz - pjz)}; const float r2 = dx[0] * dx[0] + dx[1] * dx[1] + dx[2] * dx[2]; #ifdef SWIFT_DEBUG_CHECKS @@ -746,8 +754,9 @@ void DOSELF_SUBSET(struct runner *r, struct cell *restrict ci, /* Get a hold of the ith part in ci. */ struct part *pi = &parts[ind[pid]]; - const float pix[3] = {pi->x[0] - ci->loc[0], pi->x[1] - ci->loc[1], - pi->x[2] - ci->loc[2]}; + const float pix[3] = {(float)(pi->x[0] - ci->loc[0]), + (float)(pi->x[1] - ci->loc[1]), + (float)(pi->x[2] - ci->loc[2])}; const float hi = pi->h; const float hig2 = hi * hi * kernel_gamma2; @@ -762,8 +771,9 @@ void DOSELF_SUBSET(struct runner *r, struct cell *restrict ci, struct part *restrict pj = &parts_j[pjd]; /* Compute the pairwise distance. */ - const float pjx[3] = {pj->x[0] - ci->loc[0], pj->x[1] - ci->loc[1], - pj->x[2] - ci->loc[2]}; + const float pjx[3] = {(float)(pj->x[0] - ci->loc[0]), + (float)(pj->x[1] - ci->loc[1]), + (float)(pj->x[2] - ci->loc[2])}; float dx[3] = {pix[0] - pjx[0], pix[1] - pjx[1], pix[2] - pjx[2]}; const float r2 = dx[0] * dx[0] + dx[1] * dx[1] + dx[2] * dx[2]; diff --git a/src/runner_doiact_grav.h b/src/runner_doiact_grav.h index cee0737cbae7b7d1d67d74d829447a77ada66928..bb54d9473e445a7b498ca6334dfc6ad670782e02 100644 --- a/src/runner_doiact_grav.h +++ b/src/runner_doiact_grav.h @@ -208,10 +208,10 @@ static INLINE void runner_dopair_grav_pp_full(const struct engine *e, float a_x = 0.f, a_y = 0.f, a_z = 0.f; /* Make the compiler understand we are in happy vectorization land */ - swift_align_information(cj_cache->x, SWIFT_CACHE_ALIGNMENT); - swift_align_information(cj_cache->y, SWIFT_CACHE_ALIGNMENT); - swift_align_information(cj_cache->z, SWIFT_CACHE_ALIGNMENT); - swift_align_information(cj_cache->m, SWIFT_CACHE_ALIGNMENT); + swift_align_information(float,cj_cache->x, SWIFT_CACHE_ALIGNMENT); + swift_align_information(float,cj_cache->y, SWIFT_CACHE_ALIGNMENT); + swift_align_information(float,cj_cache->z, SWIFT_CACHE_ALIGNMENT); + swift_align_information(float,cj_cache->m, SWIFT_CACHE_ALIGNMENT); swift_assume_size(gcount_padded_j, VEC_SIZE); /* Loop over every particle in the other cell. */ @@ -299,10 +299,10 @@ static INLINE void runner_dopair_grav_pp_truncated( float a_x = 0.f, a_y = 0.f, a_z = 0.f; /* Make the compiler understand we are in happy vectorization land */ - swift_align_information(cj_cache->x, SWIFT_CACHE_ALIGNMENT); - swift_align_information(cj_cache->y, SWIFT_CACHE_ALIGNMENT); - swift_align_information(cj_cache->z, SWIFT_CACHE_ALIGNMENT); - swift_align_information(cj_cache->m, SWIFT_CACHE_ALIGNMENT); + swift_align_information(float,cj_cache->x, SWIFT_CACHE_ALIGNMENT); + swift_align_information(float,cj_cache->y, SWIFT_CACHE_ALIGNMENT); + swift_align_information(float,cj_cache->z, SWIFT_CACHE_ALIGNMENT); + swift_align_information(float,cj_cache->m, SWIFT_CACHE_ALIGNMENT); swift_assume_size(gcount_padded_j, VEC_SIZE); /* Loop over every particle in the other cell. */ @@ -496,12 +496,12 @@ void runner_dopair_grav_pp(struct runner *r, struct cell *ci, struct cell *cj) { const float rmax2_j = rmax_j * rmax_j; const struct multipole *multi_i = &ci->multipole->m_pole; const struct multipole *multi_j = &cj->multipole->m_pole; - const float CoM_i[3] = {ci->multipole->CoM[0] - shift_i[0], - ci->multipole->CoM[1] - shift_i[1], - ci->multipole->CoM[2] - shift_i[2]}; - const float CoM_j[3] = {cj->multipole->CoM[0] - shift_j[0], - cj->multipole->CoM[1] - shift_j[1], - cj->multipole->CoM[2] - shift_j[2]}; + const float CoM_i[3] = {(float)(ci->multipole->CoM[0] - shift_i[0]), + (float)(ci->multipole->CoM[1] - shift_i[1]), + (float)(ci->multipole->CoM[2] - shift_i[2])}; + const float CoM_j[3] = {(float)(cj->multipole->CoM[0] - shift_j[0]), + (float)(cj->multipole->CoM[1] - shift_j[1]), + (float)(cj->multipole->CoM[2] - shift_j[2])}; /* Start by constructing particle caches */ @@ -686,10 +686,10 @@ void runner_doself_grav_pp_full(struct runner *r, struct cell *c) { float a_x = 0.f, a_y = 0.f, a_z = 0.f; /* Make the compiler understand we are in happy vectorization land */ - swift_align_information(ci_cache->x, SWIFT_CACHE_ALIGNMENT); - swift_align_information(ci_cache->y, SWIFT_CACHE_ALIGNMENT); - swift_align_information(ci_cache->z, SWIFT_CACHE_ALIGNMENT); - swift_align_information(ci_cache->m, SWIFT_CACHE_ALIGNMENT); + swift_align_information(float,ci_cache->x, SWIFT_CACHE_ALIGNMENT); + swift_align_information(float,ci_cache->y, SWIFT_CACHE_ALIGNMENT); + swift_align_information(float,ci_cache->z, SWIFT_CACHE_ALIGNMENT); + swift_align_information(float,ci_cache->m, SWIFT_CACHE_ALIGNMENT); swift_assume_size(gcount_padded, VEC_SIZE); /* Loop over every other particle in the cell. */ @@ -812,10 +812,10 @@ void runner_doself_grav_pp_truncated(struct runner *r, struct cell *c) { float a_x = 0.f, a_y = 0.f, a_z = 0.f; /* Make the compiler understand we are in happy vectorization land */ - swift_align_information(ci_cache->x, SWIFT_CACHE_ALIGNMENT); - swift_align_information(ci_cache->y, SWIFT_CACHE_ALIGNMENT); - swift_align_information(ci_cache->z, SWIFT_CACHE_ALIGNMENT); - swift_align_information(ci_cache->m, SWIFT_CACHE_ALIGNMENT); + swift_align_information(float,ci_cache->x, SWIFT_CACHE_ALIGNMENT); + swift_align_information(float,ci_cache->y, SWIFT_CACHE_ALIGNMENT); + swift_align_information(float,ci_cache->z, SWIFT_CACHE_ALIGNMENT); + swift_align_information(float,ci_cache->m, SWIFT_CACHE_ALIGNMENT); swift_assume_size(gcount_padded, VEC_SIZE); /* Loop over every other particle in the cell. */ diff --git a/src/single_io.c b/src/single_io.c index d0928512721e77f3672160847c148127bcb84ce5..0534094fb5b30d1b40dcd772a5ff9bebaa4799f2 100644 --- a/src/single_io.c +++ b/src/single_io.c @@ -581,7 +581,9 @@ void write_output_single(struct engine* e, const char* baseName, /* Number of unassociated gparts */ const size_t Ndm = Ntot > 0 ? Ntot - (Ngas + Nstars) : 0; - long long N_total[swift_type_count] = {Ngas, Ndm, 0, 0, Nstars, 0}; + long long N_total[swift_type_count] = {(long long)Ngas, + (long long)Ndm, 0, 0, + (long long)Nstars, 0}; /* File name */ char fileName[FILENAME_BUFFER_SIZE]; diff --git a/src/space.c b/src/space.c index 2c05cdfcb20443d281a079089c451ec1c295c1cb..3460416126dba6d386317c5b353068e6b7f792d5 100644 --- a/src/space.c +++ b/src/space.c @@ -319,12 +319,12 @@ void space_regrid(struct space *s, int verbose) { /* Get the new putative cell dimensions. */ const int cdim[3] = { - floor(s->dim[0] / - fmax(h_max * kernel_gamma * space_stretch, s->cell_min)), - floor(s->dim[1] / - fmax(h_max * kernel_gamma * space_stretch, s->cell_min)), - floor(s->dim[2] / - fmax(h_max * kernel_gamma * space_stretch, s->cell_min))}; + (int)floor(s->dim[0] / + fmax(h_max * kernel_gamma * space_stretch, s->cell_min)), + (int)floor(s->dim[1] / + fmax(h_max * kernel_gamma * space_stretch, s->cell_min)), + (int)floor(s->dim[2] / + fmax(h_max * kernel_gamma * space_stretch, s->cell_min))}; /* Check if we have enough cells for periodicity. */ if (s->periodic && (cdim[0] < 3 || cdim[1] < 3 || cdim[2] < 3)) diff --git a/src/statistics.c b/src/statistics.c index f3604a2417159abab59f84e66130449a9203e362..ed5e0f743411d501c11c7ada35d82d77c2398a3d 100644 --- a/src/statistics.c +++ b/src/statistics.c @@ -140,7 +140,7 @@ void stats_collect_part_mapper(void *map_data, int nr_parts, void *extra_data) { const double x[3] = {p->x[0], p->x[1], p->x[2]}; const float m = hydro_get_mass(p); const float entropy = hydro_get_entropy(p); - const float u_int = hydro_get_internal_energy(p); + const float u_inter = hydro_get_internal_energy(p); /* Collect mass */ stats.mass += m; @@ -162,7 +162,7 @@ void stats_collect_part_mapper(void *map_data, int nr_parts, void *extra_data) { /* Collect energies. */ stats.E_kin += 0.5f * m * (v[0] * v[0] + v[1] * v[1] + v[2] * v[2]); - stats.E_int += m * u_int; + stats.E_int += m * u_inter; stats.E_rad += cooling_get_radiated_energy(xp); if (gp != NULL) { stats.E_pot_self += m * gravity_get_potential(gp);