docs(GridFire): added loads of docs and supressed yaml-cpp shadow warnings

This commit is contained in:
2025-07-24 08:37:52 -04:00
parent f20bffc411
commit c3bc75a7f4
12 changed files with 1061 additions and 122 deletions

View File

@@ -14,11 +14,24 @@
namespace py = pybind11;
const std::vector<fourdst::atomic::Species>& PyEngine::getNetworkSpecies() const {
PYBIND11_OVERRIDE_PURE(
std::vector<fourdst::atomic::Species>,
gridfire::Engine, /* Base class */
getNetworkSpecies
);
/*
* Acquire the GIL (Global Interpreter Lock) for thread safety
* with the Python interpreter.
*/
py::gil_scoped_acquire gil;
/*
* get_override() looks for a Python method that overrides this C++ one.
*/
py::function override = py::get_override(this, "getNetworkSpecies");
if (override) {
py::object result = override();
m_species_cache = result.cast<std::vector<fourdst::atomic::Species>>();
return m_species_cache;
}
py::pybind11_fail("Tried to call pure virtual function \"DynamicEngine::getNetworkSpecies\"");
}
std::expected<gridfire::StepDerivatives<double>, gridfire::expectations::StaleEngineError> PyEngine::calculateRHSAndEnergy(const std::vector<double> &Y, double T9, double rho) const {
@@ -35,11 +48,24 @@ std::expected<gridfire::StepDerivatives<double>, gridfire::expectations::StaleEn
/////////////////////////////////////
const std::vector<fourdst::atomic::Species>& PyDynamicEngine::getNetworkSpecies() const {
PYBIND11_OVERRIDE_PURE(
std::vector<fourdst::atomic::Species>,
gridfire::DynamicEngine, /* Base class */
getNetworkSpecies
);
/*
* Acquire the GIL (Global Interpreter Lock) for thread safety
* with the Python interpreter.
*/
py::gil_scoped_acquire gil;
/*
* get_override() looks for a Python method that overrides this C++ one.
*/
py::function override = py::get_override(this, "getNetworkSpecies");
if (override) {
py::object result = override();
m_species_cache = result.cast<std::vector<fourdst::atomic::Species>>();
return m_species_cache;
}
py::pybind11_fail("Tried to call pure virtual function \"DynamicEngine::getNetworkSpecies\"");
}
std::expected<gridfire::StepDerivatives<double>, gridfire::expectations::StaleEngineError> PyDynamicEngine::calculateRHSAndEnergy(const std::vector<double> &Y, double T9, double rho) const {
PYBIND11_OVERRIDE_PURE(

View File

@@ -13,9 +13,12 @@ class PyEngine final : public gridfire::Engine {
public:
const std::vector<fourdst::atomic::Species>& getNetworkSpecies() const override;
std::expected<gridfire::StepDerivatives<double>,gridfire::expectations::StaleEngineError> calculateRHSAndEnergy(const std::vector<double> &Y, double T9, double rho) const override;
private:
mutable std::vector<fourdst::atomic::Species> m_species_cache;
};
class PyDynamicEngine final : public gridfire::DynamicEngine {
public:
const std::vector<fourdst::atomic::Species>& getNetworkSpecies() const override;
std::expected<gridfire::StepDerivatives<double>,gridfire::expectations::StaleEngineError> calculateRHSAndEnergy(const std::vector<double> &Y, double T9, double rho) const override;
void generateJacobianMatrix(const std::vector<double> &Y_dynamic, double T9, double rho) const override;
@@ -41,6 +44,10 @@ class PyDynamicEngine final : public gridfire::DynamicEngine {
void rebuild(const fourdst::composition::Composition& comp, gridfire::BuildDepthType depth) override {
throw std::logic_error("Setting network depth not supported by this engine.");
}
private:
mutable std::vector<fourdst::atomic::Species> m_species_cache;
};
class PyEngineView final : public gridfire::EngineView<gridfire::Engine> {