diff --git a/build-config/json/LICENSE b/build-config/json/LICENSE new file mode 100644 index 00000000..e69de29b diff --git a/build-config/json/meson.build b/build-config/json/meson.build new file mode 100644 index 00000000..e69de29b diff --git a/src/include/gridfire/exceptions/general.h b/src/include/gridfire/exceptions/debug.h similarity index 84% rename from src/include/gridfire/exceptions/general.h rename to src/include/gridfire/exceptions/debug.h index 8e39f169..d7b9acd2 100644 --- a/src/include/gridfire/exceptions/general.h +++ b/src/include/gridfire/exceptions/debug.h @@ -4,8 +4,10 @@ #include #include +#include "gridfire/exceptions/gridfire_exception.h" + namespace gridfire::exceptions { - class DebugException final : public std::runtime_error { + class DebugException final : public GridFireError{ public: #ifdef NDEBUG #if defined(__clang__) @@ -18,10 +20,8 @@ namespace gridfire::exceptions { explicit DebugException(const std::string_view message, const std::source_location loc = std::source_location::current()) - : std::runtime_error(format_error(message, loc)) - { + : GridFireError(format_error(message, loc)) { } - private: static std::string format_error(std::string_view message, const std::source_location loc) { return std::format("[DEBUG HALT] {}:{}: {}", diff --git a/src/include/gridfire/exceptions/error_engine.h b/src/include/gridfire/exceptions/error_engine.h index d7875d92..f87c308f 100644 --- a/src/include/gridfire/exceptions/error_engine.h +++ b/src/include/gridfire/exceptions/error_engine.h @@ -5,150 +5,52 @@ #include #include +#include "gridfire/exceptions/gridfire_exception.h" + namespace gridfire::exceptions { - class EngineError : public std::exception {}; - - class StaleEngineTrigger final : public EngineError { - public: - struct state { - double m_T9; - double m_rho; - std::vector m_Y; - double m_t; - int m_total_steps; - double m_eps_nuc; - }; - explicit StaleEngineTrigger(state s) - : m_state(std::move(s)) {} - - [[nodiscard]] const char* what() const noexcept override{ - return "Engine reports stale state. This means that the caller should trigger a update of the engine state before continuing with the integration. If you as an end user are seeing this error, it is likely a bug in the code that should be reported. Please provide the input parameters and the context in which this error occurred. Thank you for your help!"; - } - - [[nodiscard]] state getState() const { - return m_state; - } - - [[nodiscard]] size_t numSpecies() const { - return m_state.m_Y.size(); - } - - [[nodiscard]] size_t totalSteps() const { - return m_state.m_total_steps; - } - - [[nodiscard]] double energy() const { - return m_state.m_eps_nuc; - } - - [[nodiscard]] double getMolarAbundance(const size_t index) const { - if (index > m_state.m_Y.size() - 1) { - throw std::out_of_range("Index out of bounds for molar abundance vector."); - } - return m_state.m_Y[index]; - } - - [[nodiscard]] double temperature() const { - return m_state.m_T9 * 1e9; // Convert T9 back to Kelvin - } - - [[nodiscard]] double density() const { - return m_state.m_rho; - } - private: - state m_state; - - }; - - class StaleEngineError final : public EngineError { - public: - explicit StaleEngineError(std::string message) - : m_message(std::move(message)) {} - - [[nodiscard]] const char* what() const noexcept override { - return m_message.c_str(); - } - - private: - std::string m_message; + class EngineError : public GridFireError { + using GridFireError::GridFireError; }; class FailedToPartitionEngineError final : public EngineError { - public: - explicit FailedToPartitionEngineError(std::string message) - : m_message(std::move(message)) {} - - [[nodiscard]] const char* what() const noexcept override { - return m_message.c_str(); - } - private: - std::string m_message; + using EngineError::EngineError; }; class NetworkResizedError final : public EngineError { - public: - explicit NetworkResizedError(std::string message) - : m_message(std::move(message)) {} - - [[nodiscard]] const char* what() const noexcept override { - return m_message.c_str(); - } - private: - std::string m_message; + using EngineError::EngineError; }; class UnableToSetNetworkReactionsError final : public EngineError { - public: - explicit UnableToSetNetworkReactionsError(std::string message) - : m_message(std::move(message)) {} - - [[nodiscard]] const char* what() const noexcept override { - return m_message.c_str(); - } - - private: - std::string m_message; - }; - - class JacobianError : public EngineError {}; - - class StaleJacobianError final : public JacobianError { - public: - explicit StaleJacobianError(std::string message) : m_message(std::move(message)) {} - [[nodiscard]] const char* what() const noexcept override { - return m_message.c_str(); - } - - private: - std::string m_message; - }; - - class UninitializedJacobianError final: public JacobianError { - public: - explicit UninitializedJacobianError(std::string message): m_message(std::move(message)) {} - [[nodiscard]] const char* what() const noexcept override { - return m_message.c_str(); - } - private: - std::string m_message; - }; - - class UnknownJacobianError final : public JacobianError { - public: - explicit UnknownJacobianError(std::string message): m_message(std::move(message)) {} - [[nodiscard]] const char* what() const noexcept override { - return m_message.c_str(); - } - private: - std::string m_message; + using EngineError::EngineError; }; class BadCollectionError final : public EngineError { - public: - explicit BadCollectionError(std::string message): m_message(std::move(message)) {} - [[nodiscard]] const char* what() const noexcept override { return m_message.c_str(); } - private: - std::string m_message; + using EngineError::EngineError; }; + class InvalidQSESolutionError final : public EngineError { + using EngineError::EngineError; + }; + + class BadRHSEngineError final : public EngineError { + using EngineError::EngineError; + }; + + class JacobianError : public EngineError { + using EngineError::EngineError; + }; + + class StaleJacobianError final : public JacobianError { + using JacobianError::JacobianError; + }; + + class UninitializedJacobianError final: public JacobianError { + using JacobianError::JacobianError; + }; + + class UnknownJacobianError final : public JacobianError { + using JacobianError::JacobianError; + }; + + } \ No newline at end of file diff --git a/src/include/gridfire/exceptions/error_policy.h b/src/include/gridfire/exceptions/error_policy.h index ff52a4b1..5227bb9b 100644 --- a/src/include/gridfire/exceptions/error_policy.h +++ b/src/include/gridfire/exceptions/error_policy.h @@ -15,6 +15,8 @@ #include #include +#include "gridfire/exceptions/gridfire_exception.h" + namespace gridfire::exceptions { /** * @class PolicyError @@ -23,23 +25,8 @@ namespace gridfire::exceptions { * This exception is the parent for more specific policy-related errors. Catching this * type will catch any exception originating from the policy system. */ - class PolicyError : public std::exception { - public: - /** - * @brief Constructs a PolicyError with a descriptive message. - * @param msg The error message. - */ - explicit PolicyError(std::string msg) : m_message(std::move(msg)) {}; - - /** - * @brief Returns the explanatory string. - * @return A C-style string with the error message. - */ - [[nodiscard]] const char* what() const noexcept override { - return m_message.c_str(); - } - private: - std::string m_message; + class PolicyError : public GridFireError { + using GridFireError::GridFireError; }; /** @@ -50,12 +37,7 @@ namespace gridfire::exceptions { * reaction library used by GridFire does not contain a reaction specified by the policy. */ class MissingBaseReactionError final : public PolicyError { - public: - /** - * @brief Constructs a MissingBaseReactionError with a descriptive message. - * @param msg The error message. - */ - explicit MissingBaseReactionError(const std::string& msg) : PolicyError(msg) {}; + using PolicyError::PolicyError; }; /** @@ -66,12 +48,7 @@ namespace gridfire::exceptions { * one or more of the essential species needed to construct the network. */ class MissingSeedSpeciesError final : public PolicyError { - public: - /** - * @brief Constructs a MissingSeedSpeciesError with a descriptive message. - * @param msg The error message. - */ - explicit MissingSeedSpeciesError(const std::string& msg) : PolicyError(msg) {}; + using PolicyError::PolicyError; }; /** @@ -82,11 +59,6 @@ namespace gridfire::exceptions { * the network has been built but fails the final verification step. */ class MissingKeyReactionError final : public PolicyError { - public: - /** - * @brief Constructs a MissingKeyReactionError with a descriptive message. - * @param msg The error message. - */ - explicit MissingKeyReactionError(const std::string& msg) : PolicyError(msg) {} + using PolicyError::PolicyError; }; } \ No newline at end of file diff --git a/src/include/gridfire/exceptions/error_reaction.h b/src/include/gridfire/exceptions/error_reaction.h index 91c6d523..120a9206 100644 --- a/src/include/gridfire/exceptions/error_reaction.h +++ b/src/include/gridfire/exceptions/error_reaction.h @@ -4,16 +4,19 @@ #include #include +#include "gridfire/exceptions/gridfire_exception.h" + namespace gridfire::exceptions { - class ReactionError : public std::exception { + class ReactionError : public GridFireError { private: std::string m_message; std::string m_reactionID; public: - ReactionError(const std::string& msg, const std::string& reactionId) { + ReactionError(const std::string& msg, const std::string& reactionId) : GridFireError(msg) { m_reactionID = reactionId; m_message = std::format("Reaction {}: {}", reactionId, msg); } + const char* what() const noexcept override { return m_message.c_str(); } diff --git a/src/include/gridfire/exceptions/error_solver.h b/src/include/gridfire/exceptions/error_solver.h index 041e6159..e1097190 100644 --- a/src/include/gridfire/exceptions/error_solver.h +++ b/src/include/gridfire/exceptions/error_solver.h @@ -1,22 +1,10 @@ #pragma once -#include -#include +#include "gridfire/exceptions/gridfire_exception.h" namespace gridfire::exceptions { - class SolverError : public std::exception { - public: - SolverError(std::string msg) : m_msg(std::move(msg)) {} - - [[nodiscard]] const char* what() const noexcept override { - return m_msg.c_str(); - } - private: - std::string m_msg; - }; - - class CVODESolverFailureError final : public SolverError { - using SolverError::SolverError; + class SolverError : GridFireError { + using GridFireError::GridFireError; }; class SingularJacobianError final : public SolverError { @@ -26,4 +14,17 @@ namespace gridfire::exceptions { class IllConditionedJacobianError final : public SolverError { using SolverError::SolverError; }; + + class SUNDIALSError : public SolverError { + using SolverError::SolverError; + }; + + class CVODESolverFailureError final : public SUNDIALSError { + using SUNDIALSError::SUNDIALSError; + }; + + class KINSolSolverFailureError final : public SUNDIALSError { + using SUNDIALSError::SUNDIALSError; + }; + } \ No newline at end of file diff --git a/src/include/gridfire/exceptions/error_utils.h b/src/include/gridfire/exceptions/error_utils.h index feeb0c0c..61cb9513 100644 --- a/src/include/gridfire/exceptions/error_utils.h +++ b/src/include/gridfire/exceptions/error_utils.h @@ -4,22 +4,14 @@ #include #include -namespace gridfire::exceptions { - class UtilityError : public std::exception { - public: - explicit UtilityError(std::string message) : m_message(std::move(message)) {} +#include "gridfire/exceptions/gridfire_exception.h" - [[nodiscard]] const char* what() const noexcept override { - return m_message.c_str(); - } - private: - std::string m_message; +namespace gridfire::exceptions { + class UtilityError : public GridFireError { + using GridFireError::GridFireError; }; class HashingError final : public UtilityError { - public: - - explicit HashingError(const std::string &message) : UtilityError(message) {} - + using UtilityError::UtilityError; }; } diff --git a/src/include/gridfire/exceptions/exceptions.h b/src/include/gridfire/exceptions/exceptions.h index e57bd8f7..3faad90e 100644 --- a/src/include/gridfire/exceptions/exceptions.h +++ b/src/include/gridfire/exceptions/exceptions.h @@ -1,8 +1,9 @@ #pragma once +#include "gridfire/exceptions/gridfire_exception.h" #include "gridfire/exceptions/error_engine.h" #include "gridfire/exceptions/error_utils.h" -#include "gridfire/exceptions/general.h" +#include "gridfire/exceptions/debug.h" #include "gridfire/exceptions/error_policy.h" #include "gridfire/exceptions/error_reaction.h" #include "gridfire/exceptions/error_solver.h" diff --git a/src/include/gridfire/exceptions/gridfire_exception.h b/src/include/gridfire/exceptions/gridfire_exception.h new file mode 100644 index 00000000..0ee95a3c --- /dev/null +++ b/src/include/gridfire/exceptions/gridfire_exception.h @@ -0,0 +1,17 @@ +#pragma once +#include + +#include + +namespace gridfire::exceptions { + class GridFireError : public std::exception { + public: + explicit GridFireError(std::string msg) : m_msg(std::move(msg)) {} + + [[nodiscard]] const char* what() const noexcept override { + return m_msg.c_str(); + } + private: + std::string m_msg; + }; +} diff --git a/src/include/gridfire/gridfire.h b/src/include/gridfire/gridfire.h new file mode 100644 index 00000000..e69de29b diff --git a/src/include/gridfire/policy/policy.h b/src/include/gridfire/policy/policy.h new file mode 100644 index 00000000..e69de29b diff --git a/src/include/gridfire/solver/strategies/strategies.h b/src/include/gridfire/solver/strategies/strategies.h new file mode 100644 index 00000000..e69de29b diff --git a/src/include/gridfire/solver/strategies/strategy_abstract.h b/src/include/gridfire/solver/strategies/strategy_abstract.h new file mode 100644 index 00000000..e69de29b diff --git a/src/include/gridfire/solver/strategies/triggers/triggers.h b/src/include/gridfire/solver/strategies/triggers/triggers.h new file mode 100644 index 00000000..e69de29b diff --git a/src/include/gridfire/trigger/procedures/trigger_procedures.h b/src/include/gridfire/trigger/procedures/trigger_procedures.h new file mode 100644 index 00000000..e69de29b diff --git a/src/include/gridfire/trigger/trigger.h b/src/include/gridfire/trigger/trigger.h new file mode 100644 index 00000000..e69de29b diff --git a/src/include/gridfire/utils/formatters/formatters.h b/src/include/gridfire/utils/formatters/formatters.h new file mode 100644 index 00000000..e69de29b diff --git a/src/include/gridfire/utils/formatters/jacobian_format.h b/src/include/gridfire/utils/formatters/jacobian_format.h new file mode 100644 index 00000000..e69de29b diff --git a/src/include/gridfire/utils/utils.h b/src/include/gridfire/utils/utils.h new file mode 100644 index 00000000..e69de29b