diff --git a/src/parser.c b/src/parser.c index 6988a82217c03f3da6730fc1ff59e295ca30f9a5..4b78270ebebd121377bd2d63aecbd99b1d0b1140 100644 --- a/src/parser.c +++ b/src/parser.c @@ -145,11 +145,9 @@ static int is_empty(const char *str) { /** * @brief Parses a line from a file and stores any parameters in a structure. * - * @param fp File pointer to file to be read - * @param params Structure to be populated from file - * + * @param line Line to be parsed. + * @param params Structure to be populated from file. */ - static void parse_line(char *line, struct swift_params *params) { /* Parse line if it doesn't begin with a comment. */ if (*line != PARSER_COMMENT_CHAR) { @@ -383,7 +381,7 @@ double parser_get_param_double(const struct swift_params *params, * * @param params Structure that holds the parameters * @param name Name of the parameter to be found - * @param retParam of the parameter found + * @param retParam (return) Value of the parameter found */ void parser_get_param_string(const struct swift_params *params, const char *name, char *retParam) { @@ -402,7 +400,6 @@ void parser_get_param_string(const struct swift_params *params, * @brief Prints the contents of the parameter structure. * * @param params Structure that holds the parameters - * */ void parser_print_params(const struct swift_params *params) { printf("\n--------------------------\n"); @@ -421,9 +418,7 @@ void parser_print_params(const struct swift_params *params) { * * @param params Structure that holds the parameters * @param file_name Name of file to be written - * */ - void parser_write_params_to_file(const struct swift_params *params, const char *file_name) { FILE *file = fopen(file_name, "w"); diff --git a/src/units.c b/src/units.c index a637d3c8b2e194a7f8ef1e2e2e54461f02033e4c..46710b9d131b880057d13c31d42c4e0aaf3ec352 100644 --- a/src/units.c +++ b/src/units.c @@ -43,10 +43,11 @@ /** * @brief Initialises the UnitSystem structure with the constants given in - * const.h - * @param us The UnitSystem to initialize + * rhe parameter file. + * + * @param us The UnitSystem to initialize. + * @param params The parsed parameter file. */ - void initUnitSystem(struct UnitSystem* us, const struct swift_params* params) { us->UnitMass_in_cgs = @@ -67,7 +68,7 @@ void initUnitSystem(struct UnitSystem* us, const struct swift_params* params) { * @param us The UnitSystem used * @param baseUnit The base unit */ -double getBaseUnit(struct UnitSystem* us, enum BaseUnits baseUnit) { +double getBaseUnit(const struct UnitSystem* us, enum BaseUnits baseUnit) { switch (baseUnit) { case UNIT_MASS: return us->UnitMass_in_cgs; @@ -271,7 +272,8 @@ void getBaseUnitExponantsArray(float baseUnitsExp[5], * @param us The system of units in use * @param unit The unit to convert */ -double conversionFactor(struct UnitSystem* us, enum UnitConversionFactor unit) { +double conversionFactor(const struct UnitSystem* us, + enum UnitConversionFactor unit) { float baseUnitsExp[5] = {0.f}; getBaseUnitExponantsArray(baseUnitsExp, unit); @@ -284,7 +286,7 @@ double conversionFactor(struct UnitSystem* us, enum UnitConversionFactor unit) { * @param us The system of units in use * @param unit The unit to convert */ -float hFactor(struct UnitSystem* us, enum UnitConversionFactor unit) { +float hFactor(const struct UnitSystem* us, enum UnitConversionFactor unit) { float baseUnitsExp[5] = {0.f}; getBaseUnitExponantsArray(baseUnitsExp, unit); @@ -297,7 +299,7 @@ float hFactor(struct UnitSystem* us, enum UnitConversionFactor unit) { * @param us The system of units in use * @param unit The unit to convert */ -float aFactor(struct UnitSystem* us, enum UnitConversionFactor unit) { +float aFactor(const struct UnitSystem* us, enum UnitConversionFactor unit) { float baseUnitsExp[5] = {0.f}; getBaseUnitExponantsArray(baseUnitsExp, unit); @@ -309,7 +311,7 @@ float aFactor(struct UnitSystem* us, enum UnitConversionFactor unit) { * @brief Returns a string containing the exponents of the base units making up * the conversion factors */ -void conversionString(char* buffer, struct UnitSystem* us, +void conversionString(char* buffer, const struct UnitSystem* us, enum UnitConversionFactor unit) { float baseUnitsExp[5] = {0.f}; @@ -325,7 +327,7 @@ void conversionString(char* buffer, struct UnitSystem* us, * @param baseUnitsExponants The exponent of each base units required to form * the desired quantity. See conversionFactor() for a working example */ -double generalConversionFactor(struct UnitSystem* us, +double generalConversionFactor(const struct UnitSystem* us, float baseUnitsExponants[5]) { double factor = 1.; int i; @@ -343,7 +345,7 @@ double generalConversionFactor(struct UnitSystem* us, * @param baseUnitsExponants The exponent of each base units required to form * the desired quantity. See conversionFactor() for a working example */ -float generalhFactor(struct UnitSystem* us, float baseUnitsExponants[5]) { +float generalhFactor(const struct UnitSystem* us, float baseUnitsExponants[5]) { float factor_exp = 0.f; factor_exp += -baseUnitsExponants[UNIT_MASS]; @@ -360,7 +362,7 @@ float generalhFactor(struct UnitSystem* us, float baseUnitsExponants[5]) { * @param baseUnitsExponants The exponent of each base units required to form * the desired quantity. See conversionFactor() for a working example */ -float generalaFactor(struct UnitSystem* us, float baseUnitsExponants[5]) { +float generalaFactor(const struct UnitSystem* us, float baseUnitsExponants[5]) { float factor_exp = 0.f; factor_exp += baseUnitsExponants[UNIT_LENGTH]; @@ -377,7 +379,7 @@ float generalaFactor(struct UnitSystem* us, float baseUnitsExponants[5]) { * @param baseUnitsExponants The exponent of each base units required to form * the desired quantity. See conversionFactor() for a working example */ -void generalConversionString(char* buffer, struct UnitSystem* us, +void generalConversionString(char* buffer, const struct UnitSystem* us, float baseUnitsExponants[5]) { char temp[14]; double a_exp = generalaFactor(us, baseUnitsExponants); diff --git a/src/units.h b/src/units.h index ddd46af2a2d5e209635e093fb18ae41cba38ce5b..f96824190ace6c50cbbe218e658d9b740ae3bb32 100644 --- a/src/units.h +++ b/src/units.h @@ -92,74 +92,21 @@ enum UnitConversionFactor { UNIT_CONV_TEMPERATURE }; -/** - * @brief Initialises the UnitSystem structure with the constants given in - * const.h - */ void initUnitSystem(struct UnitSystem*, const struct swift_params*); - -/** - * @brief Returns the base unit conversion factor for a given unit system - */ -double getBaseUnit(struct UnitSystem*, enum BaseUnits); - -/** - * @brief Returns the base unit symbol in the cgs system - */ +double getBaseUnit(const struct UnitSystem*, enum BaseUnits); const char* getBaseUnitSymbol(enum BaseUnits); - -/** - * @brief Returns the base unit symbol in the cgs system - */ const char* getBaseUnitCGSSymbol(enum BaseUnits); - -/** - * @brief Returns the conversion factor for a given unit (expressed in terms of - * the 5 fundamental units) in the chosen unit system - */ -double generalConversionFactor(struct UnitSystem* us, +double generalConversionFactor(const struct UnitSystem* us, float baseUnitsExponants[5]); - -/** - * @brief Returns the conversion factor for a given unit in the chosen unit - * system - */ -double conversionFactor(struct UnitSystem* us, enum UnitConversionFactor unit); - -/** - * @brief Returns the h factor for a given unit (expressed in terms of the 5 - * fundamental units) in the chosen unit system - */ -float generalhFactor(struct UnitSystem* us, float baseUnitsExponants[5]); - -/** - * @brief Returns the h factor for a given unit in the chosen unit system - */ -float hFactor(struct UnitSystem* us, enum UnitConversionFactor unit); - -/** - * @brief Returns the scaling factor for a given unit (expressed in terms of the - * 5 fundamental units) in the chosen unit system - */ -float generalaFactor(struct UnitSystem* us, float baseUnitsExponants[5]); - -/** - * @brief Returns the scaling factor for a given unit in the chosen unit system - */ -float aFactor(struct UnitSystem* us, enum UnitConversionFactor unit); - -/** - * @brief Returns a string containing the exponents of the base units making up - * the conversion factors (expressed in terms of the 5 fundamental units) - */ -void generalConversionString(char* buffer, struct UnitSystem* us, +double conversionFactor(const struct UnitSystem* us, + enum UnitConversionFactor unit); +float generalhFactor(const struct UnitSystem* us, float baseUnitsExponants[5]); +float hFactor(const struct UnitSystem* us, enum UnitConversionFactor unit); +float generalaFactor(const struct UnitSystem* us, float baseUnitsExponants[5]); +float aFactor(const struct UnitSystem* us, enum UnitConversionFactor unit); +void generalConversionString(char* buffer, const struct UnitSystem* us, float baseUnitsExponants[5]); - -/** - * @brief Returns a string containing the exponents of the base units making up - * the conversion factors - */ -void conversionString(char* buffer, struct UnitSystem* us, +void conversionString(char* buffer, const struct UnitSystem* us, enum UnitConversionFactor unit); #endif /* SWIFT_UNITS_H */