feat(libconfig): new version of libconfig
This commit is contained in:
3
.gitignore
vendored
3
.gitignore
vendored
@@ -82,6 +82,7 @@ subprojects/cvode-*/
|
|||||||
subprojects/kinsol-*/
|
subprojects/kinsol-*/
|
||||||
subprojects/CLI11-*/
|
subprojects/CLI11-*/
|
||||||
subprojects/openssl-*/
|
subprojects/openssl-*/
|
||||||
|
subprojects/tomlplusplus-*/
|
||||||
*.fbundle
|
*.fbundle
|
||||||
*.wraplock
|
*.wraplock
|
||||||
|
|
||||||
@@ -98,6 +99,8 @@ liblogging.wrap
|
|||||||
libplugin.wrap
|
libplugin.wrap
|
||||||
minizip-ng.wrap
|
minizip-ng.wrap
|
||||||
openssl.wrap
|
openssl.wrap
|
||||||
|
glaze.wrap
|
||||||
|
tomlplusplus.wrap
|
||||||
|
|
||||||
.vscode/
|
.vscode/
|
||||||
|
|
||||||
|
|||||||
@@ -30,7 +30,6 @@ endif
|
|||||||
|
|
||||||
libcomposition = fourdst_sp.get_variable('libcomposition')
|
libcomposition = fourdst_sp.get_variable('libcomposition')
|
||||||
libconst = fourdst_sp.get_variable('libconst')
|
libconst = fourdst_sp.get_variable('libconst')
|
||||||
libconfig = fourdst_sp.get_variable('libconfig')
|
|
||||||
liblogging = fourdst_sp.get_variable('liblogging')
|
liblogging = fourdst_sp.get_variable('liblogging')
|
||||||
|
|
||||||
if get_option('plugin_support')
|
if get_option('plugin_support')
|
||||||
|
|||||||
@@ -8,7 +8,6 @@ if get_option('pkg_config')
|
|||||||
libraries: [
|
libraries: [
|
||||||
libgridfire,
|
libgridfire,
|
||||||
libcomposition,
|
libcomposition,
|
||||||
libconfig,
|
|
||||||
libconst,
|
libconst,
|
||||||
liblogging
|
liblogging
|
||||||
],
|
],
|
||||||
|
|||||||
@@ -38,6 +38,8 @@ subdir('build-python')
|
|||||||
# Buil the test suite
|
# Buil the test suite
|
||||||
subdir('tests')
|
subdir('tests')
|
||||||
|
|
||||||
|
subdir('tools')
|
||||||
|
|
||||||
# Build the pkg-config file
|
# Build the pkg-config file
|
||||||
subdir('build-extra/pkg-config')
|
subdir('build-extra/pkg-config')
|
||||||
|
|
||||||
|
|||||||
@@ -8,3 +8,4 @@ option('unsafe_fortran', type: 'boolean', value: false, description: 'Allow unte
|
|||||||
option('plugin_support', type: 'boolean', value: false, description: 'Enable support for libplugin plugins')
|
option('plugin_support', type: 'boolean', value: false, description: 'Enable support for libplugin plugins')
|
||||||
option('python_target_version', type: 'string', value: '3.13', description: 'Target version for python compilation, only used for cross compilation')
|
option('python_target_version', type: 'string', value: '3.13', description: 'Target version for python compilation, only used for cross compilation')
|
||||||
option('build_c_api', type: 'boolean', value: true, description: 'compile the C API')
|
option('build_c_api', type: 'boolean', value: true, description: 'compile the C API')
|
||||||
|
option('build_tools', type: 'boolean', value: true, description: 'build the GridFire command line tools')
|
||||||
|
|||||||
35
src/include/gridfire/config/config.h
Normal file
35
src/include/gridfire/config/config.h
Normal file
@@ -0,0 +1,35 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "fourdst/config/config.h"
|
||||||
|
|
||||||
|
namespace gridfire::config {
|
||||||
|
struct CVODESolverConfig {
|
||||||
|
double absTol = 1.0e-8;
|
||||||
|
double relTol = 1.0e-5;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct SolverConfig {
|
||||||
|
CVODESolverConfig cvode;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct AdaptiveEngineViewConfig {
|
||||||
|
double relativeCullingThreshold = 1.0e-75;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct EngineViewConfig {
|
||||||
|
AdaptiveEngineViewConfig adaptiveEngineView;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct EngineConfig {
|
||||||
|
EngineViewConfig views;
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
struct GridFireConfig {
|
||||||
|
SolverConfig solver;
|
||||||
|
EngineConfig engine;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@@ -12,6 +12,7 @@
|
|||||||
#include "gridfire/screening/screening_types.h"
|
#include "gridfire/screening/screening_types.h"
|
||||||
#include "gridfire/partition/partition_abstract.h"
|
#include "gridfire/partition/partition_abstract.h"
|
||||||
#include "gridfire/engine/procedures/construction.h"
|
#include "gridfire/engine/procedures/construction.h"
|
||||||
|
#include "gridfire/config/config.h"
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <unordered_map>
|
#include <unordered_map>
|
||||||
@@ -855,7 +856,7 @@ namespace gridfire::engine {
|
|||||||
const GraphEngine& m_engine;
|
const GraphEngine& m_engine;
|
||||||
};
|
};
|
||||||
private:
|
private:
|
||||||
Config& m_config = Config::getInstance();
|
Config<config::GridFireConfig> m_config;
|
||||||
quill::Logger* m_logger = LogManager::getInstance().getLogger("log");
|
quill::Logger* m_logger = LogManager::getInstance().getLogger("log");
|
||||||
|
|
||||||
constants m_constants;
|
constants m_constants;
|
||||||
|
|||||||
@@ -4,6 +4,7 @@
|
|||||||
#include "gridfire/screening/screening_abstract.h"
|
#include "gridfire/screening/screening_abstract.h"
|
||||||
#include "gridfire/screening/screening_types.h"
|
#include "gridfire/screening/screening_types.h"
|
||||||
#include "gridfire/types/types.h"
|
#include "gridfire/types/types.h"
|
||||||
|
#include "gridfire/config/config.h"
|
||||||
|
|
||||||
#include "fourdst/atomic/atomicSpecies.h"
|
#include "fourdst/atomic/atomicSpecies.h"
|
||||||
#include "fourdst/config/config.h"
|
#include "fourdst/config/config.h"
|
||||||
@@ -386,10 +387,10 @@ namespace gridfire::engine {
|
|||||||
*/
|
*/
|
||||||
[[nodiscard]] SpeciesStatus getSpeciesStatus(const fourdst::atomic::Species &species) const override;
|
[[nodiscard]] SpeciesStatus getSpeciesStatus(const fourdst::atomic::Species &species) const override;
|
||||||
private:
|
private:
|
||||||
using Config = fourdst::config::Config;
|
|
||||||
using LogManager = fourdst::logging::LogManager;
|
using LogManager = fourdst::logging::LogManager;
|
||||||
/** @brief A reference to the singleton Config instance, used for retrieving configuration parameters. */
|
|
||||||
Config& m_config = Config::getInstance();
|
fourdst::config::Config<config::GridFireConfig> m_config;
|
||||||
|
|
||||||
/** @brief A pointer to the logger instance, used for logging messages. */
|
/** @brief A pointer to the logger instance, used for logging messages. */
|
||||||
quill::Logger* m_logger = LogManager::getInstance().getLogger("log");
|
quill::Logger* m_logger = LogManager::getInstance().getLogger("log");
|
||||||
|
|
||||||
|
|||||||
@@ -6,6 +6,8 @@
|
|||||||
#include "gridfire/io/network_file.h"
|
#include "gridfire/io/network_file.h"
|
||||||
#include "gridfire/types/types.h"
|
#include "gridfire/types/types.h"
|
||||||
|
|
||||||
|
#include "gridfire/config/config.h"
|
||||||
|
|
||||||
#include "fourdst/config/config.h"
|
#include "fourdst/config/config.h"
|
||||||
#include "fourdst/logging/logging.h"
|
#include "fourdst/logging/logging.h"
|
||||||
|
|
||||||
@@ -365,9 +367,9 @@ namespace gridfire::engine {
|
|||||||
[[nodiscard]] std::string getNetworkFile() const { return m_fileName; }
|
[[nodiscard]] std::string getNetworkFile() const { return m_fileName; }
|
||||||
[[nodiscard]] const io::NetworkFileParser& getParser() const { return m_parser; }
|
[[nodiscard]] const io::NetworkFileParser& getParser() const { return m_parser; }
|
||||||
private:
|
private:
|
||||||
using Config = fourdst::config::Config;
|
using LogManager = LogManager;
|
||||||
using LogManager = fourdst::logging::LogManager;
|
Config<config::GridFireConfig> m_config;
|
||||||
Config& m_config = Config::getInstance();
|
|
||||||
quill::Logger* m_logger = LogManager::getInstance().getLogger("log");
|
quill::Logger* m_logger = LogManager::getInstance().getLogger("log");
|
||||||
std::string m_fileName;
|
std::string m_fileName;
|
||||||
///< Parser for the network file.
|
///< Parser for the network file.
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
#include "fourdst/config/config.h"
|
#include "fourdst/config/config.h"
|
||||||
#include "fourdst/logging/logging.h"
|
#include "fourdst/logging/logging.h"
|
||||||
|
#include "gridfire/config/config.h"
|
||||||
|
|
||||||
#include "quill/Logger.h"
|
#include "quill/Logger.h"
|
||||||
|
|
||||||
@@ -101,9 +102,8 @@ namespace gridfire::io {
|
|||||||
*/
|
*/
|
||||||
[[nodiscard]] ParsedNetworkData parse(const std::string& filename) const override;
|
[[nodiscard]] ParsedNetworkData parse(const std::string& filename) const override;
|
||||||
private:
|
private:
|
||||||
using Config = fourdst::config::Config;
|
|
||||||
using LogManager = fourdst::logging::LogManager;
|
using LogManager = fourdst::logging::LogManager;
|
||||||
Config& m_config = Config::getInstance();
|
fourdst::config::Config<config::GridFireConfig> m_config;
|
||||||
quill::Logger* m_logger = LogManager::getInstance().getLogger("log");
|
quill::Logger* m_logger = LogManager::getInstance().getLogger("log");
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -141,9 +141,8 @@ namespace gridfire::io {
|
|||||||
*/
|
*/
|
||||||
[[nodiscard]] ParsedNetworkData parse(const std::string& filename) const override;
|
[[nodiscard]] ParsedNetworkData parse(const std::string& filename) const override;
|
||||||
private:
|
private:
|
||||||
using Config = fourdst::config::Config;
|
|
||||||
using LogManager = fourdst::logging::LogManager;
|
using LogManager = fourdst::logging::LogManager;
|
||||||
Config& m_config = Config::getInstance();
|
fourdst::config::Config<config::GridFireConfig> m_config;
|
||||||
quill::Logger* m_logger = LogManager::getInstance().getLogger("log");
|
quill::Logger* m_logger = LogManager::getInstance().getLogger("log");
|
||||||
|
|
||||||
std::string m_filename;
|
std::string m_filename;
|
||||||
|
|||||||
@@ -4,6 +4,7 @@
|
|||||||
#include "gridfire/engine/engine_abstract.h"
|
#include "gridfire/engine/engine_abstract.h"
|
||||||
#include "gridfire/types/types.h"
|
#include "gridfire/types/types.h"
|
||||||
#include "gridfire/exceptions/exceptions.h"
|
#include "gridfire/exceptions/exceptions.h"
|
||||||
|
#include "gridfire/config/config.h"
|
||||||
|
|
||||||
#include "fourdst/atomic/atomicSpecies.h"
|
#include "fourdst/atomic/atomicSpecies.h"
|
||||||
#include "fourdst/config/config.h"
|
#include "fourdst/config/config.h"
|
||||||
@@ -243,7 +244,7 @@ namespace gridfire::solver {
|
|||||||
};
|
};
|
||||||
|
|
||||||
private:
|
private:
|
||||||
fourdst::config::Config& m_config = fourdst::config::Config::getInstance();
|
fourdst::config::Config<config::GridFireConfig> m_config;
|
||||||
quill::Logger* m_logger = fourdst::logging::LogManager::getInstance().getLogger("log");
|
quill::Logger* m_logger = fourdst::logging::LogManager::getInstance().getLogger("log");
|
||||||
/**
|
/**
|
||||||
* @brief CVODE RHS C-wrapper that delegates to calculate_rhs and captures exceptions.
|
* @brief CVODE RHS C-wrapper that delegates to calculate_rhs and captures exceptions.
|
||||||
|
|||||||
@@ -394,7 +394,9 @@ namespace gridfire::engine {
|
|||||||
const double maxFlow
|
const double maxFlow
|
||||||
) const {
|
) const {
|
||||||
LOG_TRACE_L1(m_logger, "Culling reactions based on flow rates...");
|
LOG_TRACE_L1(m_logger, "Culling reactions based on flow rates...");
|
||||||
const auto relative_culling_threshold = m_config.get<double>("gridfire:AdaptiveEngineView:RelativeCullingThreshold", 1e-75);
|
|
||||||
|
const auto relative_culling_threshold = m_config->engine.views.adaptiveEngineView.relativeCullingThreshold;
|
||||||
|
|
||||||
double absoluteCullingThreshold = relative_culling_threshold * maxFlow;
|
double absoluteCullingThreshold = relative_culling_threshold * maxFlow;
|
||||||
LOG_DEBUG(m_logger, "Relative culling threshold: {:7.3E} ({:7.3E})", relative_culling_threshold, absoluteCullingThreshold);
|
LOG_DEBUG(m_logger, "Relative culling threshold: {:7.3E} ({:7.3E})", relative_culling_threshold, absoluteCullingThreshold);
|
||||||
std::vector<const reaction::Reaction*> culledReactions;
|
std::vector<const reaction::Reaction*> culledReactions;
|
||||||
|
|||||||
@@ -112,8 +112,8 @@ namespace gridfire::solver {
|
|||||||
// 2. If the user has set tolerances in code, those override the config
|
// 2. If the user has set tolerances in code, those override the config
|
||||||
// 3. If the user has not set tolerances in code and the config does not have them, use hardcoded defaults
|
// 3. If the user has not set tolerances in code and the config does not have them, use hardcoded defaults
|
||||||
|
|
||||||
auto absTol = m_config.get<double>("gridfire:solver:CVODESolverStrategy:absTol", 1.0e-8);
|
auto absTol = m_config->solver.cvode.absTol;
|
||||||
auto relTol = m_config.get<double>("gridfire:solver:CVODESolverStrategy:relTol", 1.0e-5);
|
auto relTol = m_config->solver.cvode.relTol;
|
||||||
|
|
||||||
if (m_absTol) {
|
if (m_absTol) {
|
||||||
absTol = *m_absTol;
|
absTol = *m_absTol;
|
||||||
@@ -935,8 +935,8 @@ namespace gridfire::solver {
|
|||||||
sunrealtype *y_data = N_VGetArrayPointer(m_Y);
|
sunrealtype *y_data = N_VGetArrayPointer(m_Y);
|
||||||
sunrealtype *y_err_data = N_VGetArrayPointer(m_YErr);
|
sunrealtype *y_err_data = N_VGetArrayPointer(m_YErr);
|
||||||
|
|
||||||
const auto absTol = m_config.get<double>("gridfire:solver:CVODESolverStrategy:absTol", 1.0e-8);
|
const auto absTol = m_config->solver.cvode.absTol;
|
||||||
const auto relTol = m_config.get<double>("gridfire:solver:CVODESolverStrategy:relTol", 1.0e-8);
|
const auto relTol = m_config->solver.cvode.relTol;
|
||||||
|
|
||||||
std::vector<double> err_ratios;
|
std::vector<double> err_ratios;
|
||||||
const size_t num_components = N_VGetLength(m_Y);
|
const size_t num_components = N_VGetLength(m_Y);
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
[wrap-git]
|
[wrap-git]
|
||||||
url = https://github.com/4D-STAR/fourdst
|
url = https://github.com/4D-STAR/fourdst
|
||||||
revision = v0.9.13
|
revision = v0.9.14
|
||||||
depth = 1
|
depth = 1
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
executable(
|
executable(
|
||||||
'graphnet_sandbox',
|
'graphnet_sandbox',
|
||||||
'main.cpp',
|
'main.cpp',
|
||||||
dependencies: [gridfire_dep, composition_dep, cli11_dep],
|
dependencies: [gridfire_dep, cli11_dep],
|
||||||
)
|
)
|
||||||
|
|||||||
48
tools/config/generate_config_files.cpp
Normal file
48
tools/config/generate_config_files.cpp
Normal file
@@ -0,0 +1,48 @@
|
|||||||
|
#include "fourdst/config/config.h"
|
||||||
|
#include "gridfire/config/config.h"
|
||||||
|
#include <source_location>
|
||||||
|
#include <filesystem>
|
||||||
|
|
||||||
|
#include "CLI/CLI.hpp"
|
||||||
|
|
||||||
|
consteval std::string_view strip_namespaces(const std::string_view fullName) {
|
||||||
|
const size_t pos = fullName.rfind("::");
|
||||||
|
if (pos == std::string_view::npos) {
|
||||||
|
return fullName;
|
||||||
|
}
|
||||||
|
return fullName.substr(pos + 2);
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
consteval std::string_view get_type_name() {
|
||||||
|
constexpr std::string_view name = std::source_location::current().function_name();
|
||||||
|
const auto pos = name.find("T = ");
|
||||||
|
if (pos == std::string_view::npos) return name;
|
||||||
|
const auto start = pos + 4;
|
||||||
|
const auto end = name.rfind(']');
|
||||||
|
return name.substr(start, end - start);
|
||||||
|
}
|
||||||
|
|
||||||
|
int main(int argc, char** argv) {
|
||||||
|
CLI::App app{"GridFire Sandbox Application."};
|
||||||
|
|
||||||
|
std::string outputPath = ".";
|
||||||
|
|
||||||
|
app.add_option("-p,--path", outputPath, "path to save generated config files (default: current directory)");
|
||||||
|
|
||||||
|
CLI11_PARSE(app, argc, argv);
|
||||||
|
|
||||||
|
const std::filesystem::path outPath(outputPath);
|
||||||
|
if (!std::filesystem::exists(outPath)) {
|
||||||
|
std::cerr << "Error: The specified path does not exist: " << outputPath << std::endl;
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
fourdst::config::Config<gridfire::config::GridFireConfig> configConfig;
|
||||||
|
const std::string_view name = strip_namespaces(get_type_name<gridfire::config::GridFireConfig>());
|
||||||
|
|
||||||
|
const std::string defaultConfigFilePath = (outPath / (std::string(name) + ".toml")).string();
|
||||||
|
const std::string schemaFilePath = (outPath / (std::string(name) + ".schema.json")).string();
|
||||||
|
configConfig.save(defaultConfigFilePath);
|
||||||
|
configConfig.save_schema(schemaFilePath);
|
||||||
|
}
|
||||||
1
tools/config/meson.build
Normal file
1
tools/config/meson.build
Normal file
@@ -0,0 +1 @@
|
|||||||
|
executable('gf_generate_config_file', 'generate_config_files.cpp', dependencies: [gridfire_dep, cli11_dep], install: true)
|
||||||
3
tools/meson.build
Normal file
3
tools/meson.build
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
if get_option('build_tools')
|
||||||
|
subdir('config')
|
||||||
|
endif
|
||||||
Reference in New Issue
Block a user