From daafcbef013eb6cd1ea015df76fd399012bb46f6 Mon Sep 17 00:00:00 2001 From: Oliver Hahn Date: Sun, 28 Nov 2021 13:20:04 +0100 Subject: [PATCH] added more doxygen documentation to infrastructure files --- src/cosmology_parameters.cc | 9 ++++++++- src/ic_generator.cc | 33 ++++++++++++++++++++++++++++++++- src/main.cc | 7 +++++++ src/output_plugin.cc | 19 ++++++++++++++++++- src/random_plugin.cc | 18 ++++++++++++++++++ src/transfer_function_plugin.cc | 18 ++++++++++++++++++ 6 files changed, 101 insertions(+), 3 deletions(-) diff --git a/src/cosmology_parameters.cc b/src/cosmology_parameters.cc index 088c967..a9b2b7d 100644 --- a/src/cosmology_parameters.cc +++ b/src/cosmology_parameters.cc @@ -17,6 +17,10 @@ #include +/** + * @brief namespace encapsulating all things cosmology + * + */ namespace cosmology{ //! we store here the preset cosmological paramters @@ -100,7 +104,10 @@ parameters::defaultmmap_t parameters::default_pmaps_ {"Tcmb", 2.7255}}} }; - +/** + * @brief Output all sets of cosmological parameters that we store internally + * + */ void print_ParameterSets( void ){ music::ilog << "Available cosmology parameter sets:" << std::endl; cosmology::parameters p; diff --git a/src/ic_generator.cc b/src/ic_generator.cc index f419f81..1561b1a 100644 --- a/src/ic_generator.cc +++ b/src/ic_generator.cc @@ -27,19 +27,39 @@ #include // for unlink + +/** + * @brief the possible species of fluids + * + */ std::map cosmo_species_name = { {cosmo_species::dm,"Dark matter"}, {cosmo_species::baryon,"Baryons"}, - {cosmo_species::neutrino,"Neutrinos"} + {cosmo_species::neutrino,"Neutrinos"} // not implemented yet }; +/** + * @brief the namespace encapsulating the main IC generation routines + * + */ namespace ic_generator{ +//! global RNG object std::unique_ptr the_random_number_generator; + +//! global output object std::unique_ptr the_output_plugin; + +//! global cosmology object (calculates all things cosmological) std::unique_ptr the_cosmo_calc; +/** + * @brief Initialises all global objects + * + * @param the_config reference to config_file object + * @return int 0 if successful + */ int initialise( config_file& the_config ) { the_random_number_generator = std::move(select_RNG_plugin(the_config)); @@ -49,12 +69,23 @@ int initialise( config_file& the_config ) return 0; } +/** + * @brief Reset all global objects + * + */ void reset () { the_random_number_generator.reset(); the_output_plugin.reset(); the_cosmo_calc.reset(); } + +/** + * @brief Main driver routine for IC generation, everything interesting happens here + * + * @param the_config reference to the config_file object + * @return int 0 if successful + */ int run( config_file& the_config ) { //-------------------------------------------------------------------------------------------------------- diff --git a/src/main.cc b/src/main.cc index ee070ed..eb38c10 100644 --- a/src/main.cc +++ b/src/main.cc @@ -60,6 +60,13 @@ void handle_eptr(std::exception_ptr eptr) // passing by value is ok } } +/** + * @brief the main routine of MUSIC2-monofonIC + * + * @param argc + * @param argv + * @return int + */ int main( int argc, char** argv ) { diff --git a/src/output_plugin.cc b/src/output_plugin.cc index 76dfbbe..cfad290 100644 --- a/src/output_plugin.cc +++ b/src/output_plugin.cc @@ -17,13 +17,21 @@ #include "output_plugin.hh" - +/** + * @brief Get the output plugin map object + * + * @return std::map< std::string, output_plugin_creator *>& + */ std::map< std::string, output_plugin_creator *>& get_output_plugin_map() { static std::map< std::string, output_plugin_creator* > output_plugin_map; return output_plugin_map; } +/** + * @brief Print out the names of all output plugins compiled in + * + */ void print_output_plugins() { std::map< std::string, output_plugin_creator *>& m = get_output_plugin_map(); @@ -40,6 +48,15 @@ void print_output_plugins() music::ilog << std::endl; } +/** + * @brief Return a pointer to the desired output plugin as given in the config file + * + * Implements the abstract factory pattern (https://en.wikipedia.org/wiki/Abstract_factory_pattern) + * + * @param cf reference to config_file object + * @param pcc reference to cosmology::calculator object + * @return std::unique_ptr + */ std::unique_ptr select_output_plugin( config_file& cf, std::unique_ptr& pcc ) { std::string formatname = cf.get_value( "output", "format" ); diff --git a/src/random_plugin.cc b/src/random_plugin.cc index 915c939..958b08b 100644 --- a/src/random_plugin.cc +++ b/src/random_plugin.cc @@ -18,6 +18,11 @@ #include #include +/** + * @brief Get the RNG plugin map object + * + * @return std::map& + */ std::map & get_RNG_plugin_map() { @@ -25,6 +30,10 @@ get_RNG_plugin_map() return RNG_plugin_map; } +/** + * @brief Print out the names of all RNG plugins compiled in + * + */ void print_RNG_plugins() { std::map &m = get_RNG_plugin_map(); @@ -41,6 +50,15 @@ void print_RNG_plugins() music::ilog << std::endl; } + +/** + * @brief Return a pointer to the desired random number generator plugin as given in the config file + * + * Implements the abstract factory pattern (https://en.wikipedia.org/wiki/Abstract_factory_pattern) + * + * @param cf reference to config_file object + * @return std::unique_ptr unique pointer to plugin + */ std::unique_ptr select_RNG_plugin(config_file &cf) { std::string rngname = cf.get_value("random", "generator"); diff --git a/src/transfer_function_plugin.cc b/src/transfer_function_plugin.cc index c93c3ee..2dd4cef 100644 --- a/src/transfer_function_plugin.cc +++ b/src/transfer_function_plugin.cc @@ -17,6 +17,11 @@ #include +/** + * @brief Get the TransferFunction plugin map object + * + * @return std::map& + */ std::map & get_TransferFunction_plugin_map() { @@ -24,6 +29,10 @@ get_TransferFunction_plugin_map() return TransferFunction_plugin_map; } +/** + * @brief Print out the names of all transfer function plugins compiled in + * + */ void print_TransferFunction_plugins() { std::map &m = get_TransferFunction_plugin_map(); @@ -39,6 +48,15 @@ void print_TransferFunction_plugins() music::ilog << std::endl; } +/** + * @brief Return a pointer to the desired transfer function plugin as given in the config file + * + * Implements the abstract factory pattern (https://en.wikipedia.org/wiki/Abstract_factory_pattern) + * + * @param cf reference to config_file object + * @param cosmo_param reference to cosmology::parameters object holding cosmological parameter values + * @return std::unique_ptr + */ std::unique_ptr select_TransferFunction_plugin(config_file &cf, const cosmology::parameters& cosmo_param) { std::string tfname = cf.get_value("cosmology", "transfer");