1
0
Fork 0
mirror of https://github.com/cosmo-sims/monofonIC.git synced 2024-09-19 17:03:45 +02:00

more naming convention homogenisation

This commit is contained in:
Oliver Hahn 2020-04-04 20:55:24 +02:00
parent 06b3a84bd3
commit 3f17e5a796
27 changed files with 310 additions and 305 deletions

View file

@ -12,20 +12,20 @@
#include <logger.hh>
/*!
* @class ConfigFile
* @class config_file
* @brief provides read/write access to configuration options
*
* This class provides access to the configuration file. The
* configuration is stored in hash-pairs and can be queried and
* validated by the responsible class/routine
*/
class ConfigFile {
class config_file {
//! current line number
unsigned m_iLine;
unsigned iline_;
//! hash table for key/value pairs, stored as strings
std::map<std::string, std::string> m_Items;
std::map<std::string, std::string> items_;
public:
//! removes all white space from string source
@ -59,7 +59,7 @@ public:
* @param oval the interpreted/converted value
*/
template <class in_value, class out_value>
void Convert(const in_value &ival, out_value &oval) const {
void convert(const in_value &ival, out_value &oval) const {
std::stringstream ss;
ss << ival; //.. insert value into stream
ss >> oval; //.. retrieve value from stream
@ -68,33 +68,33 @@ public:
//.. conversion error
music::elog << "Error: conversion of \'" << ival << "\' failed."
<< std::endl;
throw ErrInvalidConversion(std::string("invalid conversion to ") +
throw except_invalid_conversion(std::string("invalid conversion to ") +
typeid(out_value).name() + '.');
}
}
//! constructor of class config_file
/*! @param FileName the path/name of the configuration file to be parsed
/*! @param filename the path/name of the configuration file to be parsed
*/
explicit ConfigFile(std::string const &FileName) : m_iLine(0), m_Items() {
std::ifstream file(FileName.c_str());
explicit config_file(std::string const &filename) : iline_(0), items_() {
std::ifstream file(filename.c_str());
if (!file.is_open()){
music::elog << "Could not open config file \'" << FileName << "\'." << std::endl;
music::elog << "Could not open config file \'" << filename << "\'." << std::endl;
throw std::runtime_error(
std::string("Error: Could not open config file \'") + FileName +
std::string("Error: Could not open config file \'") + filename +
std::string("\'"));
}
std::string line;
std::string name;
std::string value;
std::string inSection;
int posEqual;
m_iLine = 0;
std::string in_section;
int pos_equal;
iline_ = 0;
//.. walk through all lines ..
while (std::getline(file, line)) {
++m_iLine;
++iline_;
//.. encounterd EOL ?
if (!line.length())
continue;
@ -106,31 +106,31 @@ public:
//.. encountered section tag ?
if (line[0] == '[') {
inSection = trim(line.substr(1, line.find(']') - 1));
in_section = trim(line.substr(1, line.find(']') - 1));
continue;
}
//.. seek end of entry name ..
posEqual = line.find('=');
name = trim(line.substr(0, posEqual));
value = trim(line.substr(posEqual + 1));
pos_equal = line.find('=');
name = trim(line.substr(0, pos_equal));
value = trim(line.substr(pos_equal + 1));
if ((size_t)posEqual == std::string::npos &&
if ((size_t)pos_equal == std::string::npos &&
(name.size() != 0 || value.size() != 0)) {
music::wlog << "Ignoring non-assignment in " << FileName << ":"
<< m_iLine << std::endl;
music::wlog << "Ignoring non-assignment in " << filename << ":"
<< iline_ << std::endl;
continue;
}
if (name.length() == 0 && value.size() != 0) {
music::wlog << "Ignoring assignment missing entry name in "
<< FileName << ":" << m_iLine << std::endl;
<< filename << ":" << iline_ << std::endl;
continue;
}
if (value.length() == 0 && name.size() != 0) {
music::wlog << "Empty entry will be ignored in " << FileName << ":"
<< m_iLine << std::endl;
music::wlog << "Empty entry will be ignored in " << filename << ":"
<< iline_ << std::endl;
continue;
}
@ -138,12 +138,12 @@ public:
continue;
//.. add key/value pair to hash table ..
if (m_Items.find(inSection + '/' + name) != m_Items.end()) {
if (items_.find(in_section + '/' + name) != items_.end()) {
music::wlog << "Redeclaration overwrites previous value in "
<< FileName << ":" << m_iLine << std::endl;
<< filename << ":" << iline_ << std::endl;
}
m_Items[inSection + '/' + name] = value;
items_[in_section + '/' + name] = value;
}
}
@ -151,8 +151,8 @@ public:
/*! @param key the key value, usually "section/key"
* @param value the value of the key, also a string
*/
void InsertValue(std::string const &key, std::string const &value) {
m_Items[key] = value;
void insert_value(std::string const &key, std::string const &value) {
items_[key] = value;
}
//! inserts a key/value pair in the hash map
@ -160,9 +160,9 @@ public:
* @param key the key value usually "section/key"
* @param value the value of the key, also a string
*/
void InsertValue(std::string const &section, std::string const &key,
void insert_value(std::string const &section, std::string const &key,
std::string const &value) {
m_Items[section + '/' + key] = value;
items_[section + '/' + key] = value;
}
//! checks if a key is part of the hash map
@ -170,10 +170,10 @@ public:
* @param key the key name to be checked
* @return true if the key is present, false otherwise
*/
bool ContainsKey(std::string const &section, std::string const &key) {
bool contains_key(std::string const &section, std::string const &key) {
std::map<std::string, std::string>::const_iterator i =
m_Items.find(section + '/' + key);
if (i == m_Items.end())
items_.find(section + '/' + key);
if (i == items_.end())
return false;
return true;
}
@ -182,55 +182,55 @@ public:
/*! @param key the key name to be checked
* @return true if the key is present, false otherwise
*/
bool ContainsKey(std::string const &key) {
std::map<std::string, std::string>::const_iterator i = m_Items.find(key);
if (i == m_Items.end())
bool contains_key(std::string const &key) {
std::map<std::string, std::string>::const_iterator i = items_.find(key);
if (i == items_.end())
return false;
return true;
}
//! return value of a key
/*! returns the value of a given key, throws a ErrItemNotFound
/*! returns the value of a given key, throws a except_item_not_found
* exception if the key is not available in the hash map.
* @param key the key name
* @return the value of the key
* @sa ErrItemNotFound
* @sa except_item_not_found
*/
template <class T> T GetValue(std::string const &key) const {
return GetValue<T>("", key);
template <class T> T get_value(std::string const &key) const {
return get_value<T>("", key);
}
//! return value of a key
/*! returns the value of a given key, throws a ErrItemNotFound
/*! returns the value of a given key, throws a except_item_not_found
* exception if the key is not available in the hash map.
* @param section the section name for the key
* @param key the key name
* @return the value of the key
* @sa ErrItemNotFound
* @sa except_item_not_found
*/
template <class T>
T GetValueBasic(std::string const &section, std::string const &key) const {
T get_value_basic(std::string const &section, std::string const &key) const {
T r;
std::map<std::string, std::string>::const_iterator i =
m_Items.find(section + '/' + key);
if (i == m_Items.end()){
throw ErrItemNotFound('\'' + section + '/' + key +
items_.find(section + '/' + key);
if (i == items_.end()){
throw except_item_not_found('\'' + section + '/' + key +
std::string("\' not found."));
}
Convert(i->second, r);
convert(i->second, r);
return r;
}
template <class T>
T GetValue(std::string const &section, std::string const &key) const
T get_value(std::string const &section, std::string const &key) const
{
T r;
try
{
r = GetValueBasic<T>(section, key);
r = get_value_basic<T>(section, key);
}
catch (ErrItemNotFound& e)
catch (except_item_not_found& e)
{
music::elog << e.what() << std::endl;
throw;
@ -240,40 +240,41 @@ public:
//! exception safe version of getValue
/*! returns the value of a given key, returns a default value rather
* than a ErrItemNotFound exception if the key is not found.
* than a except_item_not_found exception if the key is not found.
* @param section the section name for the key
* @param key the key name
* @param default_value the value that is returned if the key is not found
* @return the key value (if key found) otherwise default_value
*/
template <class T>
T GetValueSafe(std::string const &section, std::string const &key,
T get_value_safe(std::string const &section, std::string const &key,
T default_value) const {
T r;
try {
r = GetValueBasic<T>(section, key);
} catch (ErrItemNotFound&) {
r = get_value_basic<T>(section, key);
} catch (except_item_not_found&) {
r = default_value;
music::dlog << "Item \'" << section << "/" << key << " not found in config. Default = \'" << default_value << "\'" << std::endl;
}
return r;
}
//! exception safe version of getValue
/*! returns the value of a given key, returns a default value rather
* than a ErrItemNotFound exception if the key is not found.
* than a except_item_not_found exception if the key is not found.
* @param key the key name
* @param default_value the value that is returned if the key is not found
* @return the key value (if key found) otherwise default_value
*/
template <class T>
T GetValueSafe(std::string const &key, T default_value) const {
return GetValueSafe("", key, default_value);
T get_value_safe(std::string const &key, T default_value) const {
return get_value_safe("", key, default_value);
}
//! dumps all key-value pairs to a std::ostream
void Dump(std::ostream &out) {
std::map<std::string, std::string>::const_iterator i = m_Items.begin();
while (i != m_Items.end()) {
void dump(std::ostream &out) {
std::map<std::string, std::string>::const_iterator i = items_.begin();
while (i != items_.end()) {
if (i->second.length() > 0)
out << std::setw(24) << std::left << i->first << " = " << i->second
<< std::endl;
@ -281,10 +282,10 @@ public:
}
}
void LogDump(void) {
void dump_to_log(void) {
music::ilog << "List of all configuration options:" << std::endl;
std::map<std::string, std::string>::const_iterator i = m_Items.begin();
while (i != m_Items.end()) {
std::map<std::string, std::string>::const_iterator i = items_.begin();
while (i != items_.end()) {
if (i->second.length() > 0)
music::ilog << std::setw(28) << i->first << " = " << i->second
<< std::endl;
@ -295,16 +296,16 @@ public:
//--- EXCEPTIONS ---
//! runtime error that is thrown if key is not found in getValue
class ErrItemNotFound : public std::runtime_error {
class except_item_not_found : public std::runtime_error {
public:
ErrItemNotFound(std::string itemname)
except_item_not_found(std::string itemname)
: std::runtime_error(itemname.c_str()) {}
};
//! runtime error that is thrown if type conversion fails
class ErrInvalidConversion : public std::runtime_error {
class except_invalid_conversion : public std::runtime_error {
public:
ErrInvalidConversion(std::string errmsg) : std::runtime_error(errmsg) {}
except_invalid_conversion(std::string errmsg) : std::runtime_error(errmsg) {}
};
//! runtime error that is thrown if identifier is not found in keys
@ -323,9 +324,9 @@ public:
//... like "true" and "false" etc.
//... converts the string to type bool, returns type bool ...
template <>
inline bool ConfigFile::GetValue<bool>(std::string const &strSection,
inline bool config_file::get_value<bool>(std::string const &strSection,
std::string const &strEntry) const {
std::string r1 = GetValue<std::string>(strSection, strEntry);
std::string r1 = get_value<std::string>(strSection, strEntry);
if (r1 == "true" || r1 == "yes" || r1 == "on" || r1 == "1")
return true;
if (r1 == "false" || r1 == "no" || r1 == "off" || r1 == "0")
@ -338,17 +339,17 @@ inline bool ConfigFile::GetValue<bool>(std::string const &strSection,
}
template <>
inline bool ConfigFile::GetValueSafe<bool>(std::string const &strSection,
inline bool config_file::get_value_safe<bool>(std::string const &strSection,
std::string const &strEntry,
bool defaultValue) const {
std::string r1;
try {
r1 = GetValueBasic<std::string>(strSection, strEntry);
r1 = get_value_basic<std::string>(strSection, strEntry);
if (r1 == "true" || r1 == "yes" || r1 == "on" || r1 == "1")
return true;
if (r1 == "false" || r1 == "no" || r1 == "off" || r1 == "0")
return false;
} catch (ErrItemNotFound&) {
} catch (except_item_not_found&) {
return defaultValue;
}
return defaultValue;
@ -356,7 +357,7 @@ inline bool ConfigFile::GetValueSafe<bool>(std::string const &strSection,
template <>
inline void
ConfigFile::Convert<std::string, std::string>(const std::string &ival,
config_file::convert<std::string, std::string>(const std::string &ival,
std::string &oval) const {
oval = ival;
}

View file

@ -131,8 +131,8 @@ public:
* @param pTransferFunction pointer to an instance of a transfer function object
*/
explicit calculator(ConfigFile &cf)
: cosmo_param_(cf), astart_( 1.0/(1.0+cf.GetValue<double>("setup","zstart")) )
explicit calculator(config_file &cf)
: cosmo_param_(cf), astart_( 1.0/(1.0+cf.get_value<double>("setup","zstart")) )
{
// pre-compute growth factors and store for interpolation
std::vector<double> tab_a, tab_D, tab_f;
@ -161,7 +161,7 @@ public:
music::ilog << std::setw(32) << std::left << "TF maximum wave number"
<< " : " << transfer_function_->get_kmax() << " h/Mpc" << std::endl;
// music::ilog << "D+(MUSIC) = " << this->get_growth_factor( 1.0/(1.0+cf.GetValue<double>("setup","zstart")) ) << std::endl;
// music::ilog << "D+(MUSIC) = " << this->get_growth_factor( 1.0/(1.0+cf.get_value<double>("setup","zstart")) ) << std::endl;
// music::ilog << "pnrom = " << cosmo_param_.pnorm << std::endl;
}

View file

@ -42,35 +42,35 @@ struct parameters
parameters( const parameters& ) = default;
explicit parameters(ConfigFile cf)
explicit parameters(config_file cf)
{
H0 = cf.GetValue<double>("cosmology", "H0");
H0 = cf.get_value<double>("cosmology", "H0");
h = H0 / 100.0;
nspect = cf.GetValue<double>("cosmology", "nspec");
nspect = cf.get_value<double>("cosmology", "nspec");
Omega_b = cf.GetValue<double>("cosmology", "Omega_b");
Omega_b = cf.get_value<double>("cosmology", "Omega_b");
Omega_m = cf.GetValue<double>("cosmology", "Omega_m");
Omega_m = cf.get_value<double>("cosmology", "Omega_m");
Omega_DE = cf.GetValue<double>("cosmology", "Omega_L");
Omega_DE = cf.get_value<double>("cosmology", "Omega_L");
w_0 = cf.GetValueSafe<double>("cosmology", "w0", -1.0);
w_0 = cf.get_value_safe<double>("cosmology", "w0", -1.0);
w_a = cf.GetValueSafe<double>("cosmology", "wa", 0.0);
w_a = cf.get_value_safe<double>("cosmology", "wa", 0.0);
Tcmb = cf.GetValueSafe<double>("cosmology", "Tcmb", 2.7255);
Tcmb = cf.get_value_safe<double>("cosmology", "Tcmb", 2.7255);
Neff = cf.GetValueSafe<double>("cosmology", "Neff", 3.046);
Neff = cf.get_value_safe<double>("cosmology", "Neff", 3.046);
sigma8 = cf.GetValue<double>("cosmology", "sigma_8");
sigma8 = cf.get_value<double>("cosmology", "sigma_8");
// calculate energy density in ultrarelativistic species from Tcmb and Neff
double Omega_gamma = 4 * phys_const::sigma_SI / std::pow(phys_const::c_SI, 3) * std::pow(Tcmb, 4.0) / phys_const::rhocrit_h2_SI / (h * h);
double Omega_nu = Neff * Omega_gamma * 7. / 8. * std::pow(4. / 11., 4. / 3.);
Omega_r = Omega_gamma + Omega_nu;
if (cf.GetValueSafe<bool>("cosmology", "ZeroRadiation", false))
if (cf.get_value_safe<bool>("cosmology", "ZeroRadiation", false))
{
Omega_r = 0.0;
}
@ -91,7 +91,7 @@ struct parameters
music::ilog << "Cosmological parameters are: " << std::endl;
music::ilog << " H0 = " << std::setw(16) << H0 << "sigma_8 = " << std::setw(16) << sigma8 << std::endl;
music::ilog << " Omega_c = " << std::setw(16) << Omega_m-Omega_b << "Omega_b = " << std::setw(16) << Omega_b << std::endl;
if (!cf.GetValueSafe<bool>("cosmology", "ZeroRadiation", false)){
if (!cf.get_value_safe<bool>("cosmology", "ZeroRadiation", false)){
music::ilog << " Omega_g = " << std::setw(16) << Omega_gamma << "Omega_nu = " << std::setw(16) << Omega_nu << std::endl;
}else{
music::ilog << " Omega_r = " << std::setw(16) << Omega_r << std::endl;

View file

@ -9,9 +9,9 @@
namespace ic_generator{
int Run( ConfigFile& the_config );
int Run( config_file& the_config );
int Initialise( ConfigFile& the_config );
int Initialise( config_file& the_config );
extern std::unique_ptr<RNG_plugin> the_random_number_generator;
extern std::unique_ptr<output_plugin> the_output_plugin;

View file

@ -30,10 +30,10 @@ private:
real_t boxlen_, k0_;
size_t n_, nhalf_;
public:
explicit fourier_gradient( const ConfigFile& the_config )
: boxlen_( the_config.GetValue<double>("setup", "BoxLength") ),
explicit fourier_gradient( const config_file& the_config )
: boxlen_( the_config.get_value<double>("setup", "BoxLength") ),
k0_(2.0*M_PI/boxlen_),
n_( the_config.GetValue<size_t>("setup","GridRes") ),
n_( the_config.get_value<size_t>("setup","GridRes") ),
nhalf_( n_/2 )
{}

View file

@ -25,8 +25,8 @@ enum class output_type {particles,field_lagrangian,field_eulerian};
class output_plugin
{
protected:
//! reference to the ConfigFile object that holds all configuration options
ConfigFile &cf_;
//! reference to the config_file object that holds all configuration options
config_file &cf_;
//! output file or directory name
std::string fname_;
@ -35,10 +35,10 @@ protected:
std::string interface_name_;
public:
//! constructor
output_plugin(ConfigFile &cf, std::string interface_name )
output_plugin(config_file &cf, std::string interface_name )
: cf_(cf), interface_name_(interface_name)
{
fname_ = cf_.GetValue<std::string>("output", "filename");
fname_ = cf_.get_value<std::string>("output", "filename");
}
//! virtual destructor
@ -78,7 +78,7 @@ public:
struct output_plugin_creator
{
//! create an instance of a plug-in
virtual std::unique_ptr<output_plugin> create(ConfigFile &cf) const = 0;
virtual std::unique_ptr<output_plugin> create(config_file &cf) const = 0;
//! destroy an instance of a plug-in
virtual ~output_plugin_creator() {}
@ -103,12 +103,12 @@ struct output_plugin_creator_concrete : public output_plugin_creator
}
//! create an instance of the plug-in
std::unique_ptr<output_plugin> create(ConfigFile &cf) const
std::unique_ptr<output_plugin> create(config_file &cf) const
{
return std::make_unique<Derived>(cf); // Derived( cf );
}
};
//! failsafe version to select the output plug-in
std::unique_ptr<output_plugin> select_output_plugin(ConfigFile &cf);
std::unique_ptr<output_plugin> select_output_plugin(config_file &cf);

View file

@ -496,12 +496,12 @@ private:
public:
// real_t boxlen, size_t ngridother
explicit lattice_gradient( ConfigFile& the_config, size_t ngridself=64 )
: boxlen_( the_config.GetValue<double>("setup", "BoxLength") ),
aini_ ( 1.0/(1.0+the_config.GetValue<double>("setup", "zstart")) ),
ngmapto_( the_config.GetValue<size_t>("setup", "GridRes") ),
explicit lattice_gradient( config_file& the_config, size_t ngridself=64 )
: boxlen_( the_config.get_value<double>("setup", "BoxLength") ),
aini_ ( 1.0/(1.0+the_config.get_value<double>("setup", "zstart")) ),
ngmapto_( the_config.get_value<size_t>("setup", "GridRes") ),
ngrid_( ngridself ), ngrid32_( std::pow(ngrid_, 1.5) ), mapratio_(real_t(ngrid_)/real_t(ngmapto_)),
XmL_ ( the_config.GetValue<double>("cosmology", "Omega_L") / the_config.GetValue<double>("cosmology", "Omega_m") ),
XmL_ ( the_config.get_value<double>("cosmology", "Omega_L") / the_config.get_value<double>("cosmology", "Omega_m") ),
D_xx_({ngrid_, ngrid_, ngrid_}, {1.0,1.0,1.0}), D_xy_({ngrid_, ngrid_, ngrid_}, {1.0,1.0,1.0}),
D_xz_({ngrid_, ngrid_, ngrid_}, {1.0,1.0,1.0}), D_yy_({ngrid_, ngrid_, ngrid_}, {1.0,1.0,1.0}),
D_yz_({ngrid_, ngrid_, ngrid_}, {1.0,1.0,1.0}), D_zz_({ngrid_, ngrid_, ngrid_}, {1.0,1.0,1.0}),
@ -509,7 +509,7 @@ public:
grad_z_({ngrid_, ngrid_, ngrid_}, {1.0,1.0,1.0})
{
music::ilog << "-------------------------------------------------------------------------------" << std::endl;
std::string lattice_str = the_config.GetValueSafe<std::string>("setup","ParticleLoad","sc");
std::string lattice_str = the_config.get_value_safe<std::string>("setup","ParticleLoad","sc");
const lattice lattice_type =
((lattice_str=="bcc")? lattice_bcc
: ((lattice_str=="fcc")? lattice_fcc

View file

@ -10,9 +10,9 @@
class RNG_plugin
{
protected:
ConfigFile *pcf_; //!< pointer to config_file from which to read parameters
config_file *pcf_; //!< pointer to config_file from which to read parameters
public:
explicit RNG_plugin(ConfigFile &cf)
explicit RNG_plugin(config_file &cf)
: pcf_(&cf)
{
}
@ -24,7 +24,7 @@ class RNG_plugin
struct RNG_plugin_creator
{
virtual std::unique_ptr<RNG_plugin> Create(ConfigFile &cf) const = 0;
virtual std::unique_ptr<RNG_plugin> Create(config_file &cf) const = 0;
virtual ~RNG_plugin_creator() {}
};
@ -42,14 +42,14 @@ struct RNG_plugin_creator_concrete : public RNG_plugin_creator
}
//! create an instance of the plugin
std::unique_ptr<RNG_plugin> Create(ConfigFile &cf) const
std::unique_ptr<RNG_plugin> Create(config_file &cf) const
{
return std::make_unique<Derived>(cf);
}
};
typedef RNG_plugin RNG_instance;
std::unique_ptr<RNG_plugin> select_RNG_plugin( ConfigFile &cf);
std::unique_ptr<RNG_plugin> select_RNG_plugin( config_file &cf);
// /*!
// * @brief encapsulates all things for multi-scale white noise generation
@ -58,18 +58,18 @@ std::unique_ptr<RNG_plugin> select_RNG_plugin( ConfigFile &cf);
// class random_number_generator
// {
// protected:
// ConfigFile *pcf_;
// config_file *pcf_;
// //const refinement_hierarchy * prefh_;
// RNG_plugin *generator_;
// int levelmin_, levelmax_;
// public:
// //! constructor
// random_number_generator( ConfigFile &cf )
// random_number_generator( config_file &cf )
// : pcf_(&cf) //, prefh_( &refh )
// {
// levelmin_ = pcf_->GetValue<int>("setup", "levelmin");
// levelmax_ = pcf_->GetValue<int>("setup", "levelmax");
// levelmin_ = pcf_->get_value<int>("setup", "levelmin");
// levelmax_ = pcf_->get_value<int>("setup", "levelmax");
// generator_ = select_RNG_plugin(cf);
// }

View file

@ -15,7 +15,7 @@
namespace testing{
void output_potentials_and_densities(
ConfigFile& the_config,
config_file& the_config,
size_t ngrid, real_t boxlen,
Grid_FFT<real_t>& phi,
Grid_FFT<real_t>& phi2,
@ -24,7 +24,7 @@ namespace testing{
std::array< Grid_FFT<real_t>*,3 >& A3 );
void output_velocity_displacement_symmetries(
ConfigFile &the_config,
config_file &the_config,
size_t ngrid, real_t boxlen, real_t vfac, real_t dplus,
Grid_FFT<real_t> &phi,
Grid_FFT<real_t> &phi2,
@ -34,7 +34,7 @@ namespace testing{
bool bwrite_out_fields=false);
void output_convergence(
ConfigFile &the_config,
config_file &the_config,
cosmology::calculator* the_cosmo_calc,
std::size_t ngrid, real_t boxlen, real_t vfac, real_t dplus,
Grid_FFT<real_t> &phi,

View file

@ -25,7 +25,7 @@ class TransferFunction_plugin
{
public:
// Cosmology cosmo_; //!< cosmological parameter, read from config_file
ConfigFile *pcf_; //!< pointer to config_file from which to read parameters
config_file *pcf_; //!< pointer to config_file from which to read parameters
bool tf_distinct_; //!< bool if density transfer function is distinct for baryons and DM
bool tf_withvel_; //!< bool if also have velocity transfer functions
bool tf_withtotal0_; //!< have the z=0 spectrum for normalisation purposes
@ -34,7 +34,7 @@ class TransferFunction_plugin
public:
//! constructor
TransferFunction_plugin(ConfigFile &cf)
TransferFunction_plugin(config_file &cf)
: pcf_(&cf), tf_distinct_(false), tf_withvel_(false), tf_withtotal0_(false), tf_velunits_(false), tf_isnormalised_(false)
{ }
@ -82,7 +82,7 @@ class TransferFunction_plugin
struct TransferFunction_plugin_creator
{
//! create an instance of a transfer function plug-in
virtual std::unique_ptr<TransferFunction_plugin> create(ConfigFile &cf) const = 0;
virtual std::unique_ptr<TransferFunction_plugin> create(config_file &cf) const = 0;
//! destroy an instance of a plug-in
virtual ~TransferFunction_plugin_creator() {}
@ -103,7 +103,7 @@ struct TransferFunction_plugin_creator_concrete : public TransferFunction_plugin
}
//! create an instance of the plug-in
std::unique_ptr<TransferFunction_plugin> create(ConfigFile &cf) const
std::unique_ptr<TransferFunction_plugin> create(config_file &cf) const
{
return std::make_unique<Derived>(cf);
}
@ -111,4 +111,4 @@ struct TransferFunction_plugin_creator_concrete : public TransferFunction_plugin
// typedef TransferFunction_plugin TransferFunction;
std::unique_ptr<TransferFunction_plugin> select_TransferFunction_plugin(ConfigFile &cf);
std::unique_ptr<TransferFunction_plugin> select_TransferFunction_plugin(config_file &cf);

View file

@ -24,7 +24,7 @@ std::unique_ptr<RNG_plugin> the_random_number_generator;
std::unique_ptr<output_plugin> the_output_plugin;
std::unique_ptr<cosmology::calculator> the_cosmo_calc;
int Initialise( ConfigFile& the_config )
int Initialise( config_file& the_config )
{
the_random_number_generator = std::move(select_RNG_plugin(the_config));
the_output_plugin = std::move(select_output_plugin(the_config));
@ -33,7 +33,7 @@ int Initialise( ConfigFile& the_config )
return 0;
}
int Run( ConfigFile& the_config )
int Run( config_file& the_config )
{
//--------------------------------------------------------------------------------------------------------
// Read run parameters
@ -41,23 +41,23 @@ int Run( ConfigFile& the_config )
//--------------------------------------------------------------------------------------------------------
//! number of resolution elements per dimension
const size_t ngrid = the_config.GetValue<size_t>("setup", "GridRes");
const size_t ngrid = the_config.get_value<size_t>("setup", "GridRes");
//--------------------------------------------------------------------------------------------------------
//! box side length in h-1 Mpc
const real_t boxlen = the_config.GetValue<double>("setup", "BoxLength");
const real_t boxlen = the_config.get_value<double>("setup", "BoxLength");
//--------------------------------------------------------------------------------------------------------
//! starting redshift
const real_t zstart = the_config.GetValue<double>("setup", "zstart");
const real_t zstart = the_config.get_value<double>("setup", "zstart");
//--------------------------------------------------------------------------------------------------------
//! order of the LPT approximation
int LPTorder = the_config.GetValueSafe<double>("setup","LPTorder",100);
int LPTorder = the_config.get_value_safe<double>("setup","LPTorder",100);
//--------------------------------------------------------------------------------------------------------
//! initialice particles on a bcc or fcc lattice instead of a standard sc lattice (doubles and quadruples the number of particles)
std::string lattice_str = the_config.GetValueSafe<std::string>("setup","ParticleLoad","sc");
std::string lattice_str = the_config.get_value_safe<std::string>("setup","ParticleLoad","sc");
const particle::lattice lattice_type =
((lattice_str=="bcc")? particle::lattice_bcc
: ((lattice_str=="fcc")? particle::lattice_fcc
@ -66,45 +66,45 @@ int Run( ConfigFile& the_config )
//--------------------------------------------------------------------------------------------------------
//! apply fixing of the complex mode amplitude following Angulo & Pontzen (2016) [https://arxiv.org/abs/1603.05253]
const bool bDoFixing = the_config.GetValueSafe<bool>("setup", "DoFixing", false);
const bool bDoFixing = the_config.get_value_safe<bool>("setup", "DoFixing", false);
//--------------------------------------------------------------------------------------------------------
//! do baryon ICs?
const bool bDoBaryons = the_config.GetValueSafe<bool>("setup", "DoBaryons", false );
const bool bDoBaryons = the_config.get_value_safe<bool>("setup", "DoBaryons", false );
std::map< cosmo_species, double > Omega;
if( bDoBaryons ){
double Om = the_config.GetValue<double>("cosmology", "Omega_m");
double Ob = the_config.GetValue<double>("cosmology", "Omega_b");
double Om = the_config.get_value<double>("cosmology", "Omega_m");
double Ob = the_config.get_value<double>("cosmology", "Omega_b");
Omega[cosmo_species::dm] = Om-Ob;
Omega[cosmo_species::baryon] = Ob;
}else{
double Om = the_config.GetValue<double>("cosmology", "Omega_m");
double Om = the_config.get_value<double>("cosmology", "Omega_m");
Omega[cosmo_species::dm] = Om;
Omega[cosmo_species::baryon] = 0.0;
}
//--------------------------------------------------------------------------------------------------------
//! do constrained ICs?
const bool bAddConstrainedModes = the_config.ContainsKey("setup", "ConstraintFieldFile" );
const bool bAddConstrainedModes = the_config.contains_key("setup", "ConstraintFieldFile" );
//--------------------------------------------------------------------------------------------------------
//! add beyond box tidal field modes following Schmidt et al. (2018) [https://arxiv.org/abs/1803.03274]
bool bAddExternalTides = the_config.ContainsKey("cosmology", "LSS_aniso_lx")
& the_config.ContainsKey("cosmology", "LSS_aniso_ly")
& the_config.ContainsKey("cosmology", "LSS_aniso_lz");
bool bAddExternalTides = the_config.contains_key("cosmology", "LSS_aniso_lx")
& the_config.contains_key("cosmology", "LSS_aniso_ly")
& the_config.contains_key("cosmology", "LSS_aniso_lz");
if( bAddExternalTides && !( the_config.ContainsKey("cosmology", "LSS_aniso_lx")
| the_config.ContainsKey("cosmology", "LSS_aniso_ly")
| the_config.ContainsKey("cosmology", "LSS_aniso_lz") ))
if( bAddExternalTides && !( the_config.contains_key("cosmology", "LSS_aniso_lx")
| the_config.contains_key("cosmology", "LSS_aniso_ly")
| the_config.contains_key("cosmology", "LSS_aniso_lz") ))
{
music::elog << "Not all dimensions of LSS_aniso_l{x,y,z} specified! Will ignore external tidal field!" << std::endl;
bAddExternalTides = false;
}
// Anisotropy parameters for beyond box tidal field
std::array<real_t,3> lss_aniso_lambda = {
the_config.GetValueSafe<double>("cosmology", "LSS_aniso_lx", 0.0),
the_config.GetValueSafe<double>("cosmology", "LSS_aniso_ly", 0.0),
the_config.GetValueSafe<double>("cosmology", "LSS_aniso_lz", 0.0),
the_config.get_value_safe<double>("cosmology", "LSS_aniso_lx", 0.0),
the_config.get_value_safe<double>("cosmology", "LSS_aniso_ly", 0.0),
the_config.get_value_safe<double>("cosmology", "LSS_aniso_lz", 0.0),
};
if( std::abs(lss_aniso_lambda[0]+lss_aniso_lambda[1]+lss_aniso_lambda[2]) > 1e-10 ){
@ -192,8 +192,8 @@ int Run( ConfigFile& the_config )
//--------------------------------------------------------------------
if( bAddConstrainedModes ){
Grid_FFT<real_t,false> cwnoise({8,8,8}, {boxlen,boxlen,boxlen});
cwnoise.Read_from_HDF5( the_config.GetValue<std::string>("setup", "ConstraintFieldFile"),
the_config.GetValue<std::string>("setup", "ConstraintFieldName") );
cwnoise.Read_from_HDF5( the_config.get_value<std::string>("setup", "ConstraintFieldFile"),
the_config.get_value<std::string>("setup", "ConstraintFieldName") );
cwnoise.FourierTransformForward();
size_t ngrid_c = cwnoise.size(0), ngrid_c_2 = ngrid_c/2;
@ -422,7 +422,7 @@ int Run( ConfigFile& the_config )
//======================================================================
// Testing
const std::string testing = the_config.GetValueSafe<std::string>("testing", "test", "none");
const std::string testing = the_config.get_value_safe<std::string>("testing", "test", "none");
if (testing != "none")
{

View file

@ -44,8 +44,12 @@ void handle_eptr(std::exception_ptr eptr) // passing by value is ok
int main( int argc, char** argv )
{
#if defined(NDEBUG)
music::logger::set_level(music::log_level::info);
// music::logger::set_level(music::log_level::Debug);
#else
music::logger::set_level(music::log_level::debug);
#endif
//------------------------------------------------------------------------------
// initialise MPI
@ -104,7 +108,7 @@ int main( int argc, char** argv )
}
// open the configuration file
ConfigFile the_config(argv[1]);
config_file the_config(argv[1]);
//------------------------------------------------------------------------------
// Set up FFTW
@ -123,7 +127,7 @@ int main( int argc, char** argv )
FFTW_API(mpi_init)();
#endif
CONFIG::num_threads = the_config.GetValueSafe<unsigned>("execution", "NumThreads",std::thread::hardware_concurrency());
CONFIG::num_threads = the_config.get_value_safe<unsigned>("execution", "NumThreads",std::thread::hardware_concurrency());
#if defined(USE_FFTW_THREADS)
if (CONFIG::FFTW_threads_ok)

View file

@ -796,7 +796,7 @@ protected:
}
public:
gadget2_output_plugin(ConfigFile &cf)
gadget2_output_plugin(config_file &cf)
: output_plugin(cf)
{
@ -812,19 +812,19 @@ public:
units_vel_.insert(std::pair<std::string, double>("m/s", 1.0e-3)); // 1 m/s
units_vel_.insert(std::pair<std::string, double>("cm/s", 1.0e-5)); // 1 cm/s
block_buf_size_ = cf_.GetValueSafe<unsigned>("output", "gadget_blksize", 1048576);
block_buf_size_ = cf_.get_value_safe<unsigned>("output", "gadget_blksize", 1048576);
//... ensure that everyone knows we want to do SPH
cf.InsertValue("setup", "do_SPH", "yes");
cf.insert_value("setup", "do_SPH", "yes");
//bbndparticles_ = !cf_.GetValueSafe<bool>("output","gadget_nobndpart",false);
//bbndparticles_ = !cf_.get_value_safe<bool>("output","gadget_nobndpart",false);
npartmax_ = 1 << 30;
nfiles_ = cf.GetValueSafe<unsigned>("output", "gadget_num_files", 1);
nfiles_ = cf.get_value_safe<unsigned>("output", "gadget_num_files", 1);
blongids_ = cf.GetValueSafe<bool>("output", "gadget_longids", false);
blongids_ = cf.get_value_safe<bool>("output", "gadget_longids", false);
shift_halfcell_ = cf.GetValueSafe<bool>("output", "gadget_cell_centered", false);
shift_halfcell_ = cf.get_value_safe<bool>("output", "gadget_cell_centered", false);
//if( nfiles_ < (int)ceil((double)npart/(double)npartmax_) )
// music::wlog.Print("Should use more files.");
@ -879,16 +879,16 @@ public:
throw std::runtime_error("Internal error: gadget-2 output plug-in called for neither \'float\' nor \'double\'");
}
YHe_ = cf.GetValueSafe<double>("cosmology", "YHe", 0.248);
gamma_ = cf.GetValueSafe<double>("cosmology", "gamma", 5.0 / 3.0);
YHe_ = cf.get_value_safe<double>("cosmology", "YHe", 0.248);
gamma_ = cf.get_value_safe<double>("cosmology", "gamma", 5.0 / 3.0);
do_baryons_ = cf.GetValueSafe<bool>("setup", "baryons", false);
omegab_ = cf.GetValueSafe<double>("cosmology", "Omega_b", 0.045);
do_baryons_ = cf.get_value_safe<bool>("setup", "baryons", false);
omegab_ = cf.get_value_safe<double>("cosmology", "Omega_b", 0.045);
//... new way
std::string lunitstr = cf.GetValueSafe<std::string>("output", "gadget_lunit", "Mpc");
std::string munitstr = cf.GetValueSafe<std::string>("output", "gadget_munit", "1e10Msol");
std::string vunitstr = cf.GetValueSafe<std::string>("output", "gadget_vunit", "km/s");
std::string lunitstr = cf.get_value_safe<std::string>("output", "gadget_lunit", "Mpc");
std::string munitstr = cf.get_value_safe<std::string>("output", "gadget_munit", "1e10Msol");
std::string vunitstr = cf.get_value_safe<std::string>("output", "gadget_vunit", "km/s");
std::map<std::string, double>::iterator mapit;
@ -917,16 +917,16 @@ public:
}
//... maintain compatibility with old way of setting units
if (cf.ContainsKey("output", "gadget_usekpc"))
if (cf.contains_key("output", "gadget_usekpc"))
{
kpcunits_ = cf.GetValueSafe<bool>("output", "gadget_usekpc", false);
kpcunits_ = cf.get_value_safe<bool>("output", "gadget_usekpc", false);
if (kpcunits_)
unit_length_chosen_ = 1e-3;
music::wlog.Print("Deprecated option \'gadget_usekpc\' may override unit selection. Use \'gadget_lunit\' instead.");
}
if (cf.ContainsKey("output", "gadget_usemsol"))
if (cf.contains_key("output", "gadget_usemsol"))
{
msolunits_ = cf.GetValueSafe<bool>("output", "gadget_usemsol", false);
msolunits_ = cf.get_value_safe<bool>("output", "gadget_usemsol", false);
if (msolunits_)
unit_mass_chosen_ = 1e-10;
music::wlog.Print("Deprecated option \'gadget_usemsol\' may override unit selection. Use \'gadget_munit\' instead.");
@ -934,12 +934,12 @@ public:
//... coarse particle properties...
spread_coarse_acrosstypes_ = cf.GetValueSafe<bool>("output", "gadget_spreadcoarse", false);
spread_coarse_acrosstypes_ = cf.get_value_safe<bool>("output", "gadget_spreadcoarse", false);
bndparticletype_ = 5;
if (!spread_coarse_acrosstypes_)
{
bndparticletype_ = cf.GetValueSafe<unsigned>("output", "gadget_coarsetype", 5);
bndparticletype_ = cf.get_value_safe<unsigned>("output", "gadget_coarsetype", 5);
if (bndparticletype_ == 0 || //bndparticletype_ == 1 || bndparticletype_ == 4 ||
bndparticletype_ > 5)
@ -950,12 +950,12 @@ public:
}
else
{
if (cf.GetValueSafe<unsigned>("output", "gadget_coarsetype", 5) != 5)
if (cf.get_value_safe<unsigned>("output", "gadget_coarsetype", 5) != 5)
music::wlog.Print("Gadget: Option \'gadget_spreadcoarse\' forces \'gadget_coarsetype=5\'! Will override.");
}
//... set time ......................................................
header_.redshift = cf.GetValue<double>("setup", "zstart");
header_.redshift = cf.get_value<double>("setup", "zstart");
header_.time = 1.0 / (1.0 + header_.redshift);
//... SF flags
@ -965,10 +965,10 @@ public:
//...
header_.num_files = nfiles_; //1;
header_.BoxSize = cf.GetValue<double>("setup", "BoxLength");
header_.Omega0 = cf.GetValue<double>("cosmology", "Omega_m");
header_.OmegaLambda = cf.GetValue<double>("cosmology", "Omega_L");
header_.HubbleParam = cf.GetValue<double>("cosmology", "H0") / 100.0;
header_.BoxSize = cf.get_value<double>("setup", "BoxLength");
header_.Omega0 = cf.get_value<double>("cosmology", "Omega_m");
header_.OmegaLambda = cf.get_value<double>("cosmology", "Omega_L");
header_.HubbleParam = cf.get_value<double>("cosmology", "H0") / 100.0;
header_.flag_stellarage = 0;
header_.flag_metals = 0;

View file

@ -33,9 +33,9 @@ void print_output_plugins()
music::ilog << std::endl;
}
std::unique_ptr<output_plugin> select_output_plugin( ConfigFile& cf )
std::unique_ptr<output_plugin> select_output_plugin( config_file& cf )
{
std::string formatname = cf.GetValue<std::string>( "output", "format" );
std::string formatname = cf.get_value<std::string>( "output", "format" );
output_plugin_creator *the_output_plugin_creator
= get_output_plugin_map()[ formatname ];

View file

@ -56,7 +56,7 @@ protected:
public:
//! constructor
explicit gadget_hdf5_output_plugin(ConfigFile &cf)
explicit gadget_hdf5_output_plugin(config_file &cf)
: output_plugin(cf, "GADGET-HDF5")
{
num_files_ = 1;
@ -64,11 +64,11 @@ public:
// use as many output files as we have MPI tasks
MPI_Comm_size(MPI_COMM_WORLD, &num_files_);
#endif
real_t astart = 1.0 / (1.0 + cf_.GetValue<double>("setup", "zstart"));
lunit_ = cf_.GetValue<double>("setup", "BoxLength");
real_t astart = 1.0 / (1.0 + cf_.get_value<double>("setup", "zstart"));
lunit_ = cf_.get_value<double>("setup", "BoxLength");
vunit_ = lunit_ / std::sqrt(astart);
blongids_ = cf_.GetValueSafe<bool>("output", "UseLongids", false);
num_simultaneous_writers_ = cf_.GetValueSafe<int>("output", "NumSimWriters", num_files_);
blongids_ = cf_.get_value_safe<bool>("output", "UseLongids", false);
num_simultaneous_writers_ = cf_.get_value_safe<int>("output", "NumSimWriters", num_files_);
for (int i = 0; i < 6; ++i)
{
@ -85,9 +85,9 @@ public:
header_.flag_cooling = 0;
header_.num_files = num_files_;
header_.BoxSize = lunit_;
header_.Omega0 = cf_.GetValue<double>("cosmology", "Omega_m");
header_.OmegaLambda = cf_.GetValue<double>("cosmology", "Omega_L");
header_.HubbleParam = cf_.GetValue<double>("cosmology", "H0") / 100.0;
header_.Omega0 = cf_.get_value<double>("cosmology", "Omega_m");
header_.OmegaLambda = cf_.get_value<double>("cosmology", "Omega_L");
header_.HubbleParam = cf_.get_value<double>("cosmology", "H0") / 100.0;
header_.flag_stellarage = 0;
header_.flag_metals = 0;
header_.flag_entropy_instead_u = 0;
@ -95,16 +95,16 @@ public:
// initial gas temperature
double Tcmb0 = 2.726;
double Omegab = cf_.GetValue<double>("cosmology", "Omega_b");
double h = cf_.GetValue<double>("cosmology", "H0") / 100.0, h2 = h*h;
double Omegab = cf_.get_value<double>("cosmology", "Omega_b");
double h = cf_.get_value<double>("cosmology", "H0") / 100.0, h2 = h*h;
double adec = 1.0 / (160.0 * pow(Omegab * h2 / 0.022, 2.0 / 5.0));
Tini_ = astart < adec ? Tcmb0 / astart : Tcmb0 / astart / astart * adec;
// suggested PM res
pmgrid_ = 2*cf_.GetValue<double>("setup", "GridRes");
pmgrid_ = 2*cf_.get_value<double>("setup", "GridRes");
gridboost_ = 1;
softening_ = cf_.GetValue<double>("setup", "BoxLength")/pmgrid_/20;
doBaryons_ = cf_.GetValue<bool>("setup", "DoBaryons");
softening_ = cf_.get_value<double>("setup", "BoxLength")/pmgrid_/20;
doBaryons_ = cf_.get_value<bool>("setup", "DoBaryons");
#if !defined(USE_SINGLEPRECISION)
doublePrec_ = 1;
#else

View file

@ -38,7 +38,7 @@ protected:
public:
//! constructor
explicit gadget2_output_plugin(ConfigFile &cf)
explicit gadget2_output_plugin(config_file &cf)
: output_plugin(cf, "GADGET-2")
{
num_files_ = 1;
@ -46,10 +46,10 @@ public:
// use as many output files as we have MPI tasks
MPI_Comm_size(MPI_COMM_WORLD, &num_files_);
#endif
real_t astart = 1.0 / (1.0 + cf_.GetValue<double>("setup", "zstart"));
lunit_ = cf_.GetValue<double>("setup", "BoxLength");
real_t astart = 1.0 / (1.0 + cf_.get_value<double>("setup", "zstart"));
lunit_ = cf_.get_value<double>("setup", "BoxLength");
vunit_ = lunit_ / std::sqrt(astart);
blongids_ = cf_.GetValueSafe<bool>("output", "UseLongids", false);
blongids_ = cf_.get_value_safe<bool>("output", "UseLongids", false);
}
output_type write_species_as(const cosmo_species &) const { return output_type::particles; }
@ -90,7 +90,7 @@ public:
/////
//... set time ......................................................
this_header_.redshift = cf_.GetValue<double>("setup", "zstart");
this_header_.redshift = cf_.get_value<double>("setup", "zstart");
this_header_.time = 1.0 / (1.0 + this_header_.redshift);
//... SF flags
@ -100,10 +100,10 @@ public:
//...
this_header_.num_files = num_files_; //1;
this_header_.BoxSize = cf_.GetValue<double>("setup", "BoxLength");
this_header_.Omega0 = cf_.GetValue<double>("cosmology", "Omega_m");
this_header_.OmegaLambda = cf_.GetValue<double>("cosmology", "Omega_L");
this_header_.HubbleParam = cf_.GetValue<double>("cosmology", "H0") / 100.0;
this_header_.BoxSize = cf_.get_value<double>("setup", "BoxLength");
this_header_.Omega0 = cf_.get_value<double>("cosmology", "Omega_m");
this_header_.OmegaLambda = cf_.get_value<double>("cosmology", "Omega_L");
this_header_.HubbleParam = cf_.get_value<double>("cosmology", "H0") / 100.0;
this_header_.flag_stellarage = 0;
this_header_.flag_metals = 0;

View file

@ -50,7 +50,7 @@ protected:
public:
//! constructor
explicit gadget_hdf5_output_plugin(ConfigFile &cf)
explicit gadget_hdf5_output_plugin(config_file &cf)
: output_plugin(cf, "GADGET-HDF5")
{
num_files_ = 1;
@ -58,11 +58,11 @@ public:
// use as many output files as we have MPI tasks
MPI_Comm_size(MPI_COMM_WORLD, &num_files_);
#endif
real_t astart = 1.0 / (1.0 + cf_.GetValue<double>("setup", "zstart"));
lunit_ = cf_.GetValue<double>("setup", "BoxLength");
real_t astart = 1.0 / (1.0 + cf_.get_value<double>("setup", "zstart"));
lunit_ = cf_.get_value<double>("setup", "BoxLength");
vunit_ = lunit_ / std::sqrt(astart);
blongids_ = cf_.GetValueSafe<bool>("output", "UseLongids", false);
num_simultaneous_writers_ = cf_.GetValueSafe<int>("output", "NumSimWriters", num_files_);
blongids_ = cf_.get_value_safe<bool>("output", "UseLongids", false);
num_simultaneous_writers_ = cf_.get_value_safe<int>("output", "NumSimWriters", num_files_);
for (int i = 0; i < 6; ++i)
{
@ -79,9 +79,9 @@ public:
header_.flag_cooling = 0;
header_.num_files = num_files_;
header_.BoxSize = lunit_;
header_.Omega0 = cf_.GetValue<double>("cosmology", "Omega_m");
header_.OmegaLambda = cf_.GetValue<double>("cosmology", "Omega_L");
header_.HubbleParam = cf_.GetValue<double>("cosmology", "H0") / 100.0;
header_.Omega0 = cf_.get_value<double>("cosmology", "Omega_m");
header_.OmegaLambda = cf_.get_value<double>("cosmology", "Omega_L");
header_.HubbleParam = cf_.get_value<double>("cosmology", "H0") / 100.0;
header_.flag_stellarage = 0;
header_.flag_metals = 0;
header_.flag_entropy_instead_u = 0;

View file

@ -21,13 +21,13 @@ protected:
bool out_eulerian_;
public:
//! constructor
explicit generic_output_plugin(ConfigFile &cf )
explicit generic_output_plugin(config_file &cf )
: output_plugin(cf, "Generic HDF5")
{
real_t astart = 1.0/(1.0+cf_.GetValue<double>("setup", "zstart"));
real_t boxsize = cf_.GetValue<double>("setup", "BoxLength");
real_t astart = 1.0/(1.0+cf_.get_value<double>("setup", "zstart"));
real_t boxsize = cf_.get_value<double>("setup", "BoxLength");
out_eulerian_ = cf_.GetValueSafe<bool>("output", "generic_out_eulerian",false);
out_eulerian_ = cf_.get_value_safe<bool>("output", "generic_out_eulerian",false);
if( CONFIG::MPI_task_rank == 0 )
{

View file

@ -40,22 +40,22 @@ protected:
public:
//! constructor
explicit grafic2_output_plugin(ConfigFile &cf)
explicit grafic2_output_plugin(config_file &cf)
: output_plugin(cf, "GRAFIC2/RAMSES")
{
lunit_ = 1.0;
vunit_ = 1.0;
double
boxlength = cf_.GetValue<double>("setup", "BoxLength"),
H0 = cf_.GetValue<double>("cosmology", "H0"),
zstart = cf_.GetValue<double>("setup", "zstart"),
boxlength = cf_.get_value<double>("setup", "BoxLength"),
H0 = cf_.get_value<double>("cosmology", "H0"),
zstart = cf_.get_value<double>("setup", "zstart"),
astart = 1.0 / (1.0 + zstart),
omegam = cf_.GetValue<double>("cosmology", "Omega_m"),
omegaL = cf_.GetValue<double>("cosmology", "Omega_L");
uint32_t ngrid = cf_.GetValue<int>("setup", "GridRes");
omegam = cf_.get_value<double>("cosmology", "Omega_m"),
omegaL = cf_.get_value<double>("cosmology", "Omega_L");
uint32_t ngrid = cf_.get_value<int>("setup", "GridRes");
bUseSPT_ = cf_.GetValueSafe<bool>("output", "grafic_use_SPT", false);
bUseSPT_ = cf_.get_value_safe<bool>("output", "grafic_use_SPT", false);
levelmin_ = uint32_t(std::log2(double(ngrid)) + 1e-6);
if (std::abs(std::pow(2.0, levelmin_) - double(ngrid)) > 1e-4)
@ -64,7 +64,7 @@ public:
abort();
}
bhavebaryons_ = cf_.GetValueSafe<bool>("setup", "baryons", false);
bhavebaryons_ = cf_.get_value_safe<bool>("setup", "baryons", false);
header_.n1 = ngrid;
header_.n2 = ngrid;
@ -89,7 +89,7 @@ public:
mkdir(dirname_.c_str(), 0777);
// write RAMSES namelist file? if so only with one task
if (cf_.GetValueSafe<bool>("output", "ramses_nml", true) && CONFIG::MPI_task_rank==0 )
if (cf_.get_value_safe<bool>("output", "ramses_nml", true) && CONFIG::MPI_task_rank==0 )
{
write_ramses_namelist();
}
@ -196,7 +196,7 @@ void grafic2_output_plugin::write_grid_data(const Grid_FFT<real_t> &g, const cos
}
// check field size against buffer size...
uint32_t ngrid = cf_.GetValue<int>("setup", "GridRes");
uint32_t ngrid = cf_.get_value<int>("setup", "GridRes");
assert( g.global_size(0) == ngrid && g.global_size(1) == ngrid && g.global_size(2) == ngrid);
assert( g.size(1) == ngrid && g.size(2) == ngrid);
// write actual field slice by slice

View file

@ -34,7 +34,7 @@ protected:
//void store_rnd(int ilevel, rng *prng);
public:
explicit RNG_music(ConfigFile &cf) : RNG_plugin(cf), initialized_(false) {}
explicit RNG_music(config_file &cf) : RNG_plugin(cf), initialized_(false) {}
~RNG_music() {}
@ -45,12 +45,12 @@ public:
void initialize_for_grid_structure()//const refinement_hierarchy &refh)
{
//prefh_ = &refh;
levelmin_ = pcf_->GetValue<unsigned>("setup", "levelmin");
levelmax_ = pcf_->GetValue<unsigned>("setup", "levelmax");
levelmin_ = pcf_->get_value<unsigned>("setup", "levelmin");
levelmax_ = pcf_->get_value<unsigned>("setup", "levelmax");
ran_cube_size_ = pcf_->GetValueSafe<unsigned>("random", "cubesize", DEF_RAN_CUBE_SIZE);
disk_cached_ = pcf_->GetValueSafe<bool>("random", "disk_cached", true);
restart_ = pcf_->GetValueSafe<bool>("random", "restart", false);
ran_cube_size_ = pcf_->get_value_safe<unsigned>("random", "cubesize", DEF_RAN_CUBE_SIZE);
disk_cached_ = pcf_->get_value_safe<bool>("random", "disk_cached", true);
restart_ = pcf_->get_value_safe<bool>("random", "restart", false);
mem_cache_.assign(levelmax_ - levelmin_ + 1, (std::vector<real_t> *)NULL);
@ -93,8 +93,8 @@ void RNG_music::parse_random_parameters(void)
std::string tempstr;
bool noseed = false;
sprintf(seedstr, "seed[%d]", i);
if (pcf_->ContainsKey("random", seedstr))
tempstr = pcf_->GetValue<std::string>("random", seedstr);
if (pcf_->contains_key("random", seedstr))
tempstr = pcf_->get_value<std::string>("random", seedstr);
else
{
// "-2" means that no seed entry was found for that level
@ -105,7 +105,7 @@ void RNG_music::parse_random_parameters(void)
if (is_number(tempstr))
{
long ltemp;
pcf_->Convert(tempstr, ltemp);
pcf_->convert(tempstr, ltemp);
rngfnames_.push_back("");
if (noseed) // ltemp < 0 )
//... generate some dummy seed which only depends on the level, negative so we know it's not
@ -141,7 +141,7 @@ void RNG_music::parse_random_parameters(void)
void RNG_music::compute_random_numbers(void)
{
bool rndsign = pcf_->GetValueSafe<bool>("random", "grafic_sign", false);
bool rndsign = pcf_->get_value_safe<bool>("random", "grafic_sign", false);
std::vector<rng *> randc(std::max(levelmax_, levelmin_seed_) + 1, (rng *)NULL);
@ -227,11 +227,11 @@ void RNG_music::compute_random_numbers(void)
// {
// int lx[3], x0[3];
// int shift[3], levelmin_poisson;
// shift[0] = pcf_->GetValue<int>("setup", "shift_x");
// shift[1] = pcf_->GetValue<int>("setup", "shift_y");
// shift[2] = pcf_->GetValue<int>("setup", "shift_z");
// shift[0] = pcf_->get_value<int>("setup", "shift_x");
// shift[1] = pcf_->get_value<int>("setup", "shift_y");
// shift[2] = pcf_->get_value<int>("setup", "shift_z");
// levelmin_poisson = pcf_->GetValue<unsigned>("setup", "levelmin");
// levelmin_poisson = pcf_->get_value<unsigned>("setup", "levelmin");
// int lfac = 1 << (ilevel - levelmin_poisson);

View file

@ -18,11 +18,11 @@ private:
std::vector<unsigned int> SeedTable_;
public:
explicit RNG_ngenic(ConfigFile &cf) : RNG_plugin(cf)
explicit RNG_ngenic(config_file &cf) : RNG_plugin(cf)
{
RandomSeed_ = cf.GetValue<long>("random", "seed");
nres_ = cf.GetValue<size_t>("setup", "GridRes");
RandomSeed_ = cf.get_value<long>("random", "seed");
nres_ = cf.get_value<size_t>("setup", "GridRes");
pRandomGenerator_ = gsl_rng_alloc(gsl_rng_ranlxd1);
gsl_rng_set(pRandomGenerator_, RandomSeed_);

View file

@ -169,13 +169,13 @@ private:
}
public:
transfer_CAMB_file_plugin(ConfigFile &cf)
transfer_CAMB_file_plugin(config_file &cf)
: TransferFunction_plugin(cf)
{
m_filename_Tk = pcf_->GetValue<std::string>("cosmology", "transfer_file");
m_Omega_m = cf.GetValue<double>("cosmology", "Omega_m"); //MvD
m_Omega_b = cf.GetValue<double>("cosmology", "Omega_b"); //MvD
m_zstart = cf.GetValue<double>("setup", "zstart"); //MvD
m_filename_Tk = pcf_->get_value<std::string>("cosmology", "transfer_file");
m_Omega_m = cf.get_value<double>("cosmology", "Omega_m"); //MvD
m_Omega_b = cf.get_value<double>("cosmology", "Omega_b"); //MvD
m_zstart = cf.get_value<double>("setup", "zstart"); //MvD
read_table();

View file

@ -170,25 +170,25 @@ private:
}
public:
explicit transfer_CLASS_plugin(ConfigFile &cf)
explicit transfer_CLASS_plugin(config_file &cf)
: TransferFunction_plugin(cf)
{
ofs_class_input_.open("input_class_parameters.ini", std::ios::trunc);
h_ = pcf_->GetValue<double>("cosmology", "H0") / 100.0;
Omega_m_ = pcf_->GetValue<double>("cosmology", "Omega_m");
Omega_b_ = pcf_->GetValue<double>("cosmology", "Omega_b");
N_ur_ = pcf_->GetValueSafe<double>("cosmology", "Neff", 3.046);
ztarget_ = pcf_->GetValueSafe<double>("cosmology", "ztarget", 0.0);
h_ = pcf_->get_value<double>("cosmology", "H0") / 100.0;
Omega_m_ = pcf_->get_value<double>("cosmology", "Omega_m");
Omega_b_ = pcf_->get_value<double>("cosmology", "Omega_b");
N_ur_ = pcf_->get_value_safe<double>("cosmology", "Neff", 3.046);
ztarget_ = pcf_->get_value_safe<double>("cosmology", "ztarget", 0.0);
atarget_ = 1.0 / (1.0 + ztarget_);
zstart_ = pcf_->GetValue<double>("setup", "zstart");
zstart_ = pcf_->get_value<double>("setup", "zstart");
astart_ = 1.0 / (1.0 + zstart_);
double lbox = pcf_->GetValue<double>("setup", "BoxLength");
int nres = pcf_->GetValue<double>("setup", "GridRes");
A_s_ = pcf_->GetValueSafe<double>("cosmology", "A_s", -1.0);
double k_p = pcf_->GetValueSafe<double>("cosmology", "k_p", 0.05);
n_s_ = pcf_->GetValue<double>("cosmology", "nspec");
Tcmb_ = cf.GetValueSafe<double>("cosmology", "Tcmb", 2.7255);
double lbox = pcf_->get_value<double>("setup", "BoxLength");
int nres = pcf_->get_value<double>("setup", "GridRes");
A_s_ = pcf_->get_value_safe<double>("cosmology", "A_s", -1.0);
double k_p = pcf_->get_value_safe<double>("cosmology", "k_p", 0.05);
n_s_ = pcf_->get_value<double>("cosmology", "nspec");
Tcmb_ = cf.get_value_safe<double>("cosmology", "Tcmb", 2.7255);
tnorm_ = 1.0;

View file

@ -207,13 +207,13 @@ public:
\param Tcmb mean temperature of the CMB fluctuations (defaults to
Tcmb = 2.726 if not specified)
*/
transfer_eisenstein_plugin(ConfigFile &cf)
transfer_eisenstein_plugin(config_file &cf)
: TransferFunction_plugin(cf)
{
double Tcmb = pcf_->GetValueSafe<double>("cosmology", "Tcmb", 2.726);
double H0 = pcf_->GetValue<double>("cosmology", "H0");
double Omega_m = pcf_->GetValue<double>("cosmology", "Omega_m");
double Omega_b = pcf_->GetValue<double>("cosmology", "Omega_b");
double Tcmb = pcf_->get_value_safe<double>("cosmology", "Tcmb", 2.726);
double H0 = pcf_->get_value<double>("cosmology", "H0");
double Omega_m = pcf_->get_value<double>("cosmology", "Omega_m");
double Omega_b = pcf_->get_value<double>("cosmology", "Omega_b");
etf_.set_parameters(H0, Omega_m, Omega_b, Tcmb);
@ -257,15 +257,15 @@ protected:
};
public:
transfer_eisenstein_wdm_plugin(ConfigFile &cf)
transfer_eisenstein_wdm_plugin(config_file &cf)
: TransferFunction_plugin(cf)
{
double Tcmb = pcf_->GetValueSafe("cosmology", "Tcmb", 2.726);
omegam_ = pcf_->GetValue<double>("cosmology", "Omega_m");
omegab_ = pcf_->GetValue<double>("cosmology", "Omega_b");
H0_ = pcf_->GetValue<double>("cosmology", "H0");
double Tcmb = pcf_->get_value_safe("cosmology", "Tcmb", 2.726);
omegam_ = pcf_->get_value<double>("cosmology", "Omega_m");
omegab_ = pcf_->get_value<double>("cosmology", "Omega_b");
H0_ = pcf_->get_value<double>("cosmology", "H0");
m_h0 = H0_ / 100.0;
wdmm_ = pcf_->GetValue<double>("cosmology", "WDMmass");
wdmm_ = pcf_->get_value<double>("cosmology", "WDMmass");
etf_.set_parameters(H0_, omegam_, omegab_, Tcmb);
@ -273,7 +273,7 @@ public:
typemap_.insert(std::pair<std::string, int>("VIEL", wdm_viel)); // add the other types
typemap_.insert(std::pair<std::string, int>("BODE_WRONG", wdm_bode_wrong)); // add the other types
type_ = pcf_->GetValueSafe<std::string>("cosmology", "WDMtftype", "BODE");
type_ = pcf_->get_value_safe<std::string>("cosmology", "WDMtftype", "BODE");
//type_ = std::string( toupper( type_.c_str() ) );
@ -286,29 +286,29 @@ public:
{
//... parameterisation from Bode et al. (2001), ApJ, 556, 93
case wdm_bode:
wdmnu_ = pcf_->GetValueSafe<double>("cosmology", "WDMnu", 1.0);
wdmgx_ = pcf_->GetValueSafe<double>("cosmology", "WDMg_x", 1.5);
wdmnu_ = pcf_->get_value_safe<double>("cosmology", "WDMnu", 1.0);
wdmgx_ = pcf_->get_value_safe<double>("cosmology", "WDMg_x", 1.5);
m_WDMalpha = 0.05 * pow(omegam_ / 0.4, 0.15) * pow(H0_ * 0.01 / 0.65, 1.3) * pow(wdmm_, -1.15) * pow(1.5 / wdmgx_, 0.29);
break;
//... parameterisation from Viel et al. (2005), Phys Rev D, 71
case wdm_viel:
wdmnu_ = pcf_->GetValueSafe<double>("cosmology", "WDMnu", 1.12);
wdmnu_ = pcf_->get_value_safe<double>("cosmology", "WDMnu", 1.12);
m_WDMalpha = 0.049 * pow(omegam_ / 0.25, 0.11) * pow(H0_ * 0.01 / 0.7, 1.22) * pow(wdmm_, -1.11);
break;
//.... below is for historical reasons due to the buggy parameterisation
//.... in early versions of MUSIC, but apart from H instead of h, Bode et al.
case wdm_bode_wrong:
wdmnu_ = pcf_->GetValueSafe<double>("cosmology", "WDMnu", 1.0);
wdmgx_ = pcf_->GetValueSafe<double>("cosmology", "WDMg_x", 1.5);
wdmnu_ = pcf_->get_value_safe<double>("cosmology", "WDMnu", 1.0);
wdmgx_ = pcf_->get_value_safe<double>("cosmology", "WDMg_x", 1.5);
m_WDMalpha = 0.05 * pow(omegam_ / 0.4, 0.15) * pow(H0_ / 0.65, 1.3) * pow(wdmm_, -1.15) * pow(1.5 / wdmgx_, 0.29);
break;
default:
wdmnu_ = pcf_->GetValueSafe<double>("cosmology", "WDMnu", 1.0);
wdmgx_ = pcf_->GetValueSafe<double>("cosmology", "WDMg_x", 1.5);
wdmnu_ = pcf_->get_value_safe<double>("cosmology", "WDMnu", 1.0);
wdmgx_ = pcf_->get_value_safe<double>("cosmology", "WDMg_x", 1.5);
m_WDMalpha = 0.05 * pow(omegam_ / 0.4, 0.15) * pow(H0_ * 0.01 / 0.65, 1.3) * pow(wdmm_, -1.15) * pow(1.5 / wdmgx_, 0.29);
break;
}
@ -340,20 +340,20 @@ protected:
eisenstein_transfer etf_;
public:
transfer_eisenstein_cdmbino_plugin(ConfigFile &cf)
transfer_eisenstein_cdmbino_plugin(config_file &cf)
: TransferFunction_plugin(cf)
{
double Tcmb = pcf_->GetValueSafe("cosmology", "Tcmb", 2.726);
double Tcmb = pcf_->get_value_safe("cosmology", "Tcmb", 2.726);
omegam_ = pcf_->GetValue<double>("cosmology", "Omega_m");
omegab_ = pcf_->GetValue<double>("cosmology", "Omega_b");
H0_ = pcf_->GetValue<double>("cosmology", "H0");
omegam_ = pcf_->get_value<double>("cosmology", "Omega_m");
omegab_ = pcf_->get_value<double>("cosmology", "Omega_b");
H0_ = pcf_->get_value<double>("cosmology", "H0");
m_h0 = H0_ / 100.0;
etf_.set_parameters(H0_, omegam_, omegab_, Tcmb);
mcdm_ = pcf_->GetValueSafe<double>("cosmology", "CDM_mass", 100.0); // bino particle mass in GeV
Tkd_ = pcf_->GetValueSafe<double>("cosmology", "CDM_Tkd", 33.0); // temperature at which CDM particle kinetically decouples (in MeV)
mcdm_ = pcf_->get_value_safe<double>("cosmology", "CDM_mass", 100.0); // bino particle mass in GeV
Tkd_ = pcf_->get_value_safe<double>("cosmology", "CDM_Tkd", 33.0); // temperature at which CDM particle kinetically decouples (in MeV)
kfs_ = 1.7e6 / m_h0 * sqrt(mcdm_ / 100. * Tkd_ / 30.) / (1.0 + log(Tkd_ / 30.) / 19.2);
kd_ = 3.8e7 / m_h0 * sqrt(mcdm_ / 100. * Tkd_ / 30.);
@ -395,19 +395,19 @@ protected:
eisenstein_transfer etf_;
public:
transfer_eisenstein_cutoff_plugin(ConfigFile &cf)
transfer_eisenstein_cutoff_plugin(config_file &cf)
: TransferFunction_plugin(cf)
{
double Tcmb = pcf_->GetValueSafe("cosmology", "Tcmb", 2.726);
double Tcmb = pcf_->get_value_safe("cosmology", "Tcmb", 2.726);
omegam_ = pcf_->GetValue<double>("cosmology", "Omega_m");
omegab_ = pcf_->GetValue<double>("cosmology", "Omega_b");
H0_ = pcf_->GetValue<double>("cosmology", "H0");
omegam_ = pcf_->get_value<double>("cosmology", "Omega_m");
omegab_ = pcf_->get_value<double>("cosmology", "Omega_b");
H0_ = pcf_->get_value<double>("cosmology", "H0");
m_h0 = H0_ / 100.0;
etf_.set_parameters(H0_, omegam_, omegab_, Tcmb);
Rcut_ = pcf_->GetValueSafe<double>("cosmology", "Rcut", 1.0);
Rcut_ = pcf_->get_value_safe<double>("cosmology", "Rcut", 1.0);
}
inline double compute(double k, tf_type type) const

View file

@ -24,9 +24,9 @@ void print_RNG_plugins()
music::ilog << std::endl;
}
std::unique_ptr<RNG_plugin> select_RNG_plugin(ConfigFile &cf)
std::unique_ptr<RNG_plugin> select_RNG_plugin(config_file &cf)
{
std::string rngname = cf.GetValueSafe<std::string>("random", "generator", "MUSIC");
std::string rngname = cf.get_value_safe<std::string>("random", "generator", "MUSIC");
RNG_plugin_creator *the_RNG_plugin_creator = get_RNG_plugin_map()[rngname];

View file

@ -9,7 +9,7 @@ namespace testing
{
void output_potentials_and_densities(
ConfigFile &the_config,
config_file &the_config,
size_t ngrid, real_t boxlen,
Grid_FFT<real_t> &phi,
Grid_FFT<real_t> &phi2,
@ -17,8 +17,8 @@ void output_potentials_and_densities(
Grid_FFT<real_t> &phi3b,
std::array<Grid_FFT<real_t> *, 3> &A3)
{
const std::string fname_hdf5 = the_config.GetValueSafe<std::string>("output", "fname_hdf5", "output.hdf5");
const std::string fname_analysis = the_config.GetValueSafe<std::string>("output", "fbase_analysis", "output");
const std::string fname_hdf5 = the_config.get_value_safe<std::string>("output", "fname_hdf5", "output.hdf5");
const std::string fname_analysis = the_config.get_value_safe<std::string>("output", "fbase_analysis", "output");
Grid_FFT<real_t> delta({ngrid, ngrid, ngrid}, {boxlen, boxlen, boxlen});
Grid_FFT<real_t> delta2({ngrid, ngrid, ngrid}, {boxlen, boxlen, boxlen});
@ -98,7 +98,7 @@ void output_potentials_and_densities(
}
void output_velocity_displacement_symmetries(
ConfigFile &the_config,
config_file &the_config,
size_t ngrid, real_t boxlen, real_t vfac, real_t dplus,
Grid_FFT<real_t> &phi,
Grid_FFT<real_t> &phi2,
@ -107,8 +107,8 @@ void output_velocity_displacement_symmetries(
std::array<Grid_FFT<real_t> *, 3> &A3,
bool bwrite_out_fields)
{
const std::string fname_hdf5 = the_config.GetValueSafe<std::string>("output", "fname_hdf5", "output.hdf5");
const std::string fname_analysis = the_config.GetValueSafe<std::string>("output", "fbase_analysis", "output");
const std::string fname_hdf5 = the_config.get_value_safe<std::string>("output", "fname_hdf5", "output.hdf5");
const std::string fname_analysis = the_config.get_value_safe<std::string>("output", "fbase_analysis", "output");
real_t vfac1 = vfac;
real_t vfac2 = 2 * vfac;
@ -241,7 +241,7 @@ void output_velocity_displacement_symmetries(
}
void output_convergence(
ConfigFile &the_config,
config_file &the_config,
cosmology::calculator* the_cosmo_calc,
std::size_t ngrid, real_t boxlen, real_t vfac, real_t dplus,
Grid_FFT<real_t> &phi,

View file

@ -23,9 +23,9 @@ void print_TransferFunction_plugins()
music::ilog << std::endl;
}
std::unique_ptr<TransferFunction_plugin> select_TransferFunction_plugin(ConfigFile &cf)
std::unique_ptr<TransferFunction_plugin> select_TransferFunction_plugin(config_file &cf)
{
std::string tfname = cf.GetValue<std::string>("cosmology", "transfer");
std::string tfname = cf.get_value<std::string>("cosmology", "transfer");
TransferFunction_plugin_creator *the_TransferFunction_plugin_creator = get_TransferFunction_plugin_map()[tfname];