fix(gcc): Fixed Gridfire on gcc

GridFire failed to compile on gcc and gnu stdlibc++ this has been
resolved. Further, the boost dependency has been removed since we no
longer use boost at all. This should dramatically simplify installation.
Finally we have added some build system checks to ensure that the
correct version of a C++ and fortran compiler are present on the system
This commit is contained in:
2025-11-28 09:42:54 -05:00
parent 08a031f30c
commit 033c5a083d
11 changed files with 42 additions and 67 deletions

View File

@@ -20,7 +20,6 @@
#include <ranges>
#include <functional>
#include <boost/numeric/ublas/matrix_sparse.hpp>
#include "cppad/cppad.hpp"
#include "cppad/utility/sparse_rc.hpp"
@@ -863,7 +862,6 @@ namespace gridfire::engine {
std::unordered_map<fourdst::atomic::Species, size_t> m_speciesToIndexMap; ///< Map from species to their index in the stoichiometry matrix.
std::unordered_map<size_t, fourdst::atomic::Species> m_indexToSpeciesMap; ///< Map from index to species in the stoichiometry matrix.
boost::numeric::ublas::compressed_matrix<int> m_stoichiometryMatrix; ///< Stoichiometry matrix (species x reactions).
mutable CppAD::ADFun<double> m_rhsADFun; ///< CppAD function for the right-hand side of the ODE.
mutable CppAD::ADFun<double> m_epsADFun; ///< CppAD function for the energy generation rate.
@@ -1281,4 +1279,4 @@ namespace gridfire::engine {
return molar_concentration_product * k_reaction * densityTerm;
}
};
};

View File

@@ -24,9 +24,6 @@
#include <fstream>
#include <ranges>
#include <boost/numeric/odeint.hpp>
#include <boost/numeric/ublas/matrix_sparse.hpp>
#include "cppad/cppad.hpp"
#include "cppad/utility/sparse_rc.hpp"
#include "cppad/utility/sparse_rcv.hpp"
@@ -819,9 +816,9 @@ namespace gridfire::engine {
LOG_TRACE_L1(m_logger, "Generating stoichiometry matrix...");
// Task 1: Set dimensions and initialize the matrix
size_t numSpecies = m_networkSpecies.size();
size_t numReactions = m_reactions.size();
m_stoichiometryMatrix.resize(numSpecies, numReactions, false);
// size_t numSpecies = m_networkSpecies.size();
// size_t numReactions = m_reactions.size();
// m_stoichiometryMatrix.resize(numSpecies, numReactions, false);
LOG_TRACE_L1(m_logger, "Stoichiometry matrix initialized with dimensions: {} rows (species) x {} columns (reactions).",
numSpecies, numReactions);
@@ -838,9 +835,9 @@ namespace gridfire::engine {
// Find the row index for this species
auto it = m_speciesToIndexMap.find(species);
if (it != m_speciesToIndexMap.end()) {
const size_t speciesRowIndex = it->second;
// const size_t speciesRowIndex = it->second;
// Set the matrix element. Boost.uBLAS handles sparse insertion.
m_stoichiometryMatrix(speciesRowIndex, reactionColumnIndex) = coefficient;
// m_stoichiometryMatrix(speciesRowIndex, reactionColumnIndex) = coefficient;
} else {
// This scenario should ideally not happen if m_networkSpeciesMap and m_speciesToIndexMap are correctly synced
LOG_ERROR(m_logger, "CRITICAL ERROR: Species '{}' from reaction '{}' stoichiometry not found in species to index map.",
@@ -852,8 +849,6 @@ namespace gridfire::engine {
reactionColumnIndex++; // Move to the next column for the next reaction
}
LOG_TRACE_L1(m_logger, "Stoichiometry matrix population complete. Number of non-zero elements: {}.",
m_stoichiometryMatrix.nnz()); // Assuming nnz() exists for compressed_matrix
}
void GraphEngine::setScreeningModel(const screening::ScreeningType model) {

View File

@@ -15,7 +15,7 @@ namespace gridfire::engine {
const Eigen::SparseMatrix<double>& jacobianMatrix,
const std::function<fourdst::atomic::Species(size_t)> &indexToSpeciesFunc
): m_jacobianMatrix(jacobianMatrix) {
for (size_t i = 0; i < jacobianMatrix.rows(); ++i) {
for (long int i = 0; i < jacobianMatrix.rows(); ++i) {
fourdst::atomic::Species species = indexToSpeciesFunc(i);
m_speciesToIndexMap[species] = i;
}
@@ -57,7 +57,7 @@ namespace gridfire::engine {
}
double NetworkJacobian::operator()(const size_t i, const size_t j) const {
if (i >= m_jacobianMatrix.rows() || j >= m_jacobianMatrix.cols()) {
if (i >= static_cast<size_t>(m_jacobianMatrix.rows()) || j >= static_cast<size_t>(m_jacobianMatrix.cols())) {
throw std::out_of_range(std::format("Index ({}, {}) out of bounds in NetworkJacobian operator() for jacobian of shape ({}, {}).", i, j, m_jacobianMatrix.rows(), m_jacobianMatrix.cols()));
}
return m_jacobianMatrix.coeff(i, j);
@@ -73,7 +73,7 @@ namespace gridfire::engine {
}
void NetworkJacobian::set(const size_t i, const size_t j, const double value) {
if (i >= m_jacobianMatrix.rows() || j >= m_jacobianMatrix.cols()) {
if (i >= static_cast<size_t>(m_jacobianMatrix.rows()) || j >= static_cast<size_t>(m_jacobianMatrix.cols())) {
throw std::out_of_range(std::format("Index ({}, {}) out of bounds in NetworkJacobian set() for jacobian of shape ({}, {}).", i, j, m_jacobianMatrix.rows(), m_jacobianMatrix.cols()));
}
m_jacobianMatrix.coeffRef(i, j) = value;

View File

@@ -31,7 +31,6 @@ gridfire_sources = files(
gridfire_build_dependencies = [
boost_dep,
const_dep,
config_dep,
composition_dep,
@@ -67,4 +66,4 @@ if get_option('build-python')
subdir('python')
else
message('Skipping Python bindings...')
endif
endif