Commit 039540fd authored by Matthieu Schaller's avatar Matthieu Schaller
Browse files

Re-factored the UnitSytem to use the same naming convention as the rest of the code.

parent 237a73ba
......@@ -149,7 +149,7 @@ external_gravity_get_potential_energy(
*/
static INLINE void potential_init_backend(
const struct swift_params* parameter_file,
const struct phys_const* phys_const, const struct UnitSystem* us,
const struct phys_const* phys_const, const struct unit_system* us,
const struct space* s, struct external_potential* potential) {
potential->x =
......
......@@ -210,7 +210,7 @@ void runner_do_cooling(struct runner *r, struct cell *c, int timer) {
const struct engine *e = r->e;
const struct cooling_function_data *cooling_func = e->cooling_func;
const struct phys_const *constants = e->physical_constants;
const struct UnitSystem *us = e->internalUnits;
const struct unit_system *us = e->internal_units;
const double timeBase = e->timeBase;
TIMER_TIC;
......
......@@ -74,8 +74,8 @@
*/
void readArray(hid_t grp, const struct io_props props, size_t N,
long long N_total, long long offset,
const struct UnitSystem* internal_units,
const struct UnitSystem* ic_units) {
const struct unit_system* internal_units,
const struct unit_system* ic_units) {
const size_t typeSize = io_sizeof_type(props.type);
const size_t copySize = typeSize * props.dimension;
......@@ -182,8 +182,8 @@ void readArray(hid_t grp, const struct io_props props, size_t N,
void prepareArray(struct engine* e, hid_t grp, char* fileName, FILE* xmfFile,
char* partTypeGroupName, const struct io_props props,
unsigned long long N_total,
const struct UnitSystem* internal_units,
const struct UnitSystem* snapshot_units) {
const struct unit_system* internal_units,
const struct unit_system* snapshot_units) {
/* Create data space */
const hid_t h_space = H5Screate(H5S_SIMPLE);
......@@ -281,14 +281,14 @@ void prepareArray(struct engine* e, hid_t grp, char* fileName, FILE* xmfFile,
* @param part_c A (char*) pointer on the first occurrence of the field of
*interest in the parts array
* @param partSize The size in bytes of the particle structure.
* @param us The UnitSystem currently in use
* @param us The unit_system currently in use
* @param convFactor The UnitConversionFactor for this arrayo
*/
void writeArray(struct engine* e, hid_t grp, char* fileName, FILE* xmfFile,
char* partTypeGroupName, const struct io_props props, size_t N,
long long N_total, int mpi_rank, long long offset,
const struct UnitSystem* internal_units,
const struct UnitSystem* snapshot_units) {
const struct unit_system* internal_units,
const struct unit_system* snapshot_units) {
const size_t typeSize = io_sizeof_type(props.type);
const size_t copySize = typeSize * props.dimension;
......@@ -424,7 +424,7 @@ void writeArray(struct engine* e, hid_t grp, char* fileName, FILE* xmfFile,
* @todo Read snapshots distributed in more than one file.
*
*/
void read_ic_serial(char* fileName, const struct UnitSystem* internal_units,
void read_ic_serial(char* fileName, const struct unit_system* internal_units,
double dim[3], struct part** parts, struct gpart** gparts,
struct spart** sparts, size_t* Ngas, size_t* Ngparts,
size_t* Nstars, int* periodic, int* flag_entropy,
......@@ -443,7 +443,7 @@ void read_ic_serial(char* fileName, const struct UnitSystem* internal_units,
long long offset[swift_type_count] = {0};
int dimension = 3; /* Assume 3D if nothing is specified */
size_t Ndm = 0;
struct UnitSystem* ic_units = malloc(sizeof(struct UnitSystem));
struct unit_system* ic_units = malloc(sizeof(struct unit_system));
/* First read some information about the content */
if (mpi_rank == 0) {
......@@ -507,7 +507,7 @@ void read_ic_serial(char* fileName, const struct UnitSystem* internal_units,
/* Read the unit system used in the ICs */
if (ic_units == NULL) error("Unable to allocate memory for IC unit system");
io_read_UnitSystem(h_file, ic_units);
io_read_unit_system(h_file, ic_units);
if (units_are_equal(ic_units, internal_units)) {
......@@ -551,7 +551,7 @@ void read_ic_serial(char* fileName, const struct UnitSystem* internal_units,
MPI_Bcast(periodic, 1, MPI_INT, 0, comm);
MPI_Bcast(&N_total, swift_type_count, MPI_LONG_LONG_INT, 0, comm);
MPI_Bcast(dim, 3, MPI_DOUBLE, 0, comm);
MPI_Bcast(ic_units, sizeof(struct UnitSystem), MPI_BYTE, 0, comm);
MPI_Bcast(ic_units, sizeof(struct unit_system), MPI_BYTE, 0, comm);
/* Divide the particles among the tasks. */
for (int ptype = 0; ptype < swift_type_count; ++ptype) {
......@@ -695,8 +695,8 @@ void read_ic_serial(char* fileName, const struct UnitSystem* internal_units,
*
* @param e The engine containing all the system.
* @param baseName The common part of the snapshot file name.
* @param internal_units The #UnitSystem used internally
* @param snapshot_units The #UnitSystem used in the snapshots
* @param internal_units The #unit_system used internally
* @param snapshot_units The #unit_system used in the snapshots
* @param mpi_rank The MPI rank of this node.
* @param mpi_size The number of MPI ranks.
* @param comm The MPI communicator.
......@@ -711,8 +711,8 @@ void read_ic_serial(char* fileName, const struct UnitSystem* internal_units,
*
*/
void write_output_serial(struct engine* e, const char* baseName,
const struct UnitSystem* internal_units,
const struct UnitSystem* snapshot_units, int mpi_rank,
const struct unit_system* internal_units,
const struct unit_system* snapshot_units, int mpi_rank,
int mpi_size, MPI_Comm comm, MPI_Info info) {
hid_t h_file = 0, h_grp = 0;
......@@ -837,10 +837,10 @@ void write_output_serial(struct engine* e, const char* baseName,
H5Gclose(h_grp);
/* Print the system of Units used in the spashot */
io_write_UnitSystem(h_file, snapshot_units, "Units");
io_write_unit_system(h_file, snapshot_units, "Units");
/* Print the system of Units used internally */
io_write_UnitSystem(h_file, internal_units, "InternalCodeUnits");
io_write_unit_system(h_file, internal_units, "InternalCodeUnits");
/* Tell the user if a conversion will be needed */
if (e->verbose) {
......
......@@ -34,7 +34,7 @@
#if defined(HAVE_HDF5) && defined(WITH_MPI) && !defined(HAVE_PARALLEL_HDF5)
void read_ic_serial(char* fileName, const struct UnitSystem* internal_units,
void read_ic_serial(char* fileName, const struct unit_system* internal_units,
double dim[3], struct part** parts, struct gpart** gparts,
struct spart** sparts, size_t* Ngas, size_t* Ngparts,
size_t* Nstars, int* periodic, int* flag_entropy,
......@@ -43,8 +43,8 @@ void read_ic_serial(char* fileName, const struct UnitSystem* internal_units,
int dry_run);
void write_output_serial(struct engine* e, const char* baseName,
const struct UnitSystem* internal_units,
const struct UnitSystem* snapshot_units, int mpi_rank,
const struct unit_system* internal_units,
const struct unit_system* snapshot_units, int mpi_rank,
int mpi_size, MPI_Comm comm, MPI_Info info);
#endif
......
......@@ -59,16 +59,16 @@
* @param h_grp The group from which to read.
* @param prop The #io_props of the field to read
* @param N The number of particles.
* @param internal_units The #UnitSystem used internally
* @param ic_units The #UnitSystem used in the ICs
* @param internal_units The #unit_system used internally
* @param ic_units The #unit_system used in the ICs
*
* @todo A better version using HDF5 hyper-slabs to read the file directly into
*the part array
* will be written once the structures have been stabilized.
*/
void readArray(hid_t h_grp, const struct io_props prop, size_t N,
const struct UnitSystem* internal_units,
const struct UnitSystem* ic_units) {
const struct unit_system* internal_units,
const struct unit_system* ic_units) {
const size_t typeSize = io_sizeof_type(prop.type);
const size_t copySize = typeSize * prop.dimension;
......@@ -163,16 +163,16 @@ void readArray(hid_t h_grp, const struct io_props prop, size_t N,
* the HDF5 file.
* @param props The #io_props of the field to read
* @param N The number of particles to write.
* @param internal_units The #UnitSystem used internally
* @param snapshot_units The #UnitSystem used in the snapshots
* @param internal_units The #unit_system used internally
* @param snapshot_units The #unit_system used in the snapshots
*
* @todo A better version using HDF5 hyper-slabs to write the file directly from
* the part array will be written once the structures have been stabilized.
*/
void writeArray(struct engine* e, hid_t grp, char* fileName, FILE* xmfFile,
char* partTypeGroupName, const struct io_props props, size_t N,
const struct UnitSystem* internal_units,
const struct UnitSystem* snapshot_units) {
const struct unit_system* internal_units,
const struct unit_system* snapshot_units) {
const size_t typeSize = io_sizeof_type(props.type);
const size_t copySize = typeSize * props.dimension;
......@@ -337,7 +337,7 @@ void writeArray(struct engine* e, hid_t grp, char* fileName, FILE* xmfFile,
* @todo Read snapshots distributed in more than one file.
*
*/
void read_ic_single(char* fileName, const struct UnitSystem* internal_units,
void read_ic_single(char* fileName, const struct unit_system* internal_units,
double dim[3], struct part** parts, struct gpart** gparts,
struct spart** sparts, size_t* Ngas, size_t* Ngparts,
size_t* Nstars, int* periodic, int* flag_entropy,
......@@ -410,9 +410,9 @@ void read_ic_single(char* fileName, const struct UnitSystem* internal_units,
H5Gclose(h_grp);
/* Read the unit system used in the ICs */
struct UnitSystem* ic_units = malloc(sizeof(struct UnitSystem));
struct unit_system* ic_units = malloc(sizeof(struct unit_system));
if (ic_units == NULL) error("Unable to allocate memory for IC unit system");
io_read_UnitSystem(h_file, ic_units);
io_read_unit_system(h_file, ic_units);
/* Tell the user if a conversion will be needed */
if (units_are_equal(ic_units, internal_units)) {
......@@ -565,8 +565,8 @@ void read_ic_single(char* fileName, const struct UnitSystem* internal_units,
*
* @param e The engine containing all the system.
* @param baseName The common part of the snapshot file name.
* @param internal_units The #UnitSystem used internally
* @param snapshot_units The #UnitSystem used in the snapshots
* @param internal_units The #unit_system used internally
* @param snapshot_units The #unit_system used in the snapshots
*
* Creates an HDF5 output file and writes the particles contained
* in the engine. If such a file already exists, it is erased and replaced
......@@ -577,8 +577,8 @@ void read_ic_single(char* fileName, const struct UnitSystem* internal_units,
*
*/
void write_output_single(struct engine* e, const char* baseName,
const struct UnitSystem* internal_units,
const struct UnitSystem* snapshot_units) {
const struct unit_system* internal_units,
const struct unit_system* snapshot_units) {
hid_t h_file = 0, h_grp = 0;
const size_t Ngas = e->s->nr_parts;
......@@ -687,10 +687,10 @@ void write_output_single(struct engine* e, const char* baseName,
H5Gclose(h_grp);
/* Print the system of Units used in the spashot */
io_write_UnitSystem(h_file, snapshot_units, "Units");
io_write_unit_system(h_file, snapshot_units, "Units");
/* Print the system of Units used internally */
io_write_UnitSystem(h_file, internal_units, "InternalCodeUnits");
io_write_unit_system(h_file, internal_units, "InternalCodeUnits");
/* Tell the user if a conversion will be needed */
if (e->verbose) {
......
......@@ -29,7 +29,7 @@
#if defined(HAVE_HDF5) && !defined(WITH_MPI)
void read_ic_single(char* fileName, const struct UnitSystem* internal_units,
void read_ic_single(char* fileName, const struct unit_system* internal_units,
double dim[3], struct part** parts, struct gpart** gparts,
struct spart** sparts, size_t* Ngas, size_t* Ndm,
size_t* Nstars, int* periodic, int* flag_entropy,
......@@ -37,8 +37,8 @@ void read_ic_single(char* fileName, const struct UnitSystem* internal_units,
int dry_run);
void write_output_single(struct engine* e, const char* baseName,
const struct UnitSystem* internal_units,
const struct UnitSystem* snapshot_units);
const struct unit_system* internal_units,
const struct unit_system* snapshot_units);
#endif
......
......@@ -37,7 +37,7 @@
* @param source the structure that has all the source term properties
*/
void sourceterms_init(const struct swift_params* parameter_file,
struct UnitSystem* us, struct sourceterms* source) {
struct unit_system* us, struct sourceterms* source) {
#ifdef SOURCETERMS_SN_FEEDBACK
supernova_init(parameter_file, us, source);
#endif /* SOURCETERMS_SN_FEEDBACK */
......
......@@ -42,7 +42,7 @@ struct sourceterms {
#endif
void sourceterms_init(const struct swift_params* parameter_file,
struct UnitSystem* us, struct sourceterms* source);
struct unit_system* us, struct sourceterms* source);
void sourceterms_print(struct sourceterms* source);
/**
......
......@@ -171,7 +171,7 @@ __attribute__((always_inline)) INLINE static void supernova_feedback_apply(
*/
__attribute__((always_inline)) INLINE static void supernova_init(
const struct swift_params* parameter_file, struct UnitSystem* us,
const struct swift_params* parameter_file, struct unit_system* us,
struct sourceterms* source) {
source->supernova.time = parser_get_param_double(parameter_file, "SN:time");
source->supernova.energy =
......
......@@ -109,7 +109,7 @@ __attribute__((always_inline)) INLINE static integertime_t get_part_timestep(
float new_dt_cooling = FLT_MAX;
if (e->policy & engine_policy_cooling)
new_dt_cooling = cooling_timestep(e->cooling_func, e->physical_constants,
e->internalUnits, p);
e->internal_units, p);
/* Compute the next timestep (gravity condition) */
float new_dt_grav = FLT_MAX;
......
......@@ -41,11 +41,11 @@
#include "error.h"
/**
* @brief Initialises the UnitSystem structure with CGS system
* @brief Initialises the unit_system structure with CGS system
*
* @param us The UnitSystem to initialize
* @param us The unit_system to initialize
*/
void units_init_cgs(struct UnitSystem* us) {
void units_init_cgs(struct unit_system* us) {
us->UnitMass_in_cgs = 1.;
us->UnitLength_in_cgs = 1.;
......@@ -55,14 +55,14 @@ void units_init_cgs(struct UnitSystem* us) {
}
/**
* @brief Initialises the UnitSystem structure with the constants given in
* @brief Initialises the unit_system structure with the constants given in
* rhe parameter file.
*
* @param us The UnitSystem to initialize.
* @param us The unit_system to initialize.
* @param params The parsed parameter file.
* @param category The section of the parameter file to read from.
*/
void units_init(struct UnitSystem* us, const struct swift_params* params,
void units_init(struct unit_system* us, const struct swift_params* params,
const char* category) {
char buffer[200];
......@@ -80,19 +80,19 @@ void units_init(struct UnitSystem* us, const struct swift_params* params,
}
/**
* @brief Initialises the UnitSystem structure with the constants given in
* @brief Initialises the unit_system structure with the constants given in
* rhe parameter file. Uses a default if the values are not present in the file.
*
* @param us The UnitSystem to initialize.
* @param us The unit_system to initialize.
* @param params The parsed parameter file.
* @param category The section of the parameter file to read from.
* @param def The default unit system to copy from if required.
*/
void units_init_default(struct UnitSystem* us,
void units_init_default(struct unit_system* us,
const struct swift_params* params, const char* category,
const struct UnitSystem* def) {
const struct unit_system* def) {
if (!def) error("Default UnitSystem not allocated");
if (!def) error("Default unit_system not allocated");
char buffer[200];
sprintf(buffer, "%s:UnitMass_in_cgs", category);
......@@ -116,11 +116,11 @@ void units_init_default(struct UnitSystem* us,
/**
* @brief Returns the base unit conversion factor for a given unit system
* @param us The UnitSystem used
* @param us The unit_system used
* @param baseUnit The base unit
*/
double units_get_base_unit(const struct UnitSystem* us,
enum BaseUnits baseUnit) {
double units_get_base_unit(const struct unit_system* us,
enum base_units baseUnit) {
switch (baseUnit) {
case UNIT_MASS:
return us->UnitMass_in_cgs;
......@@ -142,7 +142,7 @@ double units_get_base_unit(const struct UnitSystem* us,
* @brief Returns the base unit symbol used internally
* @param baseUnit The base unit
*/
const char* units_get_base_unit_internal_symbol(enum BaseUnits baseUnit) {
const char* units_get_base_unit_internal_symbol(enum base_units baseUnit) {
switch (baseUnit) {
case UNIT_MASS:
return "U_M";
......@@ -164,7 +164,7 @@ const char* units_get_base_unit_internal_symbol(enum BaseUnits baseUnit) {
* @brief Returns the base unit symbol in the cgs system
* @param baseUnit The base unit
*/
const char* units_get_base_unit_cgs_symbol(enum BaseUnits baseUnit) {
const char* units_get_base_unit_cgs_symbol(enum base_units baseUnit) {
switch (baseUnit) {
case UNIT_MASS:
return "g";
......@@ -183,7 +183,7 @@ const char* units_get_base_unit_cgs_symbol(enum BaseUnits baseUnit) {
}
void units_get_base_unit_exponants_array(float baseUnitsExp[5],
enum UnitConversionFactor unit) {
enum unit_conversion_factor unit) {
switch (unit) {
case UNIT_CONV_NO_UNITS:
break;
......@@ -337,8 +337,8 @@ void units_get_base_unit_exponants_array(float baseUnitsExp[5],
* @param us The system of units in use
* @param unit The unit to convert
*/
double units_cgs_conversion_factor(const struct UnitSystem* us,
enum UnitConversionFactor unit) {
double units_cgs_conversion_factor(const struct unit_system* us,
enum unit_conversion_factor unit) {
float baseUnitsExp[5] = {0.f};
units_get_base_unit_exponants_array(baseUnitsExp, unit);
......@@ -351,8 +351,8 @@ double units_cgs_conversion_factor(const struct UnitSystem* us,
* @param us The system of units in use
* @param unit The unit to convert
*/
float units_h_factor(const struct UnitSystem* us,
enum UnitConversionFactor unit) {
float units_h_factor(const struct unit_system* us,
enum unit_conversion_factor unit) {
float baseUnitsExp[5] = {0.f};
units_get_base_unit_exponants_array(baseUnitsExp, unit);
......@@ -365,8 +365,8 @@ float units_h_factor(const struct UnitSystem* us,
* @param us The system of units in use
* @param unit The unit to convert
*/
float units_a_factor(const struct UnitSystem* us,
enum UnitConversionFactor unit) {
float units_a_factor(const struct unit_system* us,
enum unit_conversion_factor unit) {
float baseUnitsExp[5] = {0.f};
units_get_base_unit_exponants_array(baseUnitsExp, unit);
......@@ -378,8 +378,8 @@ float units_a_factor(const struct UnitSystem* us,
* @brief Returns a string containing the exponents of the base units making up
* the conversion factors
*/
void units_cgs_conversion_string(char* buffer, const struct UnitSystem* us,
enum UnitConversionFactor unit) {
void units_cgs_conversion_string(char* buffer, const struct unit_system* us,
enum unit_conversion_factor unit) {
float baseUnitsExp[5] = {0.f};
units_get_base_unit_exponants_array(baseUnitsExp, unit);
......@@ -394,13 +394,13 @@ void units_cgs_conversion_string(char* buffer, const struct UnitSystem* us,
* @param baseUnitsExponants The exponent of each base units required to form
* the desired quantity. See conversionFactor() for a working example
*/
double units_general_cgs_conversion_factor(const struct UnitSystem* us,
double units_general_cgs_conversion_factor(const struct unit_system* us,
const float baseUnitsExponants[5]) {
double factor = 1.;
for (int i = 0; i < 5; ++i)
if (baseUnitsExponants[i] != 0)
factor *= pow(units_get_base_unit(us, (enum BaseUnits)i),
factor *= pow(units_get_base_unit(us, (enum base_units)i),
baseUnitsExponants[i]);
return factor;
}
......@@ -412,7 +412,7 @@ double units_general_cgs_conversion_factor(const struct UnitSystem* us,
* @param baseUnitsExponants The exponent of each base units required to form
* the desired quantity. See conversionFactor() for a working example
*/
float units_general_h_factor(const struct UnitSystem* us,
float units_general_h_factor(const struct unit_system* us,
const float baseUnitsExponants[5]) {
float factor_exp = 0.f;
......@@ -430,7 +430,7 @@ float units_general_h_factor(const struct UnitSystem* us,
* @param baseUnitsExponants The exponent of each base units required to form
* the desired quantity. See conversionFactor() for a working example
*/
float units_general_a_factor(const struct UnitSystem* us,
float units_general_a_factor(const struct unit_system* us,
const float baseUnitsExponants[5]) {
float factor_exp = 0.f;
......@@ -449,7 +449,7 @@ float units_general_a_factor(const struct UnitSystem* us,
* the desired quantity. See conversionFactor() for a working example
*/
void units_general_cgs_conversion_string(char* buffer,
const struct UnitSystem* us,
const struct unit_system* us,
const float baseUnitsExponants[5]) {
char temp[14];
const double a_exp = units_general_a_factor(us, baseUnitsExponants);
......@@ -493,14 +493,14 @@ void units_general_cgs_conversion_string(char* buffer,
sprintf(temp, " ");
else if (baseUnitsExponants[i] == 1.)
sprintf(temp, "%s ",
units_get_base_unit_internal_symbol((enum BaseUnits)i));
units_get_base_unit_internal_symbol((enum base_units)i));
else if (remainder(baseUnitsExponants[i], 1.) == 0)
sprintf(temp, "%s^%d ",
units_get_base_unit_internal_symbol((enum BaseUnits)i),
units_get_base_unit_internal_symbol((enum base_units)i),
(int)baseUnitsExponants[i]);
else
sprintf(temp, "%s^%7.4f ",
units_get_base_unit_internal_symbol((enum BaseUnits)i),
units_get_base_unit_internal_symbol((enum base_units)i),
baseUnitsExponants[i]);
strncat(buffer, temp, 12);
}
......@@ -513,14 +513,15 @@ void units_general_cgs_conversion_string(char* buffer,
if (baseUnitsExponants[i] == 0.)
continue;
else if (baseUnitsExponants[i] == 1.)
sprintf(temp, "%s ", units_get_base_unit_cgs_symbol((enum BaseUnits)i));
sprintf(temp, "%s ",
units_get_base_unit_cgs_symbol((enum base_units)i));
else if (remainder(baseUnitsExponants[i], 1.) == 0)
sprintf(temp, "%s^%d ",
units_get_base_unit_cgs_symbol((enum BaseUnits)i),
units_get_base_unit_cgs_symbol((enum base_units)i),
(int)baseUnitsExponants[i]);
else
sprintf(temp, "%s^%7.4f ",
units_get_base_unit_cgs_symbol((enum BaseUnits)i),
units_get_base_unit_cgs_symbol((enum base_units)i),
baseUnitsExponants[i]);
strncat(buffer, temp, 12);
}
......@@ -532,11 +533,11 @@ void units_general_cgs_conversion_string(char* buffer,
/**
* @brief Are the two unit systems equal ?
*
* @param a The First #UnitSystem
* @param b The second #UnitSystem
* @param a The First #unit_system
* @param b The second #unit_system
* @return 1 if the systems are the same, 0 otherwise
*/
int units_are_equal(const struct UnitSystem* a, const struct UnitSystem* b) {
int units_are_equal(const struct unit_system* a, const struct unit_system* b) {
if (a->UnitMass_in_cgs != b->UnitMass_in_cgs) return 0;
if (a->UnitLength_in_cgs != b->UnitLength_in_cgs) return 0;
......@@ -550,13 +551,13 @@ int units_are_equal(const struct UnitSystem* a, const struct UnitSystem* b) {
/**
* @brief Return the unit conversion factor between two systems
*
* @param from The #UnitSystem we are converting from
* @param to The #UnitSystem we are converting to
* @param from The #unit_system we are converting from
* @param to The #unit_system we are converting to
* @param baseUnitsExponants The exponent of each base units required to form
* the desired quantity. See conversionFactor() for a working example
*/
double units_general_conversion_factor(const struct UnitSystem* from,
const struct UnitSystem* to,
double units_general_conversion_factor(const struct unit_system* from,
const struct unit_system* to,
const float baseUnitsExponants[5]) {
const double from_cgs =
......@@ -570,15 +571,15 @@ double units_general_conversion_factor(const struct UnitSystem* from,
/**
* @brief Return the unit conversion factor between two systems
*
* @param from The #UnitSystem we are converting from
* @param to The #UnitSystem we are converting to
* @param from The #unit_system we are converting from
* @param to The #unit_system we are converting to
* @param unit The unit we are converting
*
* @return The conversion factor
*/
double units_conversion_factor(const struct UnitSystem* from,
const struct UnitSystem* to,
enum UnitConversionFactor unit) {
double units_conversion_factor(const struct unit_system* from,
const struct unit_system* to,
enum unit_conversion_factor unit) {
float baseUnitsExp[5] = {0.f};
......
......@@ -32,7 +32,7 @@
* internal units. It is used everytime a conversion is performed or an i/o
* function is called.
**/
struct UnitSystem {
struct unit_system {
/*! Conversion factor from grams to internal mass units */
double UnitMass_in_cgs;
......@@ -54,7 +54,7 @@ struct UnitSystem {
* @brief The base units used in the cgs (and internal) system. All units are
* derived from those.
*/
enum BaseUnits {
enum base_units {
UNIT_MASS = 0,
UNIT_LENGTH = 1,
UNIT_TIME = 2,
......@@ -65,7 +65,7 @@ enum BaseUnits {
/**
* @brief The different conversion factors supported by default
*/
enum UnitConversionFactor {
enum unit_conversion_factor {
UNIT_CONV_NO_UNITS,
UNIT_CONV_MASS,
UNIT_CONV_LENGTH,
......@@ -94,47 +94,47 @@ enum UnitConversionFactor {
UNIT_CONV_INV_VOLUME
};
void units_init_cgs(struct UnitSystem*);
void units_init(struct UnitSystem*, const struct swift_params*,
void units_init_cgs(struct unit_system*);
void units_init(struct unit_system*, const struct swift_params*,
const char* category);
void units_init_default(struct UnitSystem* us,
void units_init_default(struct unit_system* us,
const struct swift_params* params, const char* category,
const struct UnitSystem* def);
const struct unit_system* def);
int units_are_equal(const struct UnitSystem* a, const struct UnitSystem* b);
int units_are_equal(const struct unit_system* a, const struct unit_system* b);
/* Base units */
double units_get_base_unit(const struct UnitSystem*, enum BaseUnits);
const char* units_get_base_unit_internal_symbol(enum BaseUnits);